|
ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
|
08-12-2006 09:45
I want a script to reset so it will recognize a new owner and respond to only that owner's chat commands. Have I entered the reset script part correctly below? default { state_entry() { llListen(5,"",llGetOwner(),""); //only owner can change it. //llListen(5,"","",""); //anyone can change it. }
on_rez(integer rez_num) { llResetScript(); }
listen(integer chan, string name, key id, string msg) { //------------------------------------------------------ //------------------------------------------------------ if(msg=="on") { llParticleSystem([PSYS_PART_FLAGS, 0, PSYS_PART_START_ALPHA, 0.800, PSYS_PART_START_COLOR, <1.000, 1.000, 1.000>, PSYS_PART_START_SCALE, <1.200, 1.150, 0>, PSYS_SRC_BURST_RATE, 0.10, PSYS_SRC_BURST_PART_COUNT, 5, PSYS_PART_MAX_AGE, 4.000, PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_ANGLE_CONE, PSYS_SRC_INNERANGLE, 0.100, PSYS_SRC_OUTERANGLE, 0.000, PSYS_SRC_BURST_SPEED_MIN, 1.000, PSYS_SRC_BURST_SPEED_MAX, 1.000, PSYS_SRC_ACCEL, <0.000, 0.001, -1.000>, PSYS_SRC_MAX_AGE, 10.0 ]); } //------------------------------------------------------ { //etcetera for other settings }
} }
_____________________
 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
|
08-12-2006 09:46
That should be fine, yes.
|
|
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
|
08-12-2006 11:23
Resetting the script isn't always convenient on_rez - for example if you wish to retain global variables - in which case the change event offers a flexible alternative: changed(integer change) { if(change & CHANGED_OWNER) { llResetScript(); // or whatever code is appropriate } }
|
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
08-12-2006 11:36
Just for completeness you don't have to do it that way, although that should work just fine.
The changed event has a CHANGED_OWNER trigger, so you can detect a new owner and reset from there. You can also use combinations of llListenRemove and then new llListen calls if you are storing other data you would like to remain persistent across the change of owner.
One example could be a magic wand type thing for a game, with a number of charges. The charges shouldn't reset with a new owner so you'd want to change the listen without resettng the whole script.
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
08-12-2006 11:39
You'll want to have (change & CHANGED_OWNER) there rather than (change == CHANGED_OWNER) - the change bitfield could have more than one flag at once, particularly if a new owner is rezzing an object somewhere.
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
08-12-2006 23:54
Huh. I've never been able to get the CHANED_OWNER change event to actually work. I set a global variable tot he old owner and test 'llGetOwner()' for equivalence in the 'on_rez' event. That change event might work for buying an original, but I have my doubts about where the Wiki says it is called on first rez after change of ownership in other cases. Has anyone actually seen this work explicitly? 
|
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
08-13-2006 00:40
Yes, frequently.
|
|
Grazel Cosmo
Registered User
Join date: 12 Mar 2005
Posts: 28
|
08-13-2006 15:41
You could just have it use a global with the onwer's key and have the on_rez event get the owner's key and remove any old listen and create a new one For example: key owner; integer handle; ... on_rez(integer start_param) { owner = llGetOwner(); llListenRemove(handle); // won't error if handle doesn't exist so safe llListen(5, "", owner, ""); }
|