Omega Tunwarm Posted March 28, 2018 Share Posted March 28, 2018 (edited) Hello, I made a HUD, and I found a script for detaching it: 1. This is the X prim script (and it works just fine) default { touch_start(integer num_detected) { llMessageLinked(LINK_ROOT, 0, "detatch", NULL_KEY); } } 2. This is the root prim script, but I encounter an error on it: (4, 29) : ERROR : Name not defined within scope default { on_rez(integer start_param) { llRequestPermissions(attached, PERMISSION_ATTACH); } link_message(integer sender_num, integer num, string str, key id) { if ("detatch" == str) { //if (PERMISSION_ATTACH & llGetPermissions()) { llDetachFromAvatar(); } } } } Does anyone know what's not correct? Edited March 28, 2018 by Omega Tunwarm Link to comment Share on other sites More sharing options...
KT Kingsley Posted March 28, 2018 Share Posted March 28, 2018 Use... llRequestPermissions(llGetOwner(), PERMISSION_ATTACH); The function llRequestPermissions() requires the key of an avatar and the permissions being requested. In the case of a HUD the avatar wearing it is always its owner, so llGetOwner() will return the key of the avatar wearing the HUD. The name "attached", in your script, has not been defined so it's causing the error you see. 1 Link to comment Share on other sites More sharing options...
Love Zhaoying Posted March 28, 2018 Share Posted March 28, 2018 6 minutes ago, Omega Tunwarm said: llRequestPermissions(attached, PERMISSION_ATTACH); You did not define the “attached” variable above. Note that you will need a run_time_permissions() event to process the response from llRequestPermissions(). See example here: http://wiki.secondlife.com/wiki/LlRequestPermissions 1 1 Link to comment Share on other sites More sharing options...
Innula Zenovka Posted March 28, 2018 Share Posted March 28, 2018 Assuming the HUD is going to be attached by users, from their inventory, and the only time you want to do anything with attachment permissions is when you come to detach it, I wouldn't bother with checking on permissions in the link_message event. It's just as simple to ask for PERMISSION_ATTACH when you need it -- when the HUD is to detach from the avatar -- and not before. Indeed, it simplifies the logic if the only time the script asks for PERMISSION_ATTACH is when it wants to detach the HUD. So something like key kOwner; string strTrigger = "detach";//I like to use variables for as much as possible so I can copy/paste them between scripts so as to avoid typos default { state_entry(){ kOwner = llGetOwner(); } attach(key id){ if(id){ kOwner = id; } } link_message(integer sender_number, integer number, string message, key id){ if(strTrigger == message && (llGetAttached())){//no point in trying to detach something that's not attached in the first place llRequestPermissions(kOwner,PERMISSION_ATTACH); } } run_time_permissions(integer permissions){ if(permissions & PERMISSION_ATTACH){ if (llGetAttached()){ llDetachFromAvatar(); } } } } 2 1 Link to comment Share on other sites More sharing options...
Omega Tunwarm Posted March 28, 2018 Author Share Posted March 28, 2018 Thank you all for the help and suggestions 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