Reply
Honored Resident
YasmineFaladel
Posts: 4
0 Kudos

Linking a script in a menu dialogue

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

Innula Zenovka
Posts: 6,617
Registered: ‎06-02-2009
0 Kudos

Re: Linking a script in a menu dialogue

Reply to YasmineFaladel - view message

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.

Honored Resident
YasmineFaladel
Posts: 4
0 Kudos

Re: Linking a script in a menu dialogue

[ Edited ]

Reply to Innula Zenovka - view message

AHH YES IT WORKS THANK YOUU
But where do I place the ACTUAL script I want it to play o.o (in the second script i.e)

Dora Gustafson
Posts: 1,738
Registered: ‎10-05-2009
0 Kudos

Re: Linking a script in a menu dialogue

Reply to YasmineFaladel - view message

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::smileyhappy::smileyvery-happy:

Honored Resident
YasmineFaladel
Posts: 4
0 Kudos

Re: Linking a script in a menu dialogue

Reply to Dora Gustafson - view message

Hmm,I see..well thank you anyways :smileyhappy:

Innula Zenovka
Posts: 6,617
Registered: ‎06-02-2009
0 Kudos

Re: Linking a script in a menu dialogue

Reply to YasmineFaladel - view message

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?

Xiija
Posts: 223
Registered: ‎10-19-2011
0 Kudos

Re: Linking a script in a menu dialogue

[ Edited ]

Reply to Innula Zenovka - view message

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

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

.........................███▓▒░░.#21 Babe X.░░▒▓███............................
..............▀▄▀▄▀▄▀▄▀▄▀▄ S.L.R.D.A. ▄▀▄▀▄▀▄▀▄▀▄▀................
( ¨*•.¸(¨*•.¸´•.¸If I let you be in my dream, can I be in yours?¸.•´¸.•*¨) ¸.•*¨)
Member
Ela Talaj
Posts: 807
0 Kudos

Re: Linking a script in a menu dialogue

Reply to Dora Gustafson - view message

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

Elegant Solutions by The Gold Club
Dora Gustafson
Posts: 1,738
Registered: ‎10-05-2009
0 Kudos

Re: Linking a script in a menu dialogue

Reply to Ela Talaj - view message

Of course:smileysurprised::smileyhappy::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)