|
Ravinna Nishi
Registered User
Join date: 17 Apr 2007
Posts: 3
|
10-25-2007 04:07
Hi guys and gals  I'm trying to make a fun little staff for my avatar and I was hoping to get a staff she's holding in her hand to hold out in front of her properly instead of swing around with her arm along with her AO/natural movement. I can make the pose easy, but I'm not sure how i'd go along scripting it, or what kind of a script I would need. I have a few objects where you wear them, your avatar holds them appropriately, like a baseball bat, a purse, etc. Any ideas where I could start or any helpful links? Thanks in advance!
|
|
Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
|
10-25-2007 08:56
llStartAnimation(); run this on attach and (depending on your animation priorities, etc), it will apply the pose/animation. llStopAnimation(); run this on un-attach. check the wiki, i think they have a simple animation script in the examples section. btw: there are built in animations you can use for holding objects. hold_r_handgun is eminently useful for holding a lot of things. check that out, unless you want to make special custom poses. (and/or its a left hand staff  )
|
|
Ravinna Nishi
Registered User
Join date: 17 Apr 2007
Posts: 3
|
10-25-2007 21:38
Thanks for the wiki pointer! I figured it out kind of....I got the script to work so if I wear it and click it, it will use the pose...but not automatically when I put it on. I'm super new to scripting, so I'm actually really pleased that I accomplished that 
|
|
Tiarnalalon Sismondi
Registered User
Join date: 1 Jun 2006
Posts: 402
|
10-26-2007 05:55
Most attachments activate the request for animation permissions using the on_rez event.
|
|
Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
|
10-26-2007 07:19
heyas;
i thought they used the on-attatch event.
i cant whip out the code offhand from the top of my head. (or on-hand from the bottom...)
but what you want to do is basically this:
on attatch (which isnt an event, but you get an attatch/detatch event somewhere)
if get permissions & permission animate start animation. else requset permissions.
(this will stop it from asking you permission every time you wear it, and just go ahead and animate you if it already has permissions.)
on detach stop animation.
permissions event (whatever it is called)
if permission is animate start animation
just follow the wiki examples in place of my vague, general, on-the-fly notations.
|
|
Tiarnalalon Sismondi
Registered User
Join date: 1 Jun 2006
Posts: 402
|
10-26-2007 08:53
You can use the attach(key attached) event as well as on_rez, but most would prefer to just use the on_rez event for items that should only be attached since the 'attach' event will not fire if the object is rezzed on the ground.
If you rez a lot of animated attachments on the ground, I think you'll notice that a good deal of them still prompt you for permission to animate your avatar. Some even just give an error as the scripter assumed it would be attached with automatic permissions and now it's trying to animate you without perms.
Neither of these is 'right' or 'wrong' as it really depends on what You want to do. Either event handler will work just as well as the other, though you can get more goodies out of some. Like if you wanted, you could script the staff to turn on physics so it will fall down if it's rez'd on the ground instead of attached by using the on_rez event instead of the attach event.
If you want to make sure the item is attached in the on_rez event, you can simply poll with llGetAttached() like so
integer attachCheck = llGetAttached(); if (attachCheck != 0) { //do stuff for when it is attached to the avatar here. If attachCheck were 0, that would mean that it wasn't attached. //this would be where you would request permissions to animate and such. } else //this would fire when it's not attached { llSetStatus(STATUS_PHYSICS,TRUE); }
Part of the reason why so many use the on_rez event is that if both the attach and the on_rez event are used, the on_rez event will fire before the attach does.
|