Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

using multiple scripts

Boris Eebus
Registered User
Join date: 8 Feb 2008
Posts: 45
03-23-2008 09:13
I have 2 scripts

one offers a yes/no menu

if yes is selected I want to run the door_open script

currently both scripts run at the same time

here is the code

//DIALOG MENU


integer menu_handler;
integer menu_channel;
menu(key user,string title,list buttons)//make dialog easy, pick a channel by itself and destroy it after 5 seconds
{
menu_channel = (integer)(llFrand(99999.0) * -1);//yup a different channel at each use
menu_handler = llListen(menu_channel,"","","";);
llDialog(user,title,buttons,menu_channel);
llSetTimerEvent(5.0);
}

default
{
touch_start(integer t)
{
menu(llDetectedKey(0),"hello world",["yes","no"]);
}
timer() //so the menu timeout and close its listener
{
llSetTimerEvent(0.0);
llListenRemove(menu_handler);
}
listen(integer channel,string name,key id,string message)
{
if (channel == menu_channel) //in case you have others listeners
{
if(message == "yes";)
{
//do stuff from the open_door script
}
else if(message == "no";)
{
//do other stuffs
}
}
}
}
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
03-23-2008 10:10
What was the question?
_____________________
From Studio Dora
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
many ways...
03-23-2008 10:17
One is to copy the stuff from the door script into this script.

Another is to use a messaging call to send a message from this script to the door script. (probably best).

Another is to use an llSay(<private channel>...) to send the message.

Another is to have this script write something into object description that the door script detects.

Search for any example of sending messages from one script to another, and use the one that looks easiest to you.
_____________________
So many monkeys, so little Shakespeare.
Boris Eebus
Registered User
Join date: 8 Feb 2008
Posts: 45
03-23-2008 11:22
how do I run a single script which then runs the second script ?

so script A is run but within this is an if statement so "if this is true" run script B "else" run script C

Does this make more sense?
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
03-23-2008 11:28
You'll likely want to connect the two scripts with link-message operators:

if(x) llMessageLinked(-4,TRUE,"",NULL_KEY);

and..

link_message(integer sender, integer int, string str, key id)
{
if(int != FALSE) //Do stuff
}


That's a VERY basic idea...VERY basic...but it's how you'd work communication between two scripts.

Alternately, you can turn a script on and off with llSetScriptState()...though that does not appear to be what you're looking for in your above example.
_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
03-23-2008 14:09
Kenn Nilsson and Lee Ponzu already told you
My Bible is the LSL Wiki, try this link for an example
http://www.lslwiki.net/lslwiki/wakka.php?wakka=ExampleLinkMessage
_____________________
From Studio Dora