Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Scripted object, owner permissions problem

Namssor Daguerre
Imitates life
Join date: 18 Feb 2004
Posts: 1,423
10-01-2004 08:39
Any ideas how I can make the script below function properly in an object that I give or sell to another person? Currently, the new owner of the object must go into the object contents and reset the script to get it to work. Hope this question isn't too stupid.

Sincerly, a script challenged SL'er

___________________________________________________

key owner; // Key Id for the owner of the script.
float level=0.0;
default
{
state_entry()
{
llSetAlpha(0.5,ALL_SIDES);
owner = llGetOwner();
llListen(0,"",owner,"";); //Listens on channel 0 for the owner

}

listen(integer chan, string name, key id, string msg)
{
if(id == owner) //Listens to commands of owner
{
if (llToLower(msg) == "d";)
{
if (level > 1.0)
{
level=1.0;
}
else
{
level+=0.1;
}
}
if (llToLower(msg) == "l";)
{
if (level < 0.0)
{
level=0.0;
}
else
{
level-=0.1;
}
}
llSetAlpha(level,ALL_SIDES);
}
}
}
_________________________________________________
_____________________
Sensual Casanova
Spoiled Brat
Join date: 28 Feb 2004
Posts: 4,807
10-01-2004 08:48
I dont know much if anything about scripting, but wouldn't reset on rez work for this?
Ace Cassidy
Resident Bohemian
Join date: 5 Apr 2004
Posts: 1,228
10-01-2004 08:53
since your "listen" event handler checks to make sure that its the owner doing the talking, just change the llListen() call from :

llListen(0, "", owner, "";);

to

llListen(0, "", NULL_KEY, "";);

- Ace
_____________________
"Free your mind, and your ass will follow" - George Clinton
Namssor Daguerre
Imitates life
Join date: 18 Feb 2004
Posts: 1,423
10-01-2004 08:54
I tried placing that in the 'state_entry' section. It compliled just fine, but broke the script for both creator and owner. I promptly removed it. Should it go in another spot?
_____________________
Namssor Daguerre
Imitates life
Join date: 18 Feb 2004
Posts: 1,423
10-01-2004 08:59
From: someone
Originally posted by Ace Cassidy
since your "listen" event handler checks to make sure that its the owner doing the talking, just change the llListen() call from :

llListen(0, "", owner, "";);

to

llListen(0, "", NULL_KEY, "";);

- Ace


Thanks Ace, but won't that make the object responsive to any and all? I need to have this object listen only to the owner.
_____________________
Ace Cassidy
Resident Bohemian
Join date: 5 Apr 2004
Posts: 1,228
10-01-2004 09:00
From: someone
Originally posted by Ace Cassidy
since your "listen" event handler checks to make sure that its the owner doing the talking, just change the llListen() call from :

llListen(0, "", owner, "";);

to

llListen(0, "", NULL_KEY, "";);

- Ace


My bad...

Your "listen" handler checks against a global variable that is set on "state_entry"...

Also change the line inside of the "listen" handler from :

if ( id == owner )

to

if ( id == llGetOwner() )

- Ace
_____________________
"Free your mind, and your ass will follow" - George Clinton
Namssor Daguerre
Imitates life
Join date: 18 Feb 2004
Posts: 1,423
10-01-2004 09:07
From: someone
Originally posted by Ace Cassidy
My bad...

Your "listen" handler checks against a global variable that is set on "state_entry"...

Also change the line inside of the "listen" handler from :

if ( id == owner )

to

if ( id == llGetOwner() )

- Ace


Thanks again Ace , I'll try playing with those lines as you suggest.:)
_____________________
Newfie Pendragon
Crusty and proud of it
Join date: 19 Dec 2003
Posts: 1,025
10-05-2004 09:21
From: Ace Cassidy
My bad...

Your "listen" handler checks against a global variable that is set on "state_entry"...

Also change the line inside of the "listen" handler from :

if ( id == owner )

to

if ( id == llGetOwner() )

- Ace




Yep that's the ticket...but also like mentioned before, you may want an on_rez event handler that either resets the script or redoes the llListen (dont forget to llListenRemove() the old listen handle). The script doesn't always reset when transferred to a new owner, so would still be listening for the old owner. The on_rez takes care of making sure the listener is refreshed.


- Newfie Pendragon