Jump to content
  • 0

LSL Linkset help needed please


joshua Bumbo
 Share

You are about to reply to a thread that has been inactive for 2973 days.

Please take a moment to consider if this thread is worth bumping.

Question

Hello every one i'm getting into more lsl now and i am a lil stuck so please bear with me. ok so i have a link set that has 5 prims total and they are ears. (Diagram Below).

_________________________

KEY:

0 - invisible

1 - visible

_________________________

0           0  <--- Ears folded back

        0       <---- Root of Linkset

1           1  <---- Ears Normal

_________________________

The ears will fold back when the phase "fold - t" on channel 3030 and when it is touched a dialog menu will pop up with buttons to interact with the ears. What I am stuck on is i need it to not to be able to actictivate the men when they are folded and when they are normal I need them to sense if it was the left or right ear.

 

Thank you,

Mew BloodStar (joshua Bumbo)

 

--Apha Script --

//LIST OF PRIMS//
// 1 - POS BALL
// 2 - LFolded
// 3 - RFolded
// 4 - R
// 5 - L
default
{
state_entry()
{
llListen(3030,"",llGetOwner(),"");
llSetLinkAlpha(1, 0.0, ALL_SIDES);
llSetLinkAlpha(2, 0.0, ALL_SIDES);
llSetLinkAlpha(3, 0.0, ALL_SIDES);
llSetLinkAlpha(4, 1.0, ALL_SIDES);
llSetLinkAlpha(5, 1.0, ALL_SIDES);
}

listen(integer channel, string name, key id, string message)
{
if (llToLower(message) == "fold -t")
{
llSetLinkAlpha(2, 1.0, ALL_SIDES);
llSetLinkAlpha(3, 1.0, ALL_SIDES);
llSetLinkAlpha(4, 0.0, ALL_SIDES);
llSetLinkAlpha(5, 0.0, ALL_SIDES);
llSleep(15.0);
llSetLinkAlpha(2, 0.0, ALL_SIDES);
llSetLinkAlpha(3, 0.0, ALL_SIDES);
llSetLinkAlpha(4, 1.0, ALL_SIDES);
llSetLinkAlpha(5, 1.0, ALL_SIDES);
}

if (llToLower(message) == "fold -m")
{
llSetLinkAlpha(2, 1.0, ALL_SIDES);
llSetLinkAlpha(3, 1.0, ALL_SIDES);
llSetLinkAlpha(4, 0.0, ALL_SIDES);
llSetLinkAlpha(5, 0.0, ALL_SIDES);
llSleep(15.0);
llSetLinkAlpha(2, 0.0, ALL_SIDES);
llSetLinkAlpha(3, 0.0, ALL_SIDES);
llSetLinkAlpha(4, 1.0, ALL_SIDES);
llSetLinkAlpha(5, 1.0, ALL_SIDES);
}

if (llToLower(message) == "fold -t -m")
{
llSetLinkAlpha(2, 1.0, ALL_SIDES);
llSetLinkAlpha(3, 1.0, ALL_SIDES);
llSetLinkAlpha(4, 0.0, ALL_SIDES);
llSetLinkAlpha(5, 0.0, ALL_SIDES);
llSleep(15.0);
llSetLinkAlpha(2, 0.0, ALL_SIDES);
llSetLinkAlpha(3, 0.0, ALL_SIDES);
llSetLinkAlpha(4, 1.0, ALL_SIDES);
llSetLinkAlpha(5, 1.0, ALL_SIDES);
}

if (llToLower(message) == "fold -h")
{
llSetLinkAlpha(2, 1.0, ALL_SIDES);
llSetLinkAlpha(3, 1.0, ALL_SIDES);
llSetLinkAlpha(4, 0.0, ALL_SIDES);
llSetLinkAlpha(5, 0.0, ALL_SIDES);
}

if (llToLower(message) == "unfold")
{
llSetLinkAlpha(2, 0.0, ALL_SIDES);
llSetLinkAlpha(3, 0.0, ALL_SIDES);
llSetLinkAlpha(4, 1.0, ALL_SIDES);
llSetLinkAlpha(5, 1.0, ALL_SIDES);
}
}
}

 

--Dialog script for left only (Right is the same)--

list buttons = ["-", "Flick", "Bite", "Pull", "Tickle", "Scratch", "Kiss", "Play", "Poke", "Kiss OWEE"];
string dialogInfo = "\nPlease make a choice.";

key ToucherID;
integer dialogChannel;
integer listenHandle;

default
{
state_entry()
{
dialogChannel = -1 - (integer)("0x" + llGetSubString( (string)llGetKey(), -7, -1) );
}

touch_start(integer num_detected)
{
ToucherID = llDetectedKey(0);
key id = llDetectedKey(0);
string name = llDetectedName(0);
llDialog(ToucherID, dialogInfo, buttons, dialogChannel);
listenHandle = llListen(dialogChannel, "", ToucherID, "");
}

//HERE'S OUR NEWLY ADDED LISTEN EVENT
listen(integer channel, string name, key id, string message)
{
if (message == "-")
{
llDialog(ToucherID, dialogInfo, buttons, dialogChannel);
}
else if (message == "Flick")
{
llSay(0, name + " Flicks " + llKey2Name(llGetOwner()) + "'s Left Ear. OUCH!!");
}
else if (message == "Bite")
{
llSay(0, name + " Bites " + llKey2Name(llGetOwner()) + "'s left ear hard. Ouch!! That really hurt " + name + ".");
}
else if (message == "Pull")
{
llSay(0, name + " pulls on " + llKey2Name(llGetOwner()) + "'s left ear hard. Ouch!! That really hurt " + name + ".");
}
else if (message == "Tickle")
{
llSay(0, name + " tickles " + llKey2Name(llGetOwner()) + "'s left ear lightly. " + llKey2Name(llGetOwner()) + "'s ear twitches a bit.");
}
else if (message == "Scratch")
{
llSay(0, name + " scratches behind " + llKey2Name(llGetOwner()) + "'s left ear lightly. " + llKey2Name(llGetOwner()) + "'s ear twitches a bit as he purrs.");
}
else if (message == "Kiss")
{
llSay(0, name + " Kisses " + llKey2Name(llGetOwner()) + "'s left ear lightly. " + llKey2Name(llGetOwner()) + "'s ear twitches a bit as he purrs.");
}
else if (message == "Kiss OWEE")
{
llSay(0, name + " Kisses " + llKey2Name(llGetOwner()) + "'s left ear lightly. " + llKey2Name(llGetOwner()) + "'s left ear feels much better.");
}
else if (message == "Play")
{
llSay(0, name + " plays with " + llKey2Name(llGetOwner()) + "'s left ear " + llKey2Name(llGetOwner()) + "'s ear twitches a bit.");
}
else if (message == "Poke")
{
llSay(0, name + " pokes " + llKey2Name(llGetOwner()) + "'s left ear " + llKey2Name(llGetOwner()) + "'s ear twitches a bit.");
}
}
}

 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Well, if I were writing the routines, I would first combine everything into a single script instead of using three scripts.  That would simplify things a great deal by letting me get rid of a lot of redundant code.  Then, I would be sure to give the left and right ears distinctive names (like "Left Ear" and "Right Ear"). Having done that, it would be easy to tell which ear someone had touched:

if(llGetLinkName(llDetectedLinkNumber(0)) == "Left Ear" ){    // Someone touched the left ear}else if (llGetLinkName(llDetectedLinkNumber(0)) == "Right Ear" ){    // Someone touched the right ear}

Then, I'd just make a global variable to store the current (most recent) state of the ears and only let the dialog menus activate if that variable has the value "unfold".

EDIT:  No, I take that back.  Since you have those ears flipping back and forth between visible and invisible, you'll have to do it the hard way.  When someone clicks an ear, you'll have to quickly ask

float Alpha_state = llList2Float(llGetLinkPrimitiveParams(llDetectedLinkNumber(0),[PRIM_COLOR,ALL_SIDES]),1);

and then see whether Alpha_state is 0.0 or 1.0.  Awkward.

Just as a matter of cleanliness, I'd then compress most of those llSetLinkAlpha bits into a few llSetLinkPrimitiveParams statements, using PRIM_LINK_TARGET and I would run them all from a timer instead of using llSleep.  That part is really important, BTW.  The llSleep function does exactly what is says:  it puts the entire script to sleep, so that it cannot respond to messages or any other environmental triggers.  A timer event, on the other hand, allows the script to remain fully alive and responsive.

 

  • Like 3
Link to comment
Share on other sites

  • 0

Just to re-inforce Rolig's point -- it is really dangrous to use llSleep() as a lazy alternative to a timer.    It shuts the script down completely, so touching the ears won't do anything while it's sleeping.

I use it only when I want to make sure I give something else time to finish happening, and if I find myself wanting to sleep the script for more than a second, at most, it's usually a sure sign I'm doing it wrong.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2973 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...