Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Reset, or not reset?

Allan Beltran
Registered User
Join date: 2 Dec 2006
Posts: 52
12-10-2006 16:28
Okay, my first scripting question with a bit of code for you to examine.

I have some flags that affect how my object behaves. When I copy the object in-world using the SHIFT+Drag method, those flags remain the same. But I need them to reset on touch, BEFORE doing anything, since it's a new object, but wasn't rezzed. So here is my solution...question follows.

CODE
integer my_flag;
key my_key;
init()
{
my_flag = FALSE;
my_key = llGetKey();
}

default
{
state_entry()
{
init();
}

on_rez(integer start_program)
{
init();
llResetScript();
}

touch_start(integer total_number)
{
if(my_key != llGetKey())
{
init();
llResetScript();
}
}
}
My question: Is the use of llReSetScript() here redundant? Furthermore, in regards to init(), is that even neccessary if I establish the default values when I declare them?

Once again, I'm at work and unable to test my assumptions, but doe the following code do the same thing, but without the call to init()?

CODE
integer my_flag = FALSE;
key my_key = llGetKey();

default
{
state_entry()
{
//nothing to do here.
}

on_rez(integer start_program)
{
llResetScript();
}

touch_start(integer total_number)
{
if(my_key != llGetKey())
{
llResetScript();
}
}
}

Thanks for the help...
Kitty Barnett
Registered User
Join date: 10 May 2006
Posts: 5,586
12-10-2006 17:01
When you shift-drag to make a copy, the scripts in the copy automatically 'reset' (state_entry gets called) so the following really should just work:

CODE
integer my_flag = FALSE; 

default
{
state_entry()
{
}

on_rez(integer start_program)
{
llResetScript();
}
}
It's non-intuitive, but when you copy with shift-drag, the copy is actually the one that stays behind, and the one you drag away is the original. Maybe that's why it looks like the "copy" isn't getting reset?
Allan Beltran
Registered User
Join date: 2 Dec 2006
Posts: 52
12-10-2006 17:10
From: Kitty Barnett
It's non-intuitive, but when you copy with shift-drag, the copy is actually the one that stays behind, and the one you drag away is the original. Maybe that's why it looks like the "copy" isn't getting reset?
Ah, I seem to have missed that somewhere in the wiki. Thank you very much.