Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

need script help - animation that activates upon wearing (rezzing) object

Joshua Nightshade
Registered dragon
Join date: 12 Oct 2004
Posts: 1,337
12-18-2004 22:04
okay this is what I'm trying to do. I have an object that I wear, and I'm trying to get it to activate an animation immediately upon putting the attachment on. I had done this before but somehow I managed to lose my old script and the one I've got now is now no copy/no modify and I can't remember how to recreate the effect.

the script I've got now is:


default
{
state_entry()
{
llRequestPermissions( llGetOwner(), PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);
}
run_time_permissions(integer perms)
{
if(perms)
{
llStartAnimation("suitcase";);
}
}
}

which seems to work the first time I load the damn thing, but as soon as I pick it up and try to reattach it doesn't happen again. can somebody help? I searched through the forums and I didn't find anything that specifically addressed this and my scripting sucks. :/ thanks!

oh, and the animation I'm using is within the object itself like it's supposed to be.
_____________________


Visit in-world:
http://tinyurl.com/2zy63d

http://shop.onrez.com/Joshua_Nightshade
http://joshuameadows.com/
Rhombur Volos
King of Scripture & Kebab
Join date: 6 Oct 2004
Posts: 102
12-18-2004 22:42
Use the on_rez(integer fromfather) {} -event. This should activate whenever your object is rezzed.
Joshua Nightshade
Registered dragon
Join date: 12 Oct 2004
Posts: 1,337
12-18-2004 22:44
From: Rhombur Volos
Use the on_rez(integer fromfather) {} -event. This should activate whenever your object is rezzed.


where? :D
_____________________


Visit in-world:
http://tinyurl.com/2zy63d

http://shop.onrez.com/Joshua_Nightshade
http://joshuameadows.com/
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
12-18-2004 23:24
Freaky. I just wrote a script to do this exact thing an hour ago. I've shut off my gaming box, but let me see if I can recreate what I had from memory:

CODE


default {
attach(key id) {
if (id) {
if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) {
llStartAnimation("whatever");
} else {
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
}
} else {
if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) {
llStopAnimation("whatever");
}
}
}

run_time_permissions(integer perms) {
if (perms & PERMISSION_TRIGGER_ANIMATION) {
llStartAnimation("whatever");
}
}
}



It's a little messy, but I couldn't really think of a more reliable way to do it.
Danny DeGroot
Sub-legendary
Join date: 7 Jul 2004
Posts: 191
12-19-2004 00:03
I haven't tested Lex's code above, but I think the thing you'll want to add to it (or to your own code, or whatever) is a state-bounce on rez. I don't know if it's still true, but when I first joined, there was a little bug which could get you if you tried to restart the default state from within itself, IIRC.

So, in your default state (whatever else you decide to do), maybe add something like this, outside of your existing code, like right before the closing toplevel bracket in your default state:

CODE

on_rez( integer i ) { state bounce; }


Then, below your default state, add a simple new state:

CODE

state bounce {

state_entry() { state default; }

on_rez( integer i ) { state default; }

}


See if that clears it up for you.

== danny d.
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
12-19-2004 13:36
What would be the effects of the bug? I didn't see a problem when I tested this script.
Danny DeGroot
Sub-legendary
Join date: 7 Jul 2004
Posts: 191
12-19-2004 14:17
From: Lex Neva
What would be the effects of the bug? I didn't see a problem when I tested this script.


Hi Lex,

I can't remember what the effects were, exactly, and I'm not sure the bug is still there. I just remember that when I joined (about 5 months ago), I was told that default states trying to re-enter themselves didn't always behave predictably. So I was shown this coding technique to defend against it, and I've used it habitually ever since.

== danny d.