|
Steve Memotech
Registered User
Join date: 27 Mar 2007
Posts: 20
|
08-30-2007 23:14
Hi... I am creating a script that control animation by pressing keyboard (arrow left and arrow right). I have already my animations in my inventory under content tab. It compiles successfully but I have an error on script saying that: Script trying to stop animations but PERMISSION_TRIGGER_ANIMATION permission not set Here is my code: integer animation_qty; integer animation_current; string animation_name; string new_animation_name; string float_text; key avatar;
update_inventory() { animation_qty = llGetInventoryNumber(INVENTORY_ANIMATION);
}
set_anim(integer inventory_number) { new_animation_name = llGetInventoryName(INVENTORY_ANIMATION, inventory_number);
avatar = llAvatarOnSitTarget();
if (avatar != NULL_KEY) { llStopAnimation(animation_name); llStartAnimation(new_animation_name); }
animation_name = new_animation_name; }
default { touch_start(integer num) { llRequestPermissions(llDetectedKey(0), PERMISSION_TAKE_CONTROLS); update_inventory(); if (animation_qty > 0) { llSetSitText("Pose"); animation_name = llGetInventoryName(INVENTORY_ANIMATION, 0); set_anim(animation_current); }
}
run_time_permissions(integer perm) { if (perm & PERMISSION_TAKE_CONTROLS) { llTakeControls(CONTROL_RIGHT | CONTROL_LEFT, TRUE, TRUE); } if (perm & PERMISSION_TRIGGER_ANIMATION) { llStopAnimation("sit"); llStartAnimation(animation_name); } }
control(key id, integer held, integer change) { if (change & held & CONTROL_RIGHT) { llSay(0, "next animation"); animation_current++; if ((animation_current + 1) > animation_qty) { animation_current = 0; } set_anim(animation_current); } else if (change & held & CONTROL_LEFT) { llSay(0, "previous animation"); animation_current--; if (animation_current < 0) { animation_current = animation_qty - 1; }
set_anim(animation_current); } } changed(integer change) { if (change & CHANGED_INVENTORY) { update_inventory(); }
if (change & CHANGED_LINK) { avatar = llAvatarOnSitTarget(); if(avatar != NULL_KEY) { llRequestPermissions(avatar, PERMISSION_TRIGGER_ANIMATION); } else { if (llGetPermissionsKey() != NULL_KEY) { llStopAnimation(animation_name); } } } }
}
|
|
Steve Memotech
Registered User
Join date: 27 Mar 2007
Posts: 20
|
08-31-2007 00:44
bump.
|
|
Simnelia Petrichor
Registered User
Join date: 10 Feb 2006
Posts: 35
|
08-31-2007 01:34
Think the problem could be that the script doesn't set the sit target for the object using llSitTarget(). This means llAvatarOnSitTarget() will always return NULL_KEY.
|
|
Jotheph Nemeth
Registered User
Join date: 9 Aug 2007
Posts: 142
|
08-31-2007 08:27
It might be that you need to put the animation start in the run time permission event itself.
I've had odd situations happen if I put it in other calls, even if the permission is showing as being ok.
|
|
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
|
08-31-2007 09:55
also you can only have one set of permissions at a time, so if you request permissions for animation after.. you'll lose permissions for control. I think you'd be better off doing a: llRequestPermissions(llDetectedKey(0), PERMISSION_TAKE_CONTROLS|PERMISSION_TRIGGER_ANIMATION)  ; At least in your changed link.
|
|
Kidd Krasner
Registered User
Join date: 1 Jan 2007
Posts: 1,938
|
08-31-2007 10:03
Your touch_start event tries to stop the animation without ever requesting animation permissions.
Your changed event, for the unsit case, tries to stop the animation of the avatar for whom you last requested permissions. However, that could be someone who touched the object, which may not be the same as the person who stood up.
The llRequestPermissions function will release any previously required permission. Therefore, my guess is you always want to use PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS, never just one or the other.
|
|
Steve Memotech
Registered User
Join date: 27 Mar 2007
Posts: 20
|
09-08-2007 06:54
From: Kidd Krasner Your touch_start event tries to stop the animation without ever requesting animation permissions.
Your changed event, for the unsit case, tries to stop the animation of the avatar for whom you last requested permissions. However, that could be someone who touched the object, which may not be the same as the person who stood up.
The llRequestPermissions function will release any previously required permission. Therefore, my guess is you always want to use PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS, never just one or the other. I have tried your advised but it does not work. It does not work to change the animation when I press Shift left arrow key or Shift right arrow key. What is wrong with this?
|