if (change & CHANGED_OWNER)
|
|
ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
|
06-14-2008 13:13
I can't seem to get this script to delete it self if the owner changes, can anyone see what the problem is? default { changed(integer change) { if (change & CHANGED_OWNER) { llRemoveInventory(llGetScriptName()); } } state_entry() { llListen(1000,"","",""); //anyone can change it. } on_rez(integer rez_num) { llResetScript(); } listen(integer chan, string name, key id, string msg) { if(msg=="die") { llDie(); } } }
_____________________
 VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30 http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240 http://shop.onrez.com/Archtx_Edo
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
06-14-2008 13:16
Perhaps the on_rez is overtaking the changed, or interfering with it? Try putting the check into both.
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!
http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal
http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
|
|
ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
|
06-14-2008 13:40
Apparantly it was the on_rez keeping it from working. I didn't think I really needed that since it only has one state, so I deleted it and it works fine now. Thank you Ordinal! default { changed(integer change) { if (change & CHANGED_OWNER) { llRemoveInventory(llGetScriptName()); } }
state_entry() { llListen(1000,"","",""); //anyone can change it. }
listen(integer chan, string name, key id, string msg) {
if(msg=="die") { llDie(); }
} }
_____________________
 VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30 http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240 http://shop.onrez.com/Archtx_Edo
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
06-14-2008 13:43
From: Ordinal Malaprop Perhaps the on_rez is overtaking the changed, or interfering with it? Try putting the check into both. EDIT: Cool, you already have it worked out! Yep. When the new owner rezzes the object, the script is reset, which means they are now recognized as the owner. For it to work you will either have to get rid of the on_rez reset script event. Per the wiki: "in the newly-rezzed copy when the user rezzes the object for the first time. (on_rez() is still triggered first.) This occurs whether or not the object was copied or purchased." Or get rid of the changed event and store the original owner as a global and check in on_rez on_rez(integer rez_num) { if(owner != llGetOwner()) llRemoveInventory(llGetScriptName()); else llResetScript(); }
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
|
06-14-2008 15:40
So.. A script reset flushes out any queued events and on_rez comes before changed?
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
06-14-2008 15:56
From: Sindy Tsure So.. A script reset flushes out any queued events and on_rez comes before changed? Yep
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
|
06-14-2008 21:54
That one was good for a laugh... http://www.secondscripter.com/
_____________________
My tutes http://www.youtube.com/johanlaurasia
|
|
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
|
06-15-2008 06:21
When I add a "only for me" script to my items, I add a quick if (llGetOwner() != llGetInventoryCreator(llGetScriptName())) llRemoveInventory(llGetScriptName());
to the init function of my scripts. If the owner of this object, is NOT the creator of this script, delete this script. aka... if *I* no longer own this object, delete the script. This allows me to have scripts that will edit textures in bulk, and do other things, and I can pass them on knowing that on rez or reset, the object will "clean up it's own mess". Sure, the possibility exists that they could rez it in a no-scripts area.. but I ususally just use these scripts for mass editing of textures, or a way to "force" communications into the script for testing purposes.
_____________________
 ● Inworld Store: http://slurl.eclectic-randomness.com ● Website: http://www.eclectic-randomness.com ● Twitter: @WinterVentura
