SwireD Posted October 21, 2019 Share Posted October 21, 2019 Hello! I am trying to script animesh dancing character, which will also animate avatar so they dance together. Everything is fine, when one dance used, but now i need to add a menu for multiple dances and i have an error, i know its something about run_time_permissions(integer perm) { if (perm & PERMISSION_TRIGGER_ANIMATION) { // what to do here } } and it must be the list, i am afraid. cause i am not good in lists. list MENU_MAIN = ["STOP", "Dance1", "Dance2", "Dance3"]; string sound = "a78fd32e-0179-437b-9a39-6b24916aa433"; integer menu_handler; integer menu_channel; menu(key user, string title, list buttons) { llListenRemove(menu_handler); menu_channel = (integer)(llFrand(99999.0) * -1); menu_handler = llListen(menu_channel, "", "", ""); llDialog(user, title, buttons, menu_channel); llSetTimerEvent(30.0); } default { state_entry() { llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); } run_time_permissions(integer perm) { if (perm & PERMISSION_TRIGGER_ANIMATION) { // what to do here } } changed(integer change) { if (change & CHANGED_OWNER) { llResetScript(); } } touch_start(integer total_number) { menu(llDetectedKey(0), "\nText for Menu.", MENU_MAIN); } listen(integer channel, string name, key id, string message) { if (channel == menu_channel) { llListenRemove(menu_handler); llSetTimerEvent(0); if (message == "Dance1") { llStopAnimation("Dance2"); llStopObjectAnimation("Dance2"); llStopAnimation("Dance3"); llStopObjectAnimation("Dance3"); llStartAnimation("Dance1"); llStartObjectAnimation("Dance1"); } else if (message == "Dance2") { llStopAnimation("Dance1"); llStopObjectAnimation("Dance1"); llStopAnimation("Dance3"); llStopObjectAnimation("Dance3"); llStartAnimation("Dance2"); llStartObjectAnimation("Dance2"); } else if (message == "Dance3") { llStopAnimation("Dance2"); llStopObjectAnimation("Dance2"); llStopAnimation("Dance1"); llStopObjectAnimation("Dance1"); llStartAnimation("Dance3"); llStartObjectAnimation("Dance3"); } else if (message == "STOP") { llStopAnimation("Dance1"); llStopObjectAnimation("Dance1"); llStopAnimation("Dance2"); llStopObjectAnimation("Dance2"); llStopAnimation("Dance3"); llStopObjectAnimation("Dance3"); } } } timer() { llListenRemove(menu_handler); llSetTimerEvent(0); } } Link to comment Share on other sites More sharing options...
Rolig Loon Posted October 21, 2019 Share Posted October 21, 2019 (edited) You didn't say what the error is, but you don't really have to put anything in that run_time_permissions event except maybe a line of chat to reassure you that you actually gave the script permission. If I were writing this script, though, I would trigger that llRequestPermissions in the touch_start event instead of in state_entry. Then I would put the line that says 25 minutes ago, SwireD said: menu(llDetectedKey(0), "\nText for Menu.", MENU_MAIN); in the run_time_permissions event. I would then clean up the listen event so that it looks something more like this: listen (integer channel, string name, key id, string message) { llListenRemove( menu_handler ) llSetTimerEvent(0.0); KillAnims(); integer idx = llListFindList( [ "Dance1", "Dance2", "Dance3" ], [message]); if ( ~idx ) { llStartAnimation( message); llStartObjectAnimation(message); } } where KillAnims is a user defined function: KillAnims() { llStopAnimation( "Dance1" ); llStopObjectAnimation( "Dance1" ); llStopAnimation( "Dance2" ); llStopObjectAnimation( "Dance2" ); llStopAnimation( "Dance3" ); llStopObjectAnimation( "Dance3" ); } [EDIT:] Oh, and make the touch_start event say if (llDetectedKey(0) == llGetOwnerKey() ) { llRequestPermissions( llDetectedKey(0), PERMISSION_TRIGGER_ANIMATIONS ); } Edited October 21, 2019 by Rolig Loon 1 Link to comment Share on other sites More sharing options...
Profaitchikenz Haiku Posted October 21, 2019 Share Posted October 21, 2019 What is the error exactly? The script doesn't have any syntax errors so it must be something like the specified animation not found? As to what to do in the run_time_permissions event, the best thing to do is only start and stop animations inside that event. The sort of thing you would do is have a string variable lastDance, which is the dance currently playing, and a string variable nextDance, which is what has been chosen from the menu. So the bits of code would look something like this string lastDance = ""; string thisDance = ""; // then in the listen when say Dance1 is chosen else if( msg == "Dance1" ) { nextDance = msg; llRequestPermissions(owner, PERMISSION_TRIGGER_ANIMATION); // ... } run_time_permissions(integer perms) { if( perms & PERMISSION_TRIGGER_ANIMATION) { if( lastDance != "") llStopAnimation(lastDance); llStartAnimation(nextDance); lastDance = nextDance; } } 1 Link to comment Share on other sites More sharing options...
SwireD Posted October 22, 2019 Author Share Posted October 22, 2019 11 hours ago, Rolig Loon said: You didn't say what the error is, but you don't really have to put anything in that run_time_permissions event except maybe a line of chat to reassure you that you actually gave the script permission. Hi! Thank you very much! First error was "Script trying to trigger animations but PERMISSION_TRIGGER_ANIMATION permission not set" I did everything like you wrote but now i cant get rid of error "Function call mismatches"... And it refuses to give a menu maybe cause i moved it to run_time_permissions. what am i doing wrong? everything else is just perfect! list MENU_MAIN = ["STOP", "Dance1", "Dance2", "Dance3"]; //up to 12 in list string sound = "a78fd32e-0179-437b-9a39-6b24916aa433"; integer menu_handler; integer menu_channel; KillAnims() { llStopAnimation("Dance1"); llStopObjectAnimation("Dance1"); llStopAnimation("Dance2"); llStopObjectAnimation("Dance2"); llStopAnimation("Dance3"); llStopObjectAnimation("Dance3"); } menu(key user, string title, list buttons) { llListenRemove(menu_handler); menu_channel = (integer)(llFrand(99999.0) * -1); menu_handler = llListen(menu_channel, "", "", ""); llDialog(user, title, buttons, menu_channel); llSetTimerEvent(30.0); } default { state_entry() { } run_time_permissions(integer perm) { if (perm & PERMISSION_TRIGGER_ANIMATION) { menu(llDetectedKey(0), "\nText for Menu.", MENU_MAIN); } } changed(integer change) { if (change & CHANGED_OWNER) { llResetScript(); } } touch_start(integer total_number) { if (llDetectedKey(0) == llGetOwnerKey()) // <- error here "llGetOwnerKey(error here)" { llRequestPermissions(llDetectedKey(0), PERMISSION_TRIGGER_ANIMATION); } } listen(integer channel, string name, key id, string message) { llListenRemove(menu_handler); llSetTimerEvent(0.0); KillAnims(); integer idx = llListFindList(["Dance1", "Dance2", "Dance3"], [message]); if (~idx) { llStartAnimation(message); llStartObjectAnimation(message); } } timer() { llListenRemove(menu_handler); llSetTimerEvent(0); } } Link to comment Share on other sites More sharing options...
SwireD Posted October 22, 2019 Author Share Posted October 22, 2019 (edited) 12 hours ago, Profaitchikenz Haiku said: What is the error exactly? The script doesn't have any syntax errors so it must be something like the specified animation not found? Hi! First error was "Script trying to trigger animations but PERMISSION_TRIGGER_ANIMATION permission not set" I thank you very much and i tried what you advised and it almost works - now i have two errors: [02:57] Could not find animation '' - when i wear it (or reset script) [02:57] Could not find animation 'STOP' - when i hit stop. Please help to finish it. EDIT: ok i fixed animation 'STOP' error but one remains - if i reset script - [03:27] Could not find animation '' why it happens? list MENU_MAIN = ["STOP", "Dance1", "Dance2", "Dance3"]; string sound = "a78fd32e-0179-437b-9a39-6b24916aa433"; integer menu_handler; integer menu_channel; string lastDance = ""; string nextDance = ""; menu(key user, string title, list buttons) { llListenRemove(menu_handler); menu_channel = (integer)(llFrand(99999.0) * -1); menu_handler = llListen(menu_channel, "", "", ""); llDialog(user, title, buttons, menu_channel); llSetTimerEvent(30.0); } default { state_entry() { llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); } run_time_permissions(integer perm) { if (perm & PERMISSION_TRIGGER_ANIMATION) { if (lastDance != "") llStopAnimation(lastDance); llStartAnimation(nextDance); lastDance = nextDance; } } changed(integer change) { if (change & CHANGED_OWNER) { llResetScript(); } } touch_start(integer total_number) { menu(llDetectedKey(0), "\nText for Menu.", MENU_MAIN); } listen(integer channel, string name, key id, string message) { if (channel == menu_channel) { llListenRemove(menu_handler); llSetTimerEvent(0); if (message == "Dance1") { nextDance = message; llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); llStartAnimation("Dance1"); llStartObjectAnimation("Dance1"); llStopAnimation("Dance2"); llStopObjectAnimation("Dance2"); llStopAnimation("Dance3"); llStopObjectAnimation("Dance3"); } else if (message == "Dance2") { nextDance = message; llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); llStopAnimation("Dance1"); llStopObjectAnimation("Dance1"); llStopAnimation("Dance3"); llStopObjectAnimation("Dance3"); llStartAnimation("Dance2"); llStartObjectAnimation("Dance2"); } else if (message == "Dance3") { nextDance = message; llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); llStopAnimation("Dance2"); llStopObjectAnimation("Dance2"); llStopAnimation("Dance1"); llStopObjectAnimation("Dance1"); llStartAnimation("Dance3"); llStartObjectAnimation("Dance3"); } else if (message == "STOP") { llStopAnimation("Dance1"); llStopObjectAnimation("Dance1"); llStopAnimation("Dance2"); llStopObjectAnimation("Dance2"); llStopAnimation("Dance3"); llStopObjectAnimation("Dance3"); } } } timer() { llListenRemove(menu_handler); llSetTimerEvent(0); } } Edited October 22, 2019 by SwireD Link to comment Share on other sites More sharing options...
Fenix Eldritch Posted October 22, 2019 Share Posted October 22, 2019 (edited) 3 hours ago, SwireD said: EDIT: ok i fixed animation 'STOP' error but one remains - if i reset script - [03:27] Could not find animation '' why it happens? The problem is in your run_time_permissions event. You are trying to start the nextDance animation, but that variable has not yet been populated. run_time_permissions(integer perm) { if (perm & PERMISSION_TRIGGER_ANIMATION) { if (lastDance != "") llStopAnimation(lastDance); llStartAnimation(nextDance); lastDance = nextDance; } } When you reset your script, your code immediately requests animation permission, which queues up the above event and the first IF statement passes. At this point in time, no variables have been updated, so lastDance and nextDance are still empty. So the second IF test fails. However, that only prevents "llStopAnimation(lastDance)" from being executed. The other two lines after that are not part of the IF statement, so they will still run and that's why your script complains - it's trying to start an animation called "" but that doesn't exist. Did you mean to group those two lines within the second IF statement? Edited October 22, 2019 by Fenix Eldritch 1 Link to comment Share on other sites More sharing options...
Rolig Loon Posted October 22, 2019 Share Posted October 22, 2019 3 hours ago, SwireD said: I did everything like you wrote but now i cant get rid of error "Function call mismatches"... Oh, I am sorry. That was my fault. The function llGetOwnerKey() is expecting you to tell it the UUID of something that is owned. Specifically, in this case, we want it to return the UUID of the person who owns the scripted object itself: llGetOwnerKey( llGetKey() ) In other words, the if test is asking "If the UUID of the person who just touched me matches my own owner's UUID, then go ahead and ask permission to animate ... " 1 Link to comment Share on other sites More sharing options...
SwireD Posted October 22, 2019 Author Share Posted October 22, 2019 Thank you all very much! Now absolutely no errors! list MENU_MAIN = ["STOP", "Dance1", "Dance2", "Dance3"]; string sound = "a78fd32e-0179-437b-9a39-6b24916aa433"; integer menu_handler; integer menu_channel; string lastDance = ""; string nextDance = ""; menu(key user, string title, list buttons) { llListenRemove(menu_handler); menu_channel = (integer)(llFrand(99999.0) * -1); menu_handler = llListen(menu_channel, "", "", ""); llDialog(user, title, buttons, menu_channel); llSetTimerEvent(30.0); } default { state_entry() { llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); } run_time_permissions(integer perm) { if (perm & PERMISSION_TRIGGER_ANIMATION) { if (lastDance != "") { llStopAnimation(lastDance); llStartAnimation(nextDance); lastDance = nextDance; } } } touch_start(integer total_number) { menu(llDetectedKey(0), "\nText for Menu.", MENU_MAIN); } listen(integer channel, string name, key id, string message) { if (channel == menu_channel) { llListenRemove(menu_handler); llSetTimerEvent(0); if (message == "Dance1") { nextDance = message; llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); llStartAnimation("Dance1"); llStartObjectAnimation("Dance1"); llStopAnimation("Dance2"); llStopObjectAnimation("Dance2"); llStopAnimation("Dance3"); llStopObjectAnimation("Dance3"); } else if (message == "Dance2") { nextDance = message; llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); llStopAnimation("Dance1"); llStopObjectAnimation("Dance1"); llStopAnimation("Dance3"); llStopObjectAnimation("Dance3"); llStartAnimation("Dance2"); llStartObjectAnimation("Dance2"); } else if (message == "Dance3") { nextDance = message; llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); llStopAnimation("Dance2"); llStopObjectAnimation("Dance2"); llStopAnimation("Dance1"); llStopObjectAnimation("Dance1"); llStartAnimation("Dance3"); llStartObjectAnimation("Dance3"); } else if (message == "STOP") { llStopAnimation("Dance1"); llStopObjectAnimation("Dance1"); llStopAnimation("Dance2"); llStopObjectAnimation("Dance2"); llStopAnimation("Dance3"); llStopObjectAnimation("Dance3"); } } } timer() { llListenRemove(menu_handler); llSetTimerEvent(0); } } Link to comment Share on other sites More sharing options...
Profaitchikenz Haiku Posted October 22, 2019 Share Posted October 22, 2019 There is a good reason for doing all the stop and start of animations inside the run_time_permissions event which has become more noticeable recently, and that happens when you try to stop the animation after an avatar has got up from the pose ball they sat upon. Some of the TPV's have an option to revoke permissions from an object when standing up, which means that if the llStopAnimation call is in the changed event, as it has often been, the call to stop the animation fails when a TPV-user with revoke permissions on stand gets up and this leads to an error because of no permission to trigger an animation. 3 Link to comment Share on other sites More sharing options...
SwireD Posted October 22, 2019 Author Share Posted October 22, 2019 (edited) About Rolig Loon's version i still would like to understand - why i cant get menu to appear? list MENU_MAIN = ["STOP", "Dance1", "Dance2", "Dance3"]; //up to 12 in list string sound = "a78fd32e-0179-437b-9a39-6b24916aa433"; integer menu_handler; integer menu_channel; KillAnims() { llStopAnimation("Dance1"); llStopObjectAnimation("Dance1"); llStopAnimation("Dance2"); llStopObjectAnimation("Dance2"); llStopAnimation("Dance3"); llStopObjectAnimation("Dance3"); } menu(key user, string title, list buttons) { llListenRemove(menu_handler); menu_channel = (integer)(llFrand(99999.0) * -1); menu_handler = llListen(menu_channel, "", "", ""); llDialog(user, title, buttons, menu_channel); llSetTimerEvent(30.0); } default { state_entry() { } run_time_permissions(integer perm) { if (perm & PERMISSION_TRIGGER_ANIMATION) { menu(llDetectedKey(0), "\nText for Menu.", MENU_MAIN); } } changed(integer change) { if (change & CHANGED_OWNER) { llResetScript(); } } touch_start(integer total_number) { if (llDetectedKey(0) == llGetOwnerKey(llGetKey())) { llRequestPermissions(llDetectedKey(0), PERMISSION_TRIGGER_ANIMATION); } } listen(integer channel, string name, key id, string message) { llListenRemove(menu_handler); llSetTimerEvent(0.0); KillAnims(); integer idx = llListFindList(["Dance1", "Dance2", "Dance3"], [message]); if (~idx) { llStartAnimation(message); llStartObjectAnimation(message); } } timer() { llListenRemove(menu_handler); llSetTimerEvent(0); } } Edited October 22, 2019 by SwireD Link to comment Share on other sites More sharing options...
Fenix Eldritch Posted October 22, 2019 Share Posted October 22, 2019 llDetectedKey (and related functions) only work within a small subset of events - as per the wiki page specifications: Quote llDetected* functions only work if called from within Detection events (collision, collision_start, collision_end, sensor, touch, touch_start, touch_end) or in functions called by Detection events. They will fail silently and return unusable values if called during other events. So trying to use it in the run_time_permissions event won't work. If you want to reference the user's key that you detected in the touch_start event, you must store it in a global variable. 1 1 Link to comment Share on other sites More sharing options...
Rolig Loon Posted October 22, 2019 Share Posted October 22, 2019 Drat. Of course Fenix isright. This is why we have to remember to include the exculpatory warning in this forum every once in a while: "Warning: Scripts posted here have usually not been tested in world. There is no guarantee that they are bug free, ." All of which is no excuse, but is an explanation. Yes, just make a global key variable (key kAv) and then assign it in the touch_start event: kAv = llDetectedKey(0); Then refer to that in the run_time_permissions event. 1 Link to comment Share on other sites More sharing options...
SwireD Posted October 22, 2019 Author Share Posted October 22, 2019 27 minutes ago, Rolig Loon said: Drat. Of course Fenix isright. This is why we have to remember to include the exculpatory warning in this forum every once in a while: "Warning: Scripts posted here have usually not been tested in world. There is no guarantee that they are bug free, ." All of which is no excuse, but is an explanation. Yes, just make a global key variable (key kAv) and then assign it in the touch_start event: kAv = llDetectedKey(0); Then refer to that in the run_time_permissions event. 35 minutes ago, Fenix Eldritch said: llDetectedKey (and related functions) only work within a small subset of events - as per the wiki page specifications: So trying to use it in the run_time_permissions event won't work. If you want to reference the user's key that you detected in the touch_start event, you must store it in a global variable. Guys you are awesome! Thank you again! another version works list MENU_MAIN = ["STOP", "Dance1", "Dance2", "Dance3"]; string sound = "a78fd32e-0179-437b-9a39-6b24916aa433"; integer menu_handler; integer menu_channel; key kAv; KillAnims() { llStopAnimation("Dance1"); llStopObjectAnimation("Dance1"); llStopAnimation("Dance2"); llStopObjectAnimation("Dance2"); llStopAnimation("Dance3"); llStopObjectAnimation("Dance3"); } menu(key user, string title, list buttons) { llListenRemove(menu_handler); menu_channel = (integer)(llFrand(99999.0) * -1); menu_handler = llListen(menu_channel, "", "", ""); llDialog(user, title, buttons, menu_channel); llSetTimerEvent(30.0); } default { state_entry() { } run_time_permissions(integer perm) { if (perm & PERMISSION_TRIGGER_ANIMATION) { menu(kAv, "\nText for Menu.", MENU_MAIN); } } changed(integer change) { if (change & CHANGED_OWNER) { llResetScript(); } } touch_start(integer total_number) { if (llDetectedKey(0) == llGetOwnerKey(llGetKey())) { llRequestPermissions(llDetectedKey(0), PERMISSION_TRIGGER_ANIMATION); kAv = llDetectedKey(0); } } listen(integer channel, string name, key id, string message) { llListenRemove(menu_handler); llSetTimerEvent(0.0); KillAnims(); integer idx = llListFindList(["Dance1", "Dance2", "Dance3"], [message]); if (~idx) { llStartAnimation(message); llStartObjectAnimation(message); } } timer() { llListenRemove(menu_handler); llSetTimerEvent(0); } } 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now