Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Some issues with timers

Keith Richter
Registered User
Join date: 27 Jan 2007
Posts: 21
12-03-2008 11:23
Well the script i'm making at one point has a trigger which enables the prim and it has to be clicked within 3 seconds. I'm not quite sure how to get this to work as my methods have been giving me trouble.

First general attempt:

CODE

touch_start()
{
if(active == TRUE)
{
llSay(0,"success");
active == FALSE;
}
}
//under the listen it has these commands
if(message == "trigger")
{
active == TRUE;
llSetTimerEvent(3);
}
//under the timer::
timer()
{
if(active == TRUE)
{
llSay(0, "failure);
active == FALSE;
}
}


Second Attempt used llSleep in this fashion:
CODE

if(message == "trigger")
{
active = TRUE;
llSleep(3);
if(active == TRUE)
{
blah blah blah
}
}


I didn't really expect the second version to work but it was worth experimenting lol. Either way the problem with the first one is that the touch isn't working and the timer doesn't register the whole 'if' statement it seems, and also keeps infinitely looping and i dunno how to make that stop... I may be using the completely wrong method but those are my general attempts.
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
12-03-2008 11:29
From: Keith Richter
if(message == "trigger";)
{
active == TRUE;
llSetTimerEvent(3);
}

/me points to the == (instead of =) on the 2nd line above. You're doing that every time you set it. Use == for testing a value, use = for setting a value.
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
12-03-2008 11:38
You'll need to check that the second click is from the agent that first clicked it, and if it's not clear it down after 3 seconds....
CODE

key agent = NULL_KEY;
//
default {
touch_start(integer number) {
if (agent == NULL_KEY) {
agent = llDetectedKey(0);
llSetTimerEvent(3.0);
} else if (llDetectedKey(0) == agent) {
// do whatever
}
}

timer() {
agent = NULL_KEY;
llSetTimerEvent(0.0);
}
}

hth,
/esc
_____________________
http://slurl.com/secondlife/Together