|
|
ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
|
store the original owner as a global ...
06-15-2008 11:50
From: Jesse Barnett EDIT: Cool, you already have it worked out! Yep. When the new owner rezzes the object, the script is reset, which means they are now recognized as the owner. For it to work you will either have to get rid of the on_rez reset script event. Per the wiki: "in the newly-rezzed copy when the user rezzes the object for the first time. (on_rez() is still triggered first.) This occurs whether or not the object was copied or purchased." Or get rid of the changed event and store the original owner as a global and check in on_rez on_rez(integer rez_num) { if(owner != llGetOwner()) llRemoveInventory(llGetScriptName()); else llResetScript(); } Trying to do this "store the original owner as a global ..." This would not compile. key owner = llGetOwner(); This seems to work key owner = "19916e8b-2320-47d5-82f9-5f65a03e4a4e"; //avatar key Is there a better way? default {
state_entry() { llListen(1000,"","",""); //anyone can change it. } on_rez(integer rez_num) { if(owner != llGetOwner()) llRemoveInventory(llGetScriptName()); else llResetScript(); }
listen(integer chan, string name, key id, string msg) {
if(msg=="die") { llDie(); }
} }
_____________________
 VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30 http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240 http://shop.onrez.com/Archtx_Edo
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
06-15-2008 12:18
You can't call a function outside of an event. So you have to:
key owner;
default...................etc etc
state_entry................etc etc owner = llGetOwner();
Although I must add that the way Winter is doing it is more then slightly cool!
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
|
06-16-2008 01:10
From: Jesse Barnett You can't call a function outside of an event. So you have to:
key owner;
default...................etc etc
state_entry................etc etc owner = llGetOwner();
Although I must add that the way Winter is doing it is more then slightly cool! Thanks Jesse, I tried to understand what Winter was describing, unfortunalty "cool" seemed a little beyond my comprehension, but I tried it and it worked. Example below. First what you described, which worked fine: key owner;
default {
state_entry() { owner = llGetOwner(); llListen(1000,"","",""); //anyone can change it. } on_rez(integer rez_num) { if(owner != llGetOwner()) llRemoveInventory(llGetScriptName()); else llResetScript(); }
listen(integer chan, string name, key id, string msg) {
if(msg=="die") { llDie(); }
} }
Then what Winter described: From: someone When I add a "only for me" script to my items, I add a quick if (llGetOwner() != llGetInventoryCreator(llGetScriptName())) llRemoveInventory(llGetScriptName());
to the init function of my scripts. If the owner of this object, is NOT the creator of this script, delete this script. aka... if *I* no longer own this object, delete the script. This allows me to have scripts that will edit textures in bulk, and do other things, and I can pass them on knowing that on rez or reset, the object will "clean up it's own mess". Sure, the possibility exists that they could rez it in a no-scripts area.. but I ususally just use these scripts for mass editing of textures, or a way to "force" communications into the script for testing purposes. I'm not sure which is the "init function" of the script (= initial function? first function?). But I will take a stab at it. This worked when tested in SL, did I do it right?. default { state_entry() { llListen(1000,"","",""); //anyone can change it. } on_rez(integer rez_num) { if (llGetOwner() != llGetInventoryCreator(llGetScriptName())) llRemoveInventory(llGetScriptName()); }
listen(integer chan, string name, key id, string msg) { if(msg=="die") { llDie(); }
} }
_____________________
 VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30 http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240 http://shop.onrez.com/Archtx_Edo
