Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help with if else statements

Django Yifu
Beat Island Gaffer
Join date: 7 May 2007
Posts: 189
10-23-2007 05:19
I am trying to create a rezzer that rez's and object only if a prior version of it doesn't exist.

I figured that I could use a listen and an if / else condition but it does not seem to work. The rezzer is shouting and responds when the object is in world. (ie it syas it can't rez and doesn't)

but it does not seem to execute the else part if the object doesn't exist.

this is the script

CODE

default {
state_entry()
{llListen(251175,"","","");
}
touch_start(integer num_detected)
{

llShout(251175,"do you exist");}

listen(integer channel, string name, key id, string message)
{
if (message == "yups")
{
llSay(0, "Please wait for the Line to be cleared");
}

else
{
llSay(0,"working");
llRezObject("Zip Line ring", llGetLocalPos() + <0,-0.8,0>, <0,0,0>,llGetRot(), 42);
}

}
}


any help please as the wiki sdoes not seem much use
_____________________
Tread softly upon the Earth for you walk on my face.
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
10-23-2007 05:36
Not sure I understand the overall design here, but if the "else" clause in the listen() is supposed to happen when there was no message, that's not gonna work. The listen() event only happens when there's a message. If that's the idea, a timer event would be a sensible trigger. (If that's not the idea, then sorry for the confusion.)
Django Yifu
Beat Island Gaffer
Join date: 7 May 2007
Posts: 189
10-23-2007 05:39
That's exactly the idea I need to make the rez event happen if there is no message. So I would create a timer that rezes at the end but kill the timer if there is a message?
_____________________
Tread softly upon the Earth for you walk on my face.
Django Yifu
Beat Island Gaffer
Join date: 7 May 2007
Posts: 189
10-23-2007 06:01
so here is the working script just in case anyone else want it

CODE

default {
state_entry()
{llListen(251175,"","","");
}
touch_start(integer num_detected)
{
llSetTimerEvent(2);
llShout(251175,"do you exist");}

listen(integer channel, string name, key id, string message)
{
if (message == "yups")
{
llSay(0, "Please wait for the Line to be cleared");
llResetScript();
}
}
timer()
{
llRezObject("Zip Line ring", llGetLocalPos() + <0,-0.8,0>, <0,0,0>,llGetRot(), 42);
llResetScript();
}
}
_____________________
Tread softly upon the Earth for you walk on my face.
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
10-23-2007 21:28
you can also use llRegionSay instead of llShout, and the entire sim is covered then.
Lyn Mimistrobell
(waiting)
Join date: 11 Jan 2007
Posts: 179
10-24-2007 04:14
1. I don't think a script will listen to itself.
2. Whu use llResetScript() instead of a new llSetTimerEvent(2) ?
Mereille Despres
Registered User
Join date: 5 Sep 2007
Posts: 79
10-24-2007 04:34
Also, if you expect the object to be within 96m, you can use a sensor (96m is the limit of llSensor). Then you can have positive confirmation either way via the sensor and no_sensor events.
Django Yifu
Beat Island Gaffer
Join date: 7 May 2007
Posts: 189
10-24-2007 08:47
Lyn the script is speaking to another object to see if it already exists. If it doesn't it will rez the object. I only want ones existing within chat range at a time. Thats the main reason I have used the llShout rather than llRegionSay.

The llResetScript() is just to stop the timer so only one object gets rezzed and the script is back to it's ready state. Does that make much difference in terms of lag from setting a new timer. I figured it was the easiest way to quit the timer from what it says on the wiki.

Mereille I hadn't thought of using a sensor instead, I guess that would reduce lag but as it's only a periodical use of chat (as in when the user touches) and the object doing the listen is temporary I figured it wouldn't matter too much. I guess the problem is the listen in the rezzer waiting for confirmation. I will look into replacing that section of code thanks for the pointer.
_____________________
Tread softly upon the Earth for you walk on my face.