Jump to content

Linking a script in a menu dialogue


YasmineFaladel
 Share

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

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

Recommended Posts

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.

Link to comment
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:

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4138 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...