Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Toggling timer event

Basement Desade
Registered User
Join date: 14 Jul 2006
Posts: 91
06-01-2009 13:55
I am trying to start and stop a timer event via chat. I am not a skilled scripter, mostly what I do is to cobble together working scripts by hacking up old ones, and this one has me stumped.

Probably an easy fix for someone who knows what they are doing, but I've spent hours researching it, and this is as close as I've been able to get. Of course, I get a syntax error at the second "if."

[CODE}

integer train;
default
{
state_entry()
{

llListen(3, "", "","train on";);
llListen(3, "", "","train off";);
}

listen(integer channel, string name, key id, string m)
{
if (m == "train on";)
llSetTimerEvent(1);
}

timer()
{
llSay(5,"One";);
llSleep (.3);
llSay(5,"Two";);
llSleep (.3);
llSay(5,"Three";);
llSleep (.3);
llSay(5,"Four";);
llSleep (.3);
}

if (m == "train off";)
{
llSetTimerEvent(0);
}
}
}
}
[CODE}
Destiny Niles
Registered User
Join date: 23 Aug 2006
Posts: 949
06-01-2009 14:03
See if this works.
[CODE}

integer train;
default
{
state_entry()
{

llListen(3, "", "","train on";);
llListen(3, "", "","train off";);
}

listen(integer channel, string name, key id, string m)
{
if (m == "train on";)
llSetTimerEvent(1);
}

timer()
{
llSay(5,"One";);
llSleep (.3); //sleeps ignore all events so you will not be able to issue the timer off commands until this section it complete. if you want to interupt the count use .3 timer and counter
llSay(5,"Two";);
llSleep (.3);
llSay(5,"Three";);
llSleep (.3);
llSay(5,"Four";);
llSleep (.3);
// take out this bracket }

if (m == "train off";)
{ //optional for one line if's
llSetTimerEvent(0);
} //optionals
}
}
// this is an extra braket }
[CODE}[/QUOTE]
Basement Desade
Registered User
Join date: 14 Jul 2006
Posts: 91
Not quite there...
06-01-2009 14:15
Thanks Destiny,

Still getting a syntax error, but this time it moved from in front of the "if" to in front of the next "==" (in the off command)
Papalopulus Kobolowski
working mind
Join date: 11 Aug 2006
Posts: 326
06-01-2009 15:06
From: Basement Desade
Thanks Destiny,

Still getting a syntax error, but this time it moved from in front of the "if" to in front of the next "==" (in the off command)


That is because the string "m" just exist in the listen event

listen(integer channel, string name, key id, string m)


From: someone

integer train;
default
{
state_entry()
{

llListen(3, "", "","train on";);
llListen(3, "", "","train off";);
}

listen(integer channel, string name, key id, string m)
{
if (m == "train on";)
{ llSetTimerEvent(1);
}
if (m == "train off";)
{ //optional for one line if's
llSetTimerEvent(0);
} //optionals
}

timer()
{
llSay(5,"One";);
llSleep (.3); //sleeps ignore all events so you will not be able to issue the timer off commands until this section it complete. if you want to interupt the count use .3 timer and counter
llSay(5,"Two";);
llSleep (.3);
llSay(5,"Three";);
llSleep (.3);
llSay(5,"Four";);
llSleep (.3);
// take out this bracket }


}
}
// this is an extra braket }


_____________________


RAW terrain files - terraform your SIM!!
http://www.wishland.info/
PD:the wiki its your friend ;)
http://wiki.secondlife.com/wiki/LSL_Portal
Basement Desade
Registered User
Join date: 14 Jul 2006
Posts: 91
Yee-haa
06-01-2009 15:21
Works! Thanks!