RacerX Gullwing
Magic Rabbit
Join date: 18 Jun 2004
Posts: 371
|
09-05-2004 21:28
Hi I got a script at the university that says make sure this is running and delete the 123 and save it to use Its suposed to kill an object if it trys to leave the sim I was wanting to use it in some tin cans I was shooting at in (rouch) I think. { state_entry() { llSetStatus(STATUS_DIE_AT_EDGE,TRUE); vector INITCorner = llGetRegionCorner(); while(TRUE) { if(llGetRegionCorner() != INITCorner) { llDie(); } } } }
it wont compile it say's 7.0 :Error: syntax error anyone know what's wrong here?
|
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
|
09-05-2004 23:49
Please remind me to go to USL and kick the author of that script square on the arse. Infinite loops should never be without a sleep somewhere within them, even if its just for a second. Here's the corrected script: default { state_entry() { llSetStatus(STATUS_DIE_AT_EDGE, TRUE); vector INITCorner = llGetRegionCorner(); while (TRUE) { if (llGetRegionCorner() != INITCorner) { llDie(); } llSleep(5.0); } } }
==Chris
|
Eggy Lippmann
Wiktator
Join date: 1 May 2003
Posts: 7,939
|
09-06-2004 03:34
Uh, why? To avoid lag or something?
|
MSo Lambert
Registered User
Join date: 16 Aug 2004
Posts: 101
|
09-06-2004 03:46
Im not sure whats the case with LSL, but infinite loops with no sleep can use 100% of processors time in some languages and are usually avoided.
In other words, they're just a waste of resources.
_____________________
MSo
|
Moleculor Satyr
Fireflies!
Join date: 5 Jan 2004
Posts: 2,650
|
09-06-2004 03:46
Yes, to avoid lag.
The problem with that script is that it can only function seperate from any other scripts anywhere. You can't slide that into another script and have it work, because the while loop would never let it go.
But yes, having a while(TRUE) without a sleep is BAD. (A while with a conditional that will eventually be FALSE is usually fine though.)
_____________________
</sarcasm>
|
RacerX Gullwing
Magic Rabbit
Join date: 18 Jun 2004
Posts: 371
|
09-06-2004 15:02
Well thank you. That's good to know. Got back in SL and relized it was missing a default mode. Got tired of setting the cans back up pretty quick. I switched to using dominos because they set themselves back up after being knocked over. Much better for target practice.
But the cans I left laying around were causing lag the whole time till the place reset. Oops Sorry about that anyone affected.
|