Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Why doesn't this script reset?

Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
12-17-2008 18:59
I've written a server script that communicates with a number of remote client HUDs. It works fine, but I want to set things up so that if I need to re-rez the server for some reason, I can pass a new key to each of the HUDs without having to run around and find each owner and hand her/him the new key. Since I am passing other data to an external server anyway, I decided I might as well also pass the new key to it and then tell the client HUDs to check the external server for an updated key before they do anything else. Here's how I have that part of the server script written....

CODE

string URL = "http://infoisland.org/admin/roving/set_asset_id.php?id=";
init()
{
ServerKey = (string)llGetKey();
URL = URL + ServerKey;
llOwnerSay(ServerKey + " " + URL);
http3 = llHTTPRequest(URL,[HTTP_METHOD, "POST"],"");
llSetObjectDesc(ServerKey);
}
default
{
on_rez(integer start_param)
{
init();
}

state_entry()
{
init();
state manage_remote;
}
// Lots of other stuff
}
state manage_remote
{
// Stuff here too
}


This works just the way I intended, except..... when I rez the server, the steps in the init function don't execute until I click the Reset button. Why should I have to force a Reset? Why doesn't the script reset automatically when the object is rezzed?
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
12-17-2008 19:40
That's the way it's supposed to work. When you take an object into inventory, all the script state is saved then restored again when you re-rez it.

Add these lines to make it reset when rezzed..

on_rez (integer param)
{
llResetScript();
}

or, if you just want to make it reset when it changes owner, do something like this instead:

changed (integer mask)
{
if (mask & CHANGED_OWNER)
{
llResetScript();
}
}
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
12-17-2008 19:42
When you take the object back into inventory, the script is in the manage_remote state. When you rez it back in world, it's still in that state.

Add an on_rez handler to the manage_remote state, too.
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
12-17-2008 19:48
Thanks! I'll give it a shot.
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
12-17-2008 20:36
Nope. That didn't make any difference at all. It still works fine, except that I have to reset the script manually after rezzing it.:confused:

EDIT: Hmmm.... Something that I just did made it work, though. Wish I could figure out what it was. Thanks anyway.
ab Vanmoer
Registered User
Join date: 28 Nov 2006
Posts: 131
12-17-2008 21:22
In your state_entry, you call init() and then switch state to manage_remote.
In your on_rez you only call init() but don't switch to the manage_remote state.

If you want you script to reset when it is rezzed, use

on_rez(integer param)
{
llResetScript();
}

remember though you will have to put that in all states that could be active when the object is rezzed.
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
12-17-2008 22:45
Thanks. In a roundabout way, I think that's what finally beat the problem. I cleaned up the script a bit, taking out a few statements that were just there for debugging purposes, and managed to make a smoother entry into the manage_remote state while I was at it. Something in that cleanup did the trick.