|
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
06-16-2008 14:46
You really only see changed_owner when you sell an object while it exists inworld (you sold the original of the object). Not including a check for it exposes the rare edge-case. default { state_entry() { llListen(1000,"","","die"); //anyone can change it. } on_rez(integer rez_num) { string script = llGetScriptName(); if (llGetOwner() != llGetInventoryCreator(script)) llRemoveInventory(script); } changed(integer change) { if (change & CHANGED_OWNER) { llRemoveInventory(llGetScriptName()); } } listen(integer chan, string name, key id, string msg) { llDie(); } }
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
06-16-2008 15:24
From: Strife Onizuka default { state_entry() { llListen(1000,"","","die"); //anyone can change it. } on_rez(integer rez_num) { string script = llGetScriptName(); if (llGetOwner() != llGetInventoryCreator(script)) llRemoveInventory(script); } changed(integer change) { if (change & CHANGED_OWNER) { llRemoveInventory(llGetScriptName()); } } listen(integer chan, string name, key id, string msg) { llDie(); } }
ugh oh, this is really, really bad. I either need to increase my meds or decrease them. Someone pinch me because I think I just saw a script by Strife that was entirely readable and easy to understand. Nah............................... must be my imagination 
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
06-16-2008 16:06
Ok I admit it, I was lazy, I just copied and pasted the bits of code from the other posts and put them together properly and tweaked them a bit. I usually (I don't think) write unreadable code <.<
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
06-16-2008 16:11
From: Strife Onizuka I usually (I don't think) write unreadable code <.< Sorry for picking on you, it is just that it was a very, very long time before my skills reached the point so that I could understand some of your scripts. You have a knack for boiling a script down to it's very essence. It's a good thing and helped me to grow. I used to have a folder of bookmarks to some of them to peruse every now and then till they finally sank in, one at a time.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
06-16-2008 17:20
From: Strife Onizuka You really only see changed_owner when you sell an object while it exists inworld (you sold the original of the object). Not including a check for it exposes the rare edge-case. Hmm. I don't think that is right. If you take an object or attachment (or a copy; same thing since state is duplicated exactly) into inventory, give it to someone else, and they rez it, I believe you WILL get the changed/CHANGED_OWNER event. However, I wouldn't be surprised if the script has to be started at some point before the tansfer, so if the script is dropped inside the object in a no-script area and the object taken before its default/state_entry runs, I have no idea what the behavior is. I think this is often hidden by the fact that many people reset scripts blindly in the on_rez event, so the changed events never have a chance to fire.
|
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
06-16-2008 23:24
Hewee: You could be right, I'll check it out later and make the behavior explicit in the documentation (which I didn't check before posting <.< )
Jesse: Yeah, I don't like to mess about if I can avoid it. Comments to explain what the code is going to do sure, but I tend to stay away from the step by step commenting. What is the sense in writing more comments then code, the comments can lie to you about what is going on, the code can't (assuming you understand all the implications of the code).
That said some of my code is even a bit too sharp for me, for example I look back on some of my code for coping with rounding errors in my Log2 code and I have to stop and really think about what I wrote because I optimized it so many times that it doesn't resemble the original code. It's got clever solutions mixed in with clever optimizations and devious order of operations stuff.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
|
Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
|
06-17-2008 07:19
I'm having trouble that relates to the issue of changed ownership in a script for an object that is rezzed from an attachment. It works just fine and dandy for me, however, when given to another avatar it fails and the object flies off: key id;
default { changed(integer change) { if (change & CHANGED_OWNER) { llResetScript(); } } state_entry() { id = llGetOwner(); llSetStatus(STATUS_ROTATE_Z,TRUE);//alows object to turn llSetStatus(STATUS_PHYSICS,TRUE);//allows object to move (not necessary as long as object is physical) rotation rot = llGetRot();//gets rotation vector pos = llGetPos();//gets position llSetBuoyancy( .75 ); llSensorRepeat("",id,AGENT,10,2*PI,.4);//(string name, key id, integer type, float range, float arc, float rate); } sensor(integer total_number) { rotation rot = llDetectedRot(0);//sets rotation to value in llGetRot vector pos = llDetectedPos(0);//sets position to value in llGetPos vector offset =< 0.00,0.00,0.25>;//sets offset ie. keeps object from bumping into you assuming its solid llMoveToTarget(pos+=offset,0.2);//makes object move into position defigned byllDetectedPos + offset llRotLookAt(rot, .50, 0.2);//makes object face rotation defigned by llDetectedRot } }
Any clues what I'm doing wrong?
|
|
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
|
06-17-2008 07:37
From: Celty Westwick I'm having trouble that relates to the issue of changed ownership in a script for an object that is rezzed from an attachment. It works just fine and dandy for me, however, when given to another avatar it fails and the object flies off: key id;
default { changed(integer change) { if (change & CHANGED_OWNER) { llResetScript(); } } state_entry() { id = llGetOwner(); llSetStatus(STATUS_ROTATE_Z,TRUE);//alows object to turn llSetStatus(STATUS_PHYSICS,TRUE);//allows object to move (not necessary as long as object is physical) rotation rot = llGetRot();//gets rotation vector pos = llGetPos();//gets position llSetBuoyancy( .75 ); llSensorRepeat("",id,AGENT,10,2*PI,.4);//(string name, key id, integer type, float range, float arc, float rate); } sensor(integer total_number) { rotation rot = llDetectedRot(0);//sets rotation to value in llGetRot vector pos = llDetectedPos(0);//sets position to value in llGetPos vector offset =< 0.00,0.00,0.25>;//sets offset ie. keeps object from bumping into you assuming its solid llMoveToTarget(pos+=offset,0.2);//makes object move into position defigned byllDetectedPos + offset llRotLookAt(rot, .50, 0.2);//makes object face rotation defigned by llDetectedRot } }
Any clues what I'm doing wrong? Change "state_entry to "on_rez" The problem, AGAIN, is that "State Entry" is ONLY RUN ONE TIME.. when YOU SAVE IT. On a single state script (and most scripts ARE SINGLE STATE).. you can treat "state_entry" as if it read "on_save" Here's what I would do. vector offset =< 0.00,0.00,0.25>;//sets offset ie. keeps object from bumping into you assuming its solid key owner; // defined later
init() { owner= llGetOwner(); llSetStatus(STATUS_ROTATE_Z | STATUS_PHYSICS | STATUS_PHANTOM,TRUE);//alows object to turn, move, and NOT bump the avatar it's following. llSetBuoyancy( .75 ); llSensorRepeat("",owner,AGENT,96,2*PI,.4);//(string name, key id, integer type, float range, float arc, float rate); }
default { on_rez(integer startparam) // run EVERY TIME it's rezzed { init(); } state_entry() // run when saved { init(); } sensor(integer total_number) { llMoveToTarget(llDetectedPos(0)+ offset,0.2);//makes object move into position defined by llDetectedPos + offset
// you may find that the following really should "lookat" llDetectedPos. (Assuming you want it to look at the person it's following? not in the direction they're looking) llRotLookAt(llDetectedRot(0), .50, 0.2);//makes object face rotation defined by llDetectedRot } }
_____________________
 ● Inworld Store: http://slurl.eclectic-randomness.com ● Website: http://www.eclectic-randomness.com ● Twitter: @WinterVentura
|
|
Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
|
06-17-2008 08:12
Worked like a charm! Thanks very much Winter  , I'll remember that.
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
06-17-2008 10:28
From: Winter Ventura Change "state_entry to "on_rez"
The problem, AGAIN, is that "State Entry" is ONLY RUN ONE TIME.. when YOU SAVE IT. On a single state script (and most scripts ARE SINGLE STATE).. you can treat "state_entry" as if it read "on_save" Well, that's not quite true. default/state_entry IS definitely run when you reset the script, either manually or with llResetScript(). It's interesting that the object being rezzed doesn't get the CHANGED_OWNER in order to do its reset. Hmm. Maybe Strife is right. If so someone should fix/clarify this line, which has been around for a very long time and which I know I have depended on in the past with success in at least some circumstances: "The ownership of the object changed. This value is passed when an object is deeded to a group, when an object is purchased, or when a newly-purchased object is rezzed." ( http://www.lslwiki.net/lslwiki/wakka.php?wakka=changed)
|
|
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
|
06-17-2008 12:54
From: Hewee Zetkin Well, that's not quite true. You're splitting hairs. Everything in your PC's "Startup Folder" is executed when your computer is restarted too.
_____________________
 ● Inworld Store: http://slurl.eclectic-randomness.com ● Website: http://www.eclectic-randomness.com ● Twitter: @WinterVentura
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
06-17-2008 13:05
From: Winter Ventura You're splitting hairs. It's probably a relevant hair in this case since the script contained a call to llResetScript().
|
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
06-17-2008 14:03
You need to call llStopMoveToTarget() and llStopLookAt() when you rez the object. When the object rezzes it tries to move to the old position. on_rez { llStopMoveToTarget(); llStopLookAt(); }
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|