Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Keeping a variable's new value after de-rez/rez

Virrginia Tombola
Equestrienne
Join date: 10 Nov 2006
Posts: 938
06-20-2007 12:23
Well, this is one of those "I must be missing something obvious moments". Basically, I have an object that animates the avatar when attached. I have an adjustment state it goes to upon a listen event, where it presents a dialog box of animation choices, then exits back to default once a new animation is chosen.

So far, all easy enough. The trouble is, I want this newly selected animation to play when the object is rezzed the next time. In other words, I don't want to owner to have to reselect the animation.

I am declaring the animation name (as in "llStartAnimation(animationname)";) as a global string variable. If I declare the value of "animationname" at the beginning, then every time it rezzes, it goes back to the original animation. But not declaring it comes up with the obvious "animationname not found" script error.

What am I missing here?
Darien Caldwell
Registered User
Join date: 12 Oct 2006
Posts: 3,127
06-20-2007 12:36
variables are constant through rez and derez. It sounds to me like you must be resetting the script in the on_rez event. That would cause the variables to re-initialize. Just a guess without seeing the script.
_____________________
Destiny Niles
Registered User
Join date: 23 Aug 2006
Posts: 949
06-20-2007 12:36
What you do is set the animationname in the state_entry and not the on_rez. state entry is only ran once.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
06-20-2007 12:51
From: Virrginia Tombola
Well, this is one of those "I must be missing something obvious moments". Basically, I have an object that animates the avatar when attached. I have an adjustment state it goes to upon a listen event, where it presents a dialog box of animation choices, then exits back to default once a new animation is chosen.

So far, all easy enough. The trouble is, I want this newly selected animation to play when the object is rezzed the next time. In other words, I don't want to owner to have to reselect the animation.

I am declaring the animation name (as in "llStartAnimation(animationname)";) as a global string variable. If I declare the value of "animationname" at the beginning, then every time it rezzes, it goes back to the original animation. But not declaring it comes up with the obvious "animationname not found" script error.

What am I missing here?


I'm guessing you have an llResetScript() call inthere in an on_rez event?
_____________________
I'm back......
Virrginia Tombola
Equestrienne
Join date: 10 Nov 2006
Posts: 938
06-20-2007 14:02
Oddly, no. I don't have a llResetScript call in there (I did, but took it out).

It's a long and absurdly messy script (I script rather like I clean house, I'm afraid), so I'll go take another look at it and see if perhaps I have another llStartAnim call in there, with the argument defined instead of a variable.

Right now, I define the variable in the declaration, not in the state entry--perhaps that will help, too.

Thanks for the suggestions!
Daten Thielt
Registered User
Join date: 1 Dec 2006
Posts: 104
06-20-2007 14:27
if ya dont figure it out just store the variable in the objects description <llSetObjectDesc(string desc);> and retreive it using llGetObjectDesc();
Virrginia Tombola
Equestrienne
Join date: 10 Nov 2006
Posts: 938
06-20-2007 20:55
How odd. I tried Daten's suggestion right off, and despite having but one call to llSetObjDesc, and the object description changing, the description reverted upon taking into inventory and re-rezzing.

So, I fiddled with other parts of the script, added an attach event (er, yes, I had just been setting permissions etc on state entry), and had the string variable set there. For whatever reason, it seems to work now.

Scripting with an axe, I suppose. A very blunt axe :P