Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Scripted item breaks when copy given to new owner

Markov Brodsky
Junior Member
Join date: 2 Sep 2004
Posts: 4
09-12-2004 20:59
I built a puzzle game and haven't changed any of the default permissions on anything; eventually, I want to sell the item and have no-modify no-copy, so the default perms seemed ok.

Any of the copies I've worked on seem just fine; I can touch parts to activate scripts and play the game, as can others.

However, I gave a copy of the game to another player for testing. But her copy was dead! Nothing worked, not for me, not for her. Touching the parts resulted in nothing.

I really have no idea why... maybe there's something about the permissions system that affects scripts running, I don't know.

Any ideas?
_____________________
Huns Valen
Don't PM me here.
Join date: 3 May 2003
Posts: 2,749
09-12-2004 21:10
CODE
key lastOwner;

default {
on_rez(integer param) {
// Reset
if(llGetOwner() == lastOwner)
return;
lastOwner = llGetOwner();
linkTx("reset", 0);
}
// ...
}


I put this code in the jet I sell. That way, whenever someone buys a copy, it resets as soon as they rez it. This makes sure that any code that does an owner check gets refreshed. It is also generally a good idea, as it clears out any variables that may have been set, ensuring the object is at 100% factory settings. The linkTx() call goes to a llMessageLinked() wrapper, so that all the other scripts get reset as well.
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
09-13-2004 12:59
Huns:

I'm trying to understand the syntax of LSL... so please do not take this as a criticism of your code:

In your code I see:

From: someone
if(llGetOwner() == lastOwner)
return;


Does LSL permit the single item body of the conditional code to exist without the curley braces?

Or should that be:

if(llGetOwner() == lastOwner)
{
return;
}

?
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
Huns Valen
Don't PM me here.
Join date: 3 May 2003
Posts: 2,749
09-13-2004 16:10
Yes, I pasted that directly from the source.
Hank Ramos
Lifetime Scripter
Join date: 15 Nov 2003
Posts: 2,328
09-13-2004 18:39
This will work for most people. Just add this event handler, and everytime your object is rezzed from inventory, the script will reset. This will ensure that all variables, permissions, and owner-specific stuff is reinitialized...

CODE

on_rez(integer startup_param)
{
llResetScript();
}