Sign in to follow this  
Followers 0
YasmineFaladel

Linking a script in a menu dialogue

9 posts in this topic

Yes,so I have a menu dialogue and I'd like to link it to another script whenever a specific button a selected,are you suppoed to use

"llGetInventoryName(INVENTORY_SCRIPT, 1);"

because i literally have no idea what I'm doing at this point haha

Share this post


Link to post
Share on other sites

The line of code, llGetInventoryName(INVENTORY_SCRIPT, 1), means, in English, "get the name of the second script in the prim's inventory", which probably isn't what you want to do.

If you want to send a message to another script, you've got either one or two options, depending on the circumstances.  If the other script is in the same object as the one calling the menu, then you should use a LINK MESSAGE, like this:

 

integer chan;integer handle;default{	state_entry()	{		chan = -99;//give chan a value	}	touch_start(integer total_number)	{		llListenRemove(handle);//close any open listeners		key k = llDetectedKey(0);//get the uuid of the avatar who just touched me		handle = llListen(chan, "", k, "");//start listening to her or him		llSetTimerEvent(30.0);//start a timer, so you can stop listening after a time if you don't get a reply		llDialog(k,"Please choose something",["Say Message","Send Message"], chan);  //present a menu	}	listen(integer channel, string name, key id, string message)	{		llListenRemove(handle);//stop listening		llSetTimerEvent(0.0);//turn off the timer		if("Say Message"==message){//if the avatar chose that			llRegionSayTo(id,0,"You chose "+message); //say the message		}		else if ("Send Message"==message){//or if the avatar chose this			llMessageLinked(LINK_SET,10,message,id);//send a message the other scripts in the linkset comprising the number 10, the message and the avatar's uuid		}	}	timer()	{ // if no reply after 30 seconds, give up		llListenRemove(handle);		llSetTimerEvent(0.0);	}}

 

 Then in the other script, have something like this:

default{	state_entry()	{		//llSay(0, "Hello, Avatar!");	}	link_message(integer sender_number, integer number, string message, key id)	{		if (10 == number){//if it's for me			llRegionSayTo(id,0,"Hello, "+llGetDisplayName(id)"+! The other script tells me you chose "+message);		}	}}

 If the receiver script is in another object, you could make the menu script say a message on a channel the other script was listening on.

Share this post


Link to post
Share on other sites

You can not trigger one script from another script
and I don't see why you should
LSL is event driven so all scripts in a prim may have event handlers for identical events
In your case more scripts can listen for the same menu command and act upon it

It will probably take some time to get used to and take advantage of events, if the idea new to you

:smileysurprised::):smileyvery-happy:

Share this post


Link to post
Share on other sites

Can you explain, please, what you want to happen?    You may not need a second script at all, as Dora suggests, but we just don't have enough information to help you at the moment.

Does this second script need to affect the object the first script is in, or does it need to affect another object?

Share this post


Link to post
Share on other sites

you may not be able to trigger one script from another, but

you can set a script's state from another script.

Share this post


Link to post
Share on other sites

Sure you can triger a script from another script. That is one of the many reasons we have llMessageLinked().

Share this post


Link to post
Share on other sites

Of course:smileysurprised::):smileyvery-happy: what took you so long?

Still to me exchanging data and linking code are two different things.

(llMessageLinked is used for exchanging data between scripts in a link-set and not for linking code)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  
Followers 0