Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Have a script wait for another script after a Dialog

Derin Swenson
Registered User
Join date: 10 May 2006
Posts: 25
07-14-2006 22:02
greetings everyone,

I need some help...I seem to be having problems with a script I am trying to write. Basically we have Owner A and Owner B...Owner A owns Prim A and Owner B owns Prim B. Prim A and Prim B have the same scripts. When Owner B clicks on Prim A he gets a yes or no dialog asking if he wants to continue on. He clicks yes and ideally the script in Prim A waits and listens for a certain message from Prim B to continue on. Then Owner A then clicks Prim B haveing recieved a message from Prim A that Owner B wishes to perform a mutual action and Owner A needs to click on Prim B and perfrom the same actions. Owner A then clicks on Prim B and gets the same dialog that Owner B got when he clicked on Prim A (as both prims have the same script) Owner B clicks yes and then both scripts in both Prims continue now that both owners have clicked yes.

My problem is thatI get the dialog when Owner B clicks on Prim A and he clicks yes....doing this causes Prim A to talk to Prim B sending information to some global variables this info is necessary. This causes Prim B to go into the listen event and thus skiping the touch_start preventing Owner A from being able to click on Prim B and getting the same dialog.

How can I prevent this?
Also, how can I make both scripts idle (so that either Owner can start the transaction) until both Owners say Yes.

Thanks :)
Angela Salome
Registered User
Join date: 6 Oct 2005
Posts: 224
07-15-2006 01:14
From: Derin Swenson
greetings everyone,

I need some help...I seem to be having problems with a script I am trying to write. Basically we have Owner A and Owner B...Owner A owns Prim A and Owner B owns Prim B. Prim A and Prim B have the same scripts. When Owner B clicks on Prim A he gets a yes or no dialog asking if he wants to continue on. He clicks yes and ideally the script in Prim A waits and listens for a certain message from Prim B to continue on. Then Owner A then clicks Prim B haveing recieved a message from Prim A that Owner B wishes to perform a mutual action and Owner A needs to click on Prim B and perfrom the same actions. Owner A then clicks on Prim B and gets the same dialog that Owner B got when he clicked on Prim A (as both prims have the same script) Owner B clicks yes and then both scripts in both Prims continue now that both owners have clicked yes.

My problem is thatI get the dialog when Owner B clicks on Prim A and he clicks yes....doing this causes Prim A to talk to Prim B sending information to some global variables this info is necessary. This causes Prim B to go into the listen event and thus skiping the touch_start preventing Owner A from being able to click on Prim B and getting the same dialog.

How can I prevent this?
Also, how can I make both scripts idle (so that either Owner can start the transaction) until both Owners say Yes.

Thanks :)


Both scripts are idle normally, unless your script is doing all the processing in the state_entry event handler and never exiting.

Simplistically, you need to stop Prim A from talking, and Prim B from listening. For that, you need better listen filter settings. Your dialog handlers need to use random channel and use that random channel number for the llListen. Only execute listeners as needed, trigger them on touch. Be sure to use multiple states.
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
07-15-2006 07:19
Hi Derin

Make sure you have no loops that might keep you stuck in any of these bits of code.

With lsl typs programming everything should be event driven and absolutely nothing should have loops that take any amount of time. If you need to do a sequence of things separated by time intervals, use a timer.

Ed
Derin Swenson
Registered User
Join date: 10 May 2006
Posts: 25
07-15-2006 16:33
excellent, I shall try some of these hints once SL comes back up online....though here are some of the tips that you have suggested but I have already done.

To ed44 Gupte,

There are no loops in the script with the excption of self made loops ((ie going back to the beginning of a state if a certain condition was wrong. Or a resetting of a state by going outside the current state I want reset to a reset state then back again. ((this isn't part of the problem as it is currently in a whole different part of the script)). All of my scripts are event driven, as was taught to me by my mentor and class instructors.

As for the timer, suggestion...I do have a timer, but that is only if someone clicks ignore on the dialog or if the player is idle for 20 seconds...I don't know if I wish to impliment one to dictate when they can continue to the next step as, the scenerio I described in the orignal post should take all of 5 -10 seconds unless one of the parties isn't paying attention. But on the other hand I do not want to try to make the Owners and those who are participating feel as if they need to race to click eachothers prims.

Both tips are useful and I thank you for taking the time....if there is any way you can suggest something different than the timer, that would be awesome.

To Angela Salome,

I was taught this as well that all scripts remain idle unless an event triggers....the problem with this is that once they click yes...they will be sending the scripts to different states....I seem to be running into the problem that...both scripts are in sync with one another and talk fine while in the same state...which is supposed to be how it works...but I haven't found a way around not having the script change states once the Onwers click yes. The way the script works is that once a user agrees by clicking yes, it forwards him on to the next state to supposedly wait for the other prim and owner accept yes.....once they both click yes and have arrived in the same state again they move on, talking a back and forth to one another.

I am using multiple states...and a listener switch to turn off my listener events when the script isn't chatting to the other prim/script or when idle. as to the random chat channel...I have yet been able to find how to accomplish this....I would assume it uses the llfrand function and inserts it into the channel variable for the listen function or event...but have not been able to get it to work.

Lastly the Chat/listen filters.....::growls:: lol.....when I orginally wrote the script....I had them very specific.....if message is this word, on this channel, and by this this object...then do tis set of commands.....it always seemed to not work...so I cut back some, but not to the point that when ever someone said any word the script would go hey wire lol. If there is a link for helpful hints on listen filters besides the wiki, that would be great.

Thanks again all :), I could use any more thoughts anyone has.....if some of the ideas given have not worked I'll post my results and perhaps the part of the script I'm having problems with.....I just didn't want to embarrass myself with my noobish scripting style :P.
Draco18s Majestic
Registered User
Join date: 19 Sep 2005
Posts: 2,744
07-15-2006 17:23
Try adding a new state.
CODE

default
{
...
llDialog(...);
...
listen(...)
{
if(message == "Yes")
{
//communicate
state wait;
}
else if(message == "communication from B")
{
state wait2;
}
}
}

state wait
{
listen(...)
{
if(message == "communication from B")
{
state done;
}
}
}

state wait2
{
...
llDialog(...);
...
listen(...)
{
if(message == "Yes")
{
//communicate
state done;
}
}
}



This makes it so that if it is the first prim clicked it just waits for the reply from B, if it gets the message from B first it goes to a DIFFERENT state that has the touch_start() and llDialog().