Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

multi button script

ChaiBoy Rang
Registered User
Join date: 9 Mar 2007
Posts: 29
03-14-2007 14:27
I was working on changing the emote script from the library so that i can have a three button item in my hud.

button one shows menu of happy emotes such as toothy smile and wink
button two showes menu of angry emotes such as well angry, distain etc
button three stops any animation

the problem is once i seperate the script into three parts they become independent and do not override or stop each other.

What step am i missing to make the buttons work as a whole instead of seperately?

thanks
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
03-14-2007 14:43
CODE
llStopAnimation(lastAnim);


if you're tracking the lastAnim, and passing them to subroutines:

CODE
sadMenu()


you may need to pass the value of the variable lastAnim to the subroutine...

so when you call sadMenu().. do it like this:

CODE
sadMenu(lastAnim);


And when you spell out the subroutine... you need to parse that varible again... so it's:

CODE
sadMenu(string lastAnim)
{
llStopAnimation(lastAnim);
}



That's my best guess... without being able to see your script.
_____________________

● Inworld Store: http://slurl.eclectic-randomness.com
● Website: http://www.eclectic-randomness.com
● Twitter: @WinterVentura
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-15-2007 02:49
From what ChaiBoy is saying I'm guessing you have crtaed 3 scripts one in each buttoin of teh HUD? If this is the case then you will need linked messages to pass teh data back and forth. However I'm not sure WHY you would have needed to split it into 3 scripts.
ChaiBoy Rang
Registered User
Join date: 9 Mar 2007
Posts: 29
03-19-2007 13:11
how would I go about making this kind of script?

Would the main script go into the linked object and each button have a link message to activate the apropriate menu?


I'll look up link message. I was working blind so I tried the three script approch

Thanks for the tips
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
03-19-2007 14:26
Each button could carry a bitty script something like this:

CODE
default
{
touch_start(integer total_number)
{
llMessageLinked(LINK_ROOT, 1, "happy", NULL_KEY);
}
}
Then the main script in the Root Prim (LINK_ROOT) would receive the Link Message in its link_message Event Handler and react accordingly (no need to split the main logic).

Given the general syntax: llMessageLinked(integer linknum, integer num, string str, key id), in this example I'm using integer num (1) to identify the button, and string str (happy) to identify the action. Either one would probably suffice.
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
03-19-2007 14:47
Even better and faster, name the buttons and have the main script get all the touches.

Then, when the main script gets a touch, it simply does
CODE

llGetLinkName(llDetectedLinkNumber(0));

Resulting in a string like "happy" or "sad", and the script can work with the data from there.

This method requires fewer scripts, and is significantly less laggy.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-20-2007 01:18
Even faster just check the link number of the touched button (numeric check is quicker than string)
Ed Gobo
ed44's alt
Join date: 20 Jun 2006
Posts: 220
03-20-2007 05:29
Be careful, the link number depends on the order in which you link them, and you might do it differently sometimes
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-20-2007 08:56
From: Ed Gobo
Be careful, the link number depends on the order in which you link them, and you might do it differently sometimes



LOL, indeed but that why you take care in what you do and edit the code if you have too.I tend to define a constant i.e. HELPBUTTON and assign it the link number I'm interested in.