I would like to do something like the example below:
CODE
default
{
state_entry()
{
llSetTimerEvent(5);
}
timer()
{
llSetAlpha(1, ALL_SIDES);
////////PAUSE FOR 1 SECOND////////
llSetAlpha(0, ALL_SIDES);
}
}
These forums are CLOSED. Please visit the new forums HERE
Pause or wait before executing next function |
|
|
ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
|
01-09-2008 09:23
I could swear I once saw an example of a function that simply made the script pause for a prescribed number of seconds before executing the next function. But hours of searching the LSL Wiki have left me empty handed.
I would like to do something like the example below: CODE
_____________________
![]() VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30 http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240 http://shop.onrez.com/Archtx_Edo |
|
Okiphia Anatine
Okiphia Rayna
Join date: 22 Nov 2007
Posts: 454
|
01-09-2008 09:27
I could swear I once saw an example of a function that simply made the script pause for a prescribed number of seconds before executing the next function. But hours of searching the LSL Wiki have left me empty handed. I would like to do something like the example below: CODE
check out llSleep(float sec) http://www.lslwiki.net/lslwiki/wakka.php?wakka=llsleep Works beautifully, used it last night to test if llDialog really does work if you click then change sim lol _____________________
In-world, I am Okiphia Rayna. This account is an alt, and is the only account I currently have with payment info on-file due to some account cracking that took place. This is a security measure at present, and I may return to the forums as Okiphia Rayna at a later date.
If you need to reach me, IM Okiphia Rayna, not Okiphia Anatine |
|
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
|
01-09-2008 09:40
Just be careful of sleeping for any real amount of time.. Events will queue up while the script is doing the sleep, which can cause weird behavior.
Also, I think timers are supposed to be more efficient than sleeps as sleeps still chew up .2 or .3 ms per frame.. _____________________
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 |
|
Scott Tureaud
market base?
Join date: 7 Jun 2007
Posts: 224
|
01-09-2008 10:05
be very careful how you use sleep, it can eat up 10 times the resouces when compared to a timer in some scripts.
|
|
ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
|
01-09-2008 13:08
Thank you for the responses llSleep sounds like what I was looking for. But I'm concerned about the consequences of using it.
be very careful how you use sleep, it can eat up 10 times the resouces when compared to a timer in some scripts. Just be careful of sleeping for any real amount of time.. Events will queue up while the script is doing the sleep, which can cause weird behavior. Am I to understand that llSleep used in one script will delay all other scripts trying to run in the sim, or just the events in that single script? In the example I posted, I'm trying to make an object turn visible then invisible and keep repeating that behavior every few seconds, so the prim appears to flicker possibly twice a second. Is that a bad thing having a timer continuing to loop like that? I don't want to knowingly introduce scripts that will increase lag terribly. _____________________
![]() VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30 http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240 http://shop.onrez.com/Archtx_Edo |
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
01-09-2008 13:14
I'd do it with a timer personally. You just may need some global variables to keep track of state between events, since you don't have that nice persistent stack space for local variables. In your case, it would be pretty trivial to have a boolean to keep track of what the next visibility change should be. You could also test some quality of the prim each time to avoid a global variable in your script, but it's likely not worth it in this case.
|
|
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
|
01-09-2008 13:25
I don't think an llSleep of 1 second is going to cause you any problems... but you could do it all in the timer:
integer clicks; default { state_entry() { llSetTimerEvent(1); } timer() { clicks += 1 if (clicks == 5) llSetAlpha(1, ALL_SIDES); if (clicks == 6) { llSetAlpha(0, ALL_SIDES); clicks = 0; } } } The advantage is that the script is available to respond to other events without any delay (lag allowing ). |
|
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
|
01-09-2008 13:34
Am I to understand that llSleep used in one script will delay all other scripts trying to run in the sim, or just the events in that single script? Just that single script.. By 'events will get queued up' I mean that, for example, if your script handles touch events and has a 10 second sleep, it's not going to get notified of any touches until the sleep finishes. Slow touches aren't too bad but if it was handling collisions, things could get pretty weird. If the script is really as simple as the OP _and_ you were doing more than a second of sleeping, you might want to consider using states.. Maybe something like this, which hasn't even been compiled, let alone tested... CODE
_____________________
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 |
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
01-09-2008 15:09
Six of one and half dozen of the other. Everytime you do a state change the simulator has to exit the state and enter the other state. Using the timer like Pale does is how I do it a lot. It allows you to do multiple events of various lenghts with just the one timer. But then with Meade's, you aren't having to fire the timer every second. Have a sneaking suspicion the state changes are more expensive simulator wise. Hopefully someone can clarify that. Both scripts have errors corrected below:
CODE
Does this: "*** state_entry() SetTimerEvent(1.000000) *** timer() *** timer() *** timer() *** timer() *** timer() SetAlpha(1.000000,-1) *** timer() SetAlpha(0.000000,-1) *** timer() *** timer() *** timer() *** timer() *** timer() SetAlpha(1.000000,-1) *** timer() SetAlpha(0.000000,-1) *** timer() *** timer() *** timer() *** timer() *** timer() SetAlpha(1.000000,-1) *** timer() SetAlpha(0.000000,-1)" CODE
output: *** state_entry() SetTimerEvent(5.000000) *** timer() SetTimerEvent(0.000000) state->blinky *** state_exit() *** state_entry() SetAlpha(1.000000,-1) SetTimerEvent(1.000000) *** timer() SetTimerEvent(0.000000) SetAlpha(0.000000,-1) state->default *** state_exit() *** state_entry()" But since you don't have any events or other input in this case then would probably go with what you were originally asking: CODE
output: "*** state_entry() SetTimerEvent(5.000000) *** timer() SetAlpha(1.000000,-1) Sleep(1.000000) SetAlpha(0.000000,-1) *** timer() SetAlpha(1.000000,-1) Sleep(1.000000) SetAlpha(0.000000,-1) *** timer() SetAlpha(1.000000,-1) Sleep(1.000000) SetAlpha(0.000000,-1)" PS: Thanks for the christmas present ArchTX!! _____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum |
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
01-09-2008 20:49
if you do use multiple states, just remember that the timer persists accross states... no need to keep starting and stopping it.
of course since you're just changing one thing back and forth boolean switching could be just as useful as a state change... this would work for a constant flashing timer() llSetAlpha( (gBooSwitch = !gBooSwitch), ALL_SIDES); } this would work for a flicker each interval called timer() llSetAlpha( (gBooSwitch = !gBooSwitch), ALL_SIDES); llSetAlpha( (gBooSwitch = !gBooSwitch), ALL_SIDES); } _____________________
|
| . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - |
|
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
|
01-09-2008 23:36
integer clicks = FALSE;
default { state_entry() { llSetTimerEvent(1.0); } timer() { clicks = !clicks; if (clicks == TRUE) { llSetAlpha(1, ALL_SIDES); llSetTimerEvent(1.0); } else { llSetAlpha(0, ALL_SIDES); llSetTimerEvent(5.0); } } } |