|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
01-12-2009 00:26
I'm trying to make something for an RP game in which objects will get passed from player to player quite a bit and it's important for the object to know who the previous owner was as well as who owns it at the moment. If I give someone an object containing a script that includes changed(integer change) { if (change & CHANGED_OWNER) { llSetObjectDesc(llGetOwner()); llResetScript(); } } whose key will get set as the object description -- mine (the previous owner) or theirs? And if it is their key and not mine that gets set there, is any other way to get the script to remember who gave the object to the current owner? Ideally, I would like to write an init() function that only gets called when the owner changes, use that to reset some variables and keep others, and not reset the script at all unless it's necessary because something's gone wrong. Does that sound feasible?
|
|
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
|
01-12-2009 00:54
It will get the key of the current owner when the script can run again.
If it was transferred via avatar inventory, scripts aren't running, and it will not update until it is next rezzed. That means that you could have it go through several owners via avatar inventory, and it will only register the one which next rezzes it in-world.
Yes, you should be able to use your init() function idea just fine, depending on how you code the rest of the script. llResetScript() isn't really necessary unless you just want to start over fresh.
|
|
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
|
01-12-2009 01:17
Something like this does it:
string owner;
default { state_entry() { owner = llKey2Name(llGetOwner()); llSay(0, "Previous owner: " + llGetObjectDesc()); llSay(0, "Current owner: " + owner); }
changed(integer change) { if (change & CHANGED_OWNER){ llSetObjectDesc(owner); llResetScript(); } } }
|
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
01-13-2009 03:53
Thanks, both... that clarifies things a lot and does what i need. Looks like this going to be a bit simpler than at first i feared (famous last words...).
|