Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Follow script gone wrong upon selling object

Senjin Soothsayer
Registered User
Join date: 5 Oct 2005
Posts: 2
03-05-2006 12:43
Hi everyone, this one has bugged me for ages now and I cannot find a solution. Tried everything I could think of so now it's upto you guys.

I made a pet that is free-roaming and follows you around. Others got an interest in it so I want to sell it, but whenever they rez it, it follows me, instead of them.

It uses llGetOwner to get it's owner and the coordinates of him/her so it can follow. But it somehow keeps going over to me instead. Even when the owner is set to someone else. I tries putting it in a vendor, in boxes, all doesn't work. The moment someone bought it and puts it down, it zooms off to me, ignoring them completely.

Please help out, what is going wrong o.O

Sen

(The following about part of the script is as follows:

CODE
vector offset;
key id;

default
{
state_entry()
{
id = llGetOwner();
llSensorRepeat("", id, AGENT, 96, 2 * PI, 1);
}

sensor(integer total_number)
{
if(llDetectedKey(0) == id)
{
integer randomizer = (integer) llFrand(10);
vector pos = llDetectedPos(0);

if(randomizer == 0)
{
offset.x = llFrand(2) - 1;
offset.y = llFrand(2) - 1;
offset.z = 1 + llFrand(0.2);
}
else if(randomizer > 6)
{
offset.z = 1 + llFrand(0.2);
}

pos += offset;
llSetPos(pos);
}
}
}
Zak Escher
Builder and Scripter
Join date: 3 Aug 2003
Posts: 181
03-05-2006 13:12
Add

CODE

on_rez(integer start_param)
{
llResetScript();
}


in the default state. This will cause the follow script to reset everytime it is rezzed. This should cause the owner to be reset to the true owner of the object.
_____________________
Zak Escher
Unity Shapes
http://slurl.com/secondlife/Hatteras%20Island/125/46/31
http://unityshapes.blogspot.com/
See what I have for sale at SLExchange
Senjin Soothsayer
Registered User
Join date: 5 Oct 2005
Posts: 2
03-05-2006 13:37
It actually works now, I had been stuck with this problem for over a month.

You're my hero!

Thankew thankew thankew thankew *hugs*
Nepenthes Ixchel
Broadly Offended.
Join date: 6 Dec 2005
Posts: 696
03-05-2006 16:14
This also applies to listeners that listed to llGetOwner(); they need to be reset when the owner Changes.

if llResetScript() on rez is not desireable (because you have globals you wish to keep, for example) then try somethinbg like

CODE

//global variable
key gLastOwner=NULL_KEY;

on_rez(integer not_used){
if (gLastOwner!=llGetOwner()){
//reset listeners, or sensors, or whatever
gLastOwner=llGetOwner();
}
}