|
Oberon Onmura
Registered User
Join date: 28 Dec 2006
Posts: 125
|
01-15-2009 06:14
Hi -
Another chapter in my amateur scripter saga ...
I have an object with a couple of commands in an on_rez event. What I'm finding is that when I rez the object, edit the script, reset it, then save it back to my inventory, the on_rez event never triggers again. I have tried incorporating a llResetScript() function in various places of the script, but that doesn't seem to do it.
Any suggestions would be most appreciated!
|
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
01-15-2009 06:28
Might help to see the script... There's all sorts of things it could be; if your script has more than one state, for example, you probably will need an on_rez event in each state in which it's likely to be when taken back into your inventory.
|
|
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
|
01-15-2009 07:12
llResetScript will reload the script and all the default variable values, and trigger the default: state_entry event. on_rez is ONLY triggered when you rez the object. state_entry is only triggered when you save the script, or reset it (or enter the state). A neat trick is to make a user defined function called "init()" Then slip the init(); call into on_rez, and state_entry, and various other places (like certain situations in the change event (such as changed owner, or changed link perhaps.. and maybe places like the attach event, etc.) Then you're sure that whatever is in the init() function will be triggered. That's where I usually put my "always open and listening to the owner" listens.. variable assignments, and things like polling a linkset to store linknumbers of various prims. string objectname; string nickname = "Script";
init() { objectname = llGetObjectName(); llSetObjectName(nickname); llSay(0, "/me is ready."); llSetObjectName(objectname); }
default {
state_entry() { init(); }
on_rez(integer num) { init(); }
touch_start(integer count) { init(); } }
_____________________
 ● Inworld Store: http://slurl.eclectic-randomness.com ● Website: http://www.eclectic-randomness.com ● Twitter: @WinterVentura
|
|
Oberon Onmura
Registered User
Join date: 28 Dec 2006
Posts: 125
|
01-15-2009 08:47
From: Winter Ventura llResetScript will reload the script and all the default variable values, and trigger the default: state_entry event.
on_rez is ONLY triggered when you rez the object. state_entry is only triggered when you save the script, or reset it (or enter the state).
OK. This is helpful. But my problem is that on_rez isn't being triggered when I rez the object!
|
|
Oberon Onmura
Registered User
Join date: 28 Dec 2006
Posts: 125
|
01-15-2009 08:52
From: Innula Zenovka Might help to see the script... There's all sorts of things it could be; if your script has more than one state, for example, you probably will need an on_rez event in each state in which it's likely to be when taken back into your inventory. Here's the script snippet.
vector pos; integer count;
default { on_rez(integer start_param) { llOwnerSay("rezzed with the number " + (string)start_param); llSetObjectName(llGetObjectName()+" "+(string)start_param); } state_entry() { llCollisionSound("",0); llSleep(20); llSetStatus(STATUS_PHYSICS|STATUS_DIE_AT_EDGE,TRUE); llSetStatus(STATUS_ROTATE_Y|STATUS_ROTATE_X|STATUS_ROTATE_Z,FALSE); llSetBuoyancy(1.05); llSetAlpha(0.4,ALL_SIDES); llSetPrimitiveParams([PRIM_GLOW,ALL_SIDES,0.03]); integer push = llRound(6-llFrand(12)); integer push2 = llRound(6-llFrand(12)); llSleep(1.0); llApplyImpulse(<10*push,10*push2,2.0>,0); llSleep(30+llFrand(10)); llDie(); } }
|
|
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
|
01-15-2009 10:39
The problem is that your script is sleeping.
Events can only happen when another event's code isn't running.
Use llSetTimerEvent() and the timer event instead of the first and 3rd llSleep() calls.
|
|
Oberon Onmura
Registered User
Join date: 28 Dec 2006
Posts: 125
|
01-15-2009 12:14
From: Lear Cale The problem is that your script is sleeping.
Events can only happen when another event's code isn't running.
Use llSetTimerEvent() and the timer event instead of the first and 3rd llSleep() calls. Thanks so much! Now I can let all the hairs I pulled out start to grow back again. Until the next time ...
|