What came first on_rez or the state_entry()?
|
Fafnir Fauna
Downy Cat
Join date: 23 Jun 2004
Posts: 34
|
09-23-2004 03:57
Quick question, and probably a dumb one. But I just want to know for sure.
When rezzing an object with a script attached, what is called first? on_rez() or state_entry()? In other words.. where would be the best place to put initializations on a rezzed object's script?
|
Azelda Garcia
Azelda Garcia
Join date: 3 Nov 2003
Posts: 819
|
09-23-2004 04:26
state_entry happens when: - you add the script to the object - you change state
on_rez happens when: - you rez the object - you teleport with the object
Normally, they will not actually fire at the same time, ie state_entry wont fire when you rez the object.
What you can do is put a function called Init() in both on_rez and state_entry and put your initialization code in that.
Azelda
|
Arito Cotton
Still Addicted
Join date: 25 Aug 2003
Posts: 131
|
09-23-2004 04:58
I like to do this: default { state_entry() { state init; } on_rez(integer start_params) { state init; } }
state init { state_entry() { // Perform all initialization // and setup here.
globalvariable = 4; foobar = "bleh bleh";
// Go to the "normal" state now. state normal } }
state normal { // Normal event handlers // go in here. state_entry() {
} timer() {
} // etc... }
If you need to re-initialize your script, you can simply call "llResetScript();" or "state init;" - either will work.
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
09-23-2004 06:19
calling state init; from inside init shouldn't cause a state entry to be fired.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
Catfart Grayson
Registered User
Join date: 16 May 2004
Posts: 264
|
09-23-2004 09:22
on_rez is triggerd by teleporting with the object? That could be the cause of a couple of bugs I've had. Can you confirm that.
_____________________
Cat
|
Catherine Omega
Geometry Ninja
Join date: 10 Jan 2003
Posts: 2,053
|
09-23-2004 17:21
Yes, on_rez is caused every time the object is rezzed, including when you teleport, log on and off, or attach the object.
|
Azelda Garcia
Azelda Garcia
Join date: 3 Nov 2003
Posts: 819
|
09-23-2004 21:22
Which is incredibly useful by the way.
|
Reitsuki Kojima
Witchhunter
Join date: 27 Jan 2004
Posts: 5,328
|
09-24-2004 07:49
Also occasionaly on zone crossings, for some reason. I found this out with an attachment I made to emit a cloud of smoke when I teleported... Every once and a while it would fire when I crossed a sim border, but there wasnt any particular patern to it that I could tell.
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
09-24-2004 08:54
the sword script i use on ever sim crossing emits particles. I think it's a bug but i'm not interested enough to fix the problem. I'm mostly waiting on getting some good sword fighting animations (hint hint i'm in the market for some good animations; animations that will work well with a katana in the right hand, a wakazashi in the left and swords in both hands; including drawing the swords animations; willing to pay in the range of 10k COD).
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
|
Related event order question
09-29-2004 13:08
For attached objects, both on_rez and attach are triggered when teleporting or logging on or off. Which one of those fires first?
|
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
|
Related event order question
09-29-2004 13:09
For attached objects, both on_rez and attach or triggered when teleporting or logging on or off. Which one of those fires first?
|
Kurt Zidane
Just Human
Join date: 1 Apr 2004
Posts: 636
|
09-29-2004 16:59
So is there a way to detect what triggered on_rez or state_entry?
|