Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

sleep() ? why it doesn't sleep !?

Dominique Laville
Registered User
Join date: 24 Apr 2008
Posts: 84
06-07-2008 06:12
My object dies if it is touched.
But I want it to sleep in the first 2 seconds, so you can't kill it in the first 2 seconds of life.

But it dies anyway.. why ?!

state_entry()
{

llSleep(2);
}

touch_start(integer total_number)
{

llDie();
}

ps. Is it maybe because it is rezzed from another object ? So, state_entry does not work in this case ? how could I solve ?
FireEyes Fauna
Registered User
Join date: 26 Apr 2004
Posts: 138
06-07-2008 06:39
state_entry is only run when you first save the script or reset the script.

You want to use an on_rez event. Or put a llResetScript() into your on_rez event so that it runs the state_entry.

CODE

state_entry()
{
llSleep(2);
}

on_rez(integer param)
{
llResetScript();
}

touch_start(integer total_number)
{
llDie();
}
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
06-07-2008 06:39
state default
{
on_rez(integer num)
{

llSleep(2);
state goaway;

}
}

state goaway
{
touch_start(integer total_number)
{

llDie();
}
}
_____________________
My SLExchange shop

Typos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not.


The function is working perfectly fine. It's just not working the way you wanted it to work.
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
06-07-2008 07:18
Another snippet :)

CODE

integer canDie = FALSE;
float canDieAfter = 2.0;

default{
state_entry(){
llSetTimerEvent(canDieAfter);
}

touch_start(integer total_num){
if(canDie)
llDie();
}

timer(){
llSetTimerEvent(0);
canDie = TRUE;
}
}
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
06-07-2008 07:38
What Senuka or Haruki said! Or:
CODE
integer time = 0;

default {
state_entry() {
llSleep(2.0);
time = 1;
}
touch_start(integer total_number) {
if (time)
llDie();
}
}
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum