Quite Oh’s LSL Snippets

I find it a pain in the butt to continually search though previous scripts to find out how I’ve done things, so this is simply a repository of LSL snippet that I use. It’s quick and easy for me, and I hope that some of these may serve you as well. Expect this list to grow as my scripting experiences increases. Note: The intent of this document is NOT to explain or teach, there are many far more qualified than I do perform this task; this is merely a convenience for me and those who are looking for quick and simple shortcuts to getting the job done.

Count instances of a character in a string
llGetListLength(llParseStringKeepNulls(message, ["char_to_count"], []))-1;

Using chat to do things (listeners)

// Global vars: Used for chat and menus
integer listener_handle;
integer listen_channel = 123;

// Set the listener for chat and menu commands (in default state state_entry(), usually)
listener_handle = llListen( listen_channel, "", llGetOwner(), "" );

listen(integer channel, string name, key id, string message) {
    message = llToLower(message);
    name = llToLower(name);
    if (message == "trigger_command") {
        ... do stuff here...

Pulsing a glow effect

// Glow parameters
float   gGlow                   = 0.10;
float   gGlowTop                = 0.50;
float   gGlowBottom             = 0.05;
float   gGlowIncrement          = 0.05;

// Pulse parameters 0 for decrement, 1 for increment
integer gPulseDirection         = 0;
integer gPulseSpeed            = .01;

	touch_start(integer total_number)
	// Pulse the glow
		// Glow: increment up, and down (like it's pulsing)
		if (gGlow >= gGlowTop) {
			gPulseDirection = 0;
		if (gGlow <= gGlowBottom) {
			gPulseDirection = 1;
		if ( gPulseDirection ) {
			gGlow += gGlowIncrement;
		}  else {
			gGlow -= gGlowIncrement;
		llSetPrimitiveParams([PRIM_GLOW, ALL_SIDES, gGlow]);

1 Comment

  1. Mark said,

    March 8, 2014 at 4:00 am

    Integer is wrong type on pulse rate. Should be float.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: