It's all in the wrist...

Welcome to Baddabean.com
Tuesday, September 07 2010 @ 07:56 PM MST

Friendly Greetings and some Code!

lol sorry it's been a few days, but I've been really hammered here lately..

No, not hammered in a good way, with vodka or scotch, but just really busy. I haven't had much chance to script in lsl for all the other coding I've been doing! Still, I guess that's a good thing, means things are moving along.

I did have a chance to find and comment up a script for the forum that some people keep asking about, so that was nice to pull something out and dust it off.

This is a really basic prim color changer which uses an llDialog menu and is set to owner-only. I made it for a friend a little while ago who's just learning scripting, and needed a place to start, and something to reference back to later for tidbits ;o)


key owner;
key toucher;
integer menu_channel;
integer listenhandler;
list menu_buttons = ["Blue","Green","Red","Cancel"]; //simple color choices, change for your needs

default
{
state_entry()
{
owner = llGetOwner(); //this identifies the owner when the script is reset or the item is rezzed.
}

touch_start(integer total_number)
{
toucher = llDetectedKey(0); //determine if the person who touched is the owner
if(toucher == owner) //if the toucher is the owner, do this stuff
{
menu_channel = (integer)llGetGMTclock() * -2; //this gives you a random channel based on the gmt clock time, helps keep other objects from interfering with your dialog menu.
listenhandler = llListen(menu_channel,"",toucher,""); //sets up the listen for the dialog choices
llDialog(toucher,"What color would you like?",menu_buttons,menu_channel); //actual dialog menu command
}
else //if toucher is not the owner, tell 'em to go away ;o)
{
llInstantMessage(toucher, "I'm sorry, only the owner may use this.");
}
}
changed(integer change) //reset script if owner changes
{
if(change && CHANGED_OWNER)
{
llResetScript();
}
}
listen(integer menu_channel,string name, key toucher,string choice) //tells the script what to do based on the choice made in the dialog menu
{
llListenRemove(listenhandler); // Stop listening on menu_channel
if(choice == "Blue") //These choices must match exactly the buttons in the list menu_buttons...whatever button is pushed, that will be the message sent from the dialog menu
{
llSetColor(,ALL_SIDES); //sets object color, ALL_SIDES means all the faces will change to this color. the vector (ie "" is the  value of the color you want to set.
}
else if(choice == "Green")
{
llSetColor(,ALL_SIDES);
}
else if(choice == "Red")
{
llSetColor(,ALL_SIDES);
}
else if(choice == "Cancel")
{
llResetScript();
}
}

}

Till I see ya again, remember - it's all in the wrist..


~ELQ

Trackback

Trackback URL for this entry: http://baddabean.com/trackback.php?id=20090308220557711

No trackback comments for this entry.
Friendly Greetings and some Code! | 0 comments | Create New Account
The following comments are owned by whomever posted them. This site is not responsible for what they say.