Reivan Posted May 2, 2023 Share Posted May 2, 2023 (edited) Hello i want to make hud with two buttons that show hide obiects wearing by avatar. Avatar have weared not linked two objects A and B, hud have two buttons A and B, when i click A button it shows A object and hide B object, When i click B button it shows B object and hide A object. I managed to make this hud button script: default { on_rez(integer rez) { if (!llGetAttached() ) llResetScript(); } state_entry() { llRequestPermissions( llGetOwner(), PERMISSION_ATTACH); } touch_start(integer total_number) { llRegionSay( -20,"off" ); } } And this object script: string ANIM = "animation"; integer an = 0; default { state_entry() { llListen(-20, "", NULL_KEY, ""); llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); } listen(integer channel, string name, key id, string message) { if (llGetOwner() == llGetOwnerKey(id) ) { if(message == "off") { llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); llSetLinkAlpha(LINK_THIS, 0.0, ALL_SIDES); an=1; } if(message == "on") { llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); llSetLinkAlpha(LINK_THIS, 1.0, ALL_SIDES); an=0; } } } run_time_permissions(integer perm) { if (perm & PERMISSION_TRIGGER_ANIMATION) { if (an) llStartAnimation(ANIM); else llStopAnimation(ANIM); } } } And it somehow work but with one problem, i tested it on my friend avatar and when i use hud my friend avatar is also controled, i spend couple of hours on this and nothing i tried works, anyone willing to help me with this making it to work only on owner avatar? Edited May 2, 2023 by Reivan Link to comment Share on other sites More sharing options...
Rolig Loon Posted May 2, 2023 Share Posted May 2, 2023 You scripted the HUD button to reset on rez, but you forgot to do the same thing for the object's script. 2 Link to comment Share on other sites More sharing options...
Love Zhaoying Posted May 2, 2023 Share Posted May 2, 2023 13 minutes ago, Rolig Loon said: You scripted the HUD button to reset on rez, but you forgot to do the same thing for the object's script. Does that explain why the object's script still reacts to the previous owner's messages? Link to comment Share on other sites More sharing options...
Rolig Loon Posted May 2, 2023 Share Posted May 2, 2023 Yup. If the new owner manually reset the scripts, that would fix it too, but you shouldn't ever count on the new owner doing that. If your script ever relies on knowing who llGetOwner is, it's best to reset it if you expect the owner to change. 1 1 Link to comment Share on other sites More sharing options...
Quistess Alpha Posted May 2, 2023 Share Posted May 2, 2023 FWIW, this is why it's very useful to put something like changed(integer c) { if(c&CHANGED_OWNER) { llResetScript(); } } in most scripts in things intended to be given to someone else. It also often saves you from passing along 'personal settings' that may have changed from default values. 3 2 Link to comment Share on other sites More sharing options...
Reivan Posted May 2, 2023 Author Share Posted May 2, 2023 Thanks, now works as intended. 1 Link to comment Share on other sites More sharing options...
primerib1 Posted May 5, 2023 Share Posted May 5, 2023 On 5/2/2023 at 9:55 PM, Quistess Alpha said: FWIW, this is why it's very useful to put something like changed(integer c) { if(c&CHANGED_OWNER) { llResetScript(); } } in most scripts in things intended to be given to someone else. It also often saves you from passing along 'personal settings' that may have changed from default values. I now just do llResetScript() on_rez. Then the thing just pulls its previous state from LSD and all is well. 1 Link to comment Share on other sites More sharing options...
Rolig Loon Posted May 5, 2023 Share Posted May 5, 2023 Either way works. If you don't want to force a restart for some reason, you can also use Tessa's way to just change the owner. if (c&CHANGED_OWNER) Owner = llGetOwner(); Where you are using a global key variable to hold the UUID. Link to comment Share on other sites More sharing options...
Quistess Alpha Posted May 5, 2023 Share Posted May 5, 2023 1 hour ago, Rolig Loon said: Either way works. If you don't want to force a restart for some reason, you can also use Tessa's way to just change the owner. if (c&CHANGED_OWNER) Owner = llGetOwner(); Where you are using a global key variable to hold the UUID. and remember to remove and reset any owner-only listens, and re-set important config values if applicable. 2 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