How to activate only by owner of the object?
|
|
Avion Raymaker
Palacio del Emperador!
Join date: 18 Jun 2007
Posts: 980
|
07-09-2008 12:02
I have a nice texture-switching script originally made by Strife Onizuka. I'd like to either add some code to it, or add another script to the prim, which only allows the owner of the prim to switch the texture. Is that possible?
I've searched like crazy and cannot find a function for this. I'm probably using the wrong terminology.
Thank you, -Avion
|
|
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
|
07-09-2008 12:19
How would a non-owner normally change the texture of a prim?
Is the script maybe triggered by a touch event ? If so, it seems like an "if (llDetectedKey(0) != llGetOwner()) return;" at the top of the touch event would make it ignore touches by anybody except the owner..
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!! - Go here: http://jira.secondlife.com/browse/SVC-1224- If you see "if you were logged in.." on the left, click it and log in - Click the "Vote for it" link on the left
|
|
Avion Raymaker
Palacio del Emperador!
Join date: 18 Jun 2007
Posts: 980
|
07-09-2008 12:30
From: Meade Paravane How would a non-owner normally change the texture of a prim?
Is the script maybe triggered by a touch event ? If so, it seems like an "if (llDetectedKey(0) != llGetOwner()) return;" at the top of the touch event would make it ignore touches by anybody except the owner.. Thank you, Meade, that's what I need. This script simply cycles through all the textures in the prim's inventory when you touch it. I want the owner of a vehicle to be able to change insignia, skins, etc., but don't want spectators to be able to arbitrarily mess with them.
|
|
revochen Mayne
...says
Join date: 14 Nov 2006
Posts: 198
|
07-09-2008 12:42
I wonder if the code is lacking security as it only asks for 'if llDetectedKey(0)!=llGetOwner()' and return then. But what if 2 persons will touch the object exact the same time. That would create a llDetectedKey(1) instance and as its not explicit asked for the script wont return if its not the owner. Or did i miss something? óô
|
|
Virrginia Tombola
Equestrienne
Join date: 10 Nov 2006
Posts: 938
|
07-09-2008 12:59
Good point Revochan, but an easy enough fix, I think. Instead of a return, just make the switch occur only if the owner key is detected:
if(llDetectedKey(0)==llGetOwner()){ TextureSwitch(); }
where "TextureSwitch" is whatever code you use to change the texture.
_____________________
Horses, Carriages, Modern and Historical Riding apparel. Ride a demo horse, play whist, or just loiter. I'm fair used to loiterers. http://slurl.com/secondlife/Caledon%20Eyre/48%20/183/23/
|
|
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
|
07-09-2008 13:18
From: revochen Mayne I wonder if the code is lacking security as it only asks for 'if llDetectedKey(0)!=llGetOwner()' and return then. But what if 2 persons will touch the object exact the same time. That would create a llDetectedKey(1) instance and as its not explicit asked for the script wont return if its not the owner. Or did i miss something? óô I guess it depends on what the script Avion has looks like now.. If the touch event just looks at the first detected thing, what I posted above is probably fine. If it loops through all of them, which I don't doubt since it came from Strife  , it should should be something like... touch_start (integer count) { integer i; for (i = 0; i < count; ++i) { if (llDetectedKey(i) == llGetOwner()) { .... do stuff .... } } }
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!! - Go here: http://jira.secondlife.com/browse/SVC-1224- If you see "if you were logged in.." on the left, click it and log in - Click the "Vote for it" link on the left
|
|
Avion Raymaker
Palacio del Emperador!
Join date: 18 Jun 2007
Posts: 980
|
07-09-2008 13:45
From: Meade Paravane I guess it depends on what the script Avion has looks like now.. If the touch event just looks at the first detected thing, what I posted above is probably fine. If it loops through all of them, which I don't doubt since it came from Strife  , it should should be something like... touch_start (integer count) { integer i; for (i = 0; i < count; ++i) { if (llDetectedKey(i) == llGetOwner()) { .... do stuff .... } } }
Strife's script cycles through the textures one at a time each time you touch it, if you set one of the numbers in there to zero. Otherwise it's a slideshow. I wish I could post it but I simply can't recreate what I did to find it. When I get back in-world I'll test all these great suggestions and report on my success or failure. The script works great for changing the tailflag I want to display on my Zeppelin! It's just that anybody can come by and change it.
|
|
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
|
07-09-2008 13:52
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!! - Go here: http://jira.secondlife.com/browse/SVC-1224- If you see "if you were logged in.." on the left, click it and log in - Click the "Vote for it" link on the left
|
|
Avion Raymaker
Palacio del Emperador!
Join date: 18 Jun 2007
Posts: 980
|
07-09-2008 14:09
Yes!! WOOT That's it. Set float time to 0 if you want it touch activated. It's fantastic because the script doesn't even care what the names of the textures are. But yes, that's the script I want to add the owner-detection to.
|
|
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
|
07-09-2008 14:13
Ok.. Just do this then.. touch_start(integer a) { if (llDetectedKey(0) == llGetOwner()) { next(); } }
Like revochen says above, this might not notice that the owner has touched it if somebody else touches it at the almost-exact same time. That shouldn't happen very often, though.
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!! - Go here: http://jira.secondlife.com/browse/SVC-1224- If you see "if you were logged in.." on the left, click it and log in - Click the "Vote for it" link on the left
|
|
Avion Raymaker
Palacio del Emperador!
Join date: 18 Jun 2007
Posts: 980
|
07-10-2008 07:58
From: Meade Paravane Ok.. Just do this then.. touch_start(integer a) { if (llDetectedKey(0) == llGetOwner()) { next(); } }
Like revochen says above, this might not notice that the owner has touched it if somebody else touches it at the almost-exact same time. That shouldn't happen very often, though. Meade, that worked. Yes, I'm guessing there would be a slim chance of 2 people being able to touch it at once, and even if they do it's not the end of the world. So this will work out perfectly. Thanks everyone, --Avion
|