Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

cant get script to reset on a timer

Maihem Randt
NEXUS-6 N6FAB21416
Join date: 22 Aug 2007
Posts: 108
11-26-2008 09:43
this is a hollow prim on touch script I picked up here on the forums and i am trying to get it to reset so the door closes again shortly after it has been opend, say 30 seconds.

so far I'm having no luck possibly due to my poor scripting skills...


//********************************************************
//This Script was pulled out for you by YadNi Monde from the SL FORUMS at /15/1.html, it is intended to stay FREE by it s author(s) and all the comments here in ORANGE must NOT be deleted. They include notes on how to use it and no help will be provided either by YadNi Monde or it s Author(s). IF YOU DO NOT AGREE WITH THIS JUST DONT USE!!!
//********************************************************






// Iris Open Script by Cera Murakami - 7/21/2006
// Touch-sensitive iris opening door
// Toggles open and closed state for a hole in a torus as an iris door
// Put this script into a flattened torus.

// Iris opening door script, using a torus
//This script enables you to use a torus as a simple touch-activated iris door, for science fiction or organic building projects. It uses a torus as the prim for the door, and opens or closes the hole in the torus to operate it.
//
//To use, make a flattened torus, the height and width you need for your door, and about 0.1M to 0.05M thick. The 'door frame' for this can be another torus, or an oval or round hole in another prim.
//
//Note that the same script should also be able to be used with a different prim shape for the iris door prim, by changing the specifications in the two llSetPrimitiveParams statements to suit the other prim shape. I'll experiment some more with that soon, and will offer some variations here later.


// ----- Global Variables ------------------
integer g_OpenNow; // True (1) if iris is 'open' now

default
{
on_rez(integer param)
{
llResetScript();
}

state_entry()
{
if (g_OpenNow == TRUE) // Prim is in open state, so calculate new 'closed' size
{
state WaitToClose;
}
else // Prim is in a closed (or undefined state), so calculate new 'open' size
{
g_OpenNow = FALSE;
state WaitToOpen;
}
}
}

state WaitToClose // Iris is Open, and waiting to close
{
touch_start(integer total_number)
{
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.5, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
g_OpenNow = FALSE;
state WaitToOpen;
}
}

state WaitToOpen // Iris is closed, and waiting to open
{
touch_start(integer total_number)
{
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.05, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
g_OpenNow = TRUE;
state WaitToClose;
}


timer()
{
llResetScript();
}
}
_____________________
Plasma Labs Sci-Fi gadgets, props and cool stuff!
http://www.freewebs.com/plasmalabs/
visit the shop http://snurl.com/4163n
Ee Maculate
Owner of Fourmile Castle
Join date: 11 Jan 2007
Posts: 919
11-26-2008 09:51
You don't have an llSetTimerEvent to tell it to start timing?

http://rpgstats.com/wiki/index.php?title=LlSetTimerEvent
Maihem Randt
NEXUS-6 N6FAB21416
Join date: 22 Aug 2007
Posts: 108
11-26-2008 10:10
Im playing around with default

llSetTimerEvent(30);

but having some difficulties figuring out where it goes in the script
_____________________
Plasma Labs Sci-Fi gadgets, props and cool stuff!
http://www.freewebs.com/plasmalabs/
visit the shop http://snurl.com/4163n
Maihem Randt
NEXUS-6 N6FAB21416
Join date: 22 Aug 2007
Posts: 108
11-26-2008 10:14
syntax errors make me sad

//********************************************************
//This Script was pulled out for you by YadNi Monde from the SL FORUMS at /15/1.html, it is intended to stay FREE by it s author(s) and all the comments here in ORANGE must NOT be deleted. They include notes on how to use it and no help will be provided either by YadNi Monde or it s Author(s). IF YOU DO NOT AGREE WITH THIS JUST DONT USE!!!
//********************************************************






// Iris Open Script by Cera Murakami - 7/21/2006
// Touch-sensitive iris opening door
// Toggles open and closed state for a hole in a torus as an iris door
// Put this script into a flattened torus.

// Iris opening door script, using a torus
//This script enables you to use a torus as a simple touch-activated iris door, for science fiction or organic building projects. It uses a torus as the prim for the door, and opens or closes the hole in the torus to operate it.
//
//To use, make a flattened torus, the height and width you need for your door, and about 0.1M to 0.05M thick. The 'door frame' for this can be another torus, or an oval or round hole in another prim.
//
//Note that the same script should also be able to be used with a different prim shape for the iris door prim, by changing the specifications in the two llSetPrimitiveParams statements to suit the other prim shape. I'll experiment some more with that soon, and will offer some variations here later.


// ----- Global Variables ------------------
integer g_OpenNow; // True (1) if iris is 'open' now

default
{
on_rez(integer param)
{
llResetScript();
}

state_entry()
{
if (g_OpenNow == TRUE) // Prim is in open state, so calculate new 'closed' size
{
state WaitToClose;
}
else // Prim is in a closed (or undefined state), so calculate new 'open' size
{
g_OpenNow = FALSE;
state WaitToOpen;
}
}
}

state WaitToClose // Iris is Open, and waiting to close
{
touch_start(integer total_number)
{
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.5, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
g_OpenNow = FALSE;
state WaitToOpen;
}
}

state WaitToOpen // Iris is closed, and waiting to open
{
touch_start(integer total_number)
{
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.05, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
g_OpenNow = TRUE;
state WaitToClose;
}

}

llSetTimerEvent(30);
}

timer()
{
llResetScript();
}
}
_____________________
Plasma Labs Sci-Fi gadgets, props and cool stuff!
http://www.freewebs.com/plasmalabs/
visit the shop http://snurl.com/4163n
Jeredin Denimore
Romani Ite Domum
Join date: 5 Jul 2008
Posts: 95
11-26-2008 11:14
From: Maihem Randt
syntax errors make me sad

//********************************************************
//This Script was pulled out for you by YadNi Monde from the SL FORUMS at /15/1.html, it is intended to stay FREE by it s author(s) and all the comments here in ORANGE must NOT be deleted. They include notes on how to use it and no help will be provided either by YadNi Monde or it s Author(s). IF YOU DO NOT AGREE WITH THIS JUST DONT USE!!!
//********************************************************






// Iris Open Script by Cera Murakami - 7/21/2006
// Touch-sensitive iris opening door
// Toggles open and closed state for a hole in a torus as an iris door
// Put this script into a flattened torus.

// Iris opening door script, using a torus
//This script enables you to use a torus as a simple touch-activated iris door, for science fiction or organic building projects. It uses a torus as the prim for the door, and opens or closes the hole in the torus to operate it.
//
//To use, make a flattened torus, the height and width you need for your door, and about 0.1M to 0.05M thick. The 'door frame' for this can be another torus, or an oval or round hole in another prim.
//
//Note that the same script should also be able to be used with a different prim shape for the iris door prim, by changing the specifications in the two llSetPrimitiveParams statements to suit the other prim shape. I'll experiment some more with that soon, and will offer some variations here later.


// ----- Global Variables ------------------
integer g_OpenNow; // True (1) if iris is 'open' now

default
{
on_rez(integer param)
{
llResetScript();
}

state_entry()
{
if (g_OpenNow == TRUE) // Prim is in open state, so calculate new 'closed' size
{
state WaitToClose;
}
else // Prim is in a closed (or undefined state), so calculate new 'open' size
{
g_OpenNow = FALSE;
state WaitToOpen;
}
}
}

state WaitToClose // Iris is Open, and waiting to close
{
touch_start(integer total_number)
{
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.5, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
g_OpenNow = FALSE;
state WaitToOpen;
}
}

state WaitToOpen // Iris is closed, and waiting to open
{
touch_start(integer total_number)
{
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.05, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
g_OpenNow = TRUE;
state WaitToClose;
}

}

llSetTimerEvent(30);
}

timer()
{
llResetScript();
}
}


give this a try...
CODE

integer g_OpenNow; // True (1) if iris is 'open' now

default
{
on_rez(integer param)
{
llResetScript();
}

state_entry()
{
if (g_OpenNow == TRUE) // Prim is in open state, so calculate new 'closed' size
{
state WaitToClose;
}
else // Prim is in a closed (or undefined state), so calculate new 'open' size
{
g_OpenNow = FALSE;
state WaitToOpen;
}
}
}

state WaitToClose // Iris is Open, and waiting to close
{
state_entry()
{
llSetTimerEvent(30);
}

timer()
{
llSetTimerEvent(0);
llResetScript();
}

touch_start(integer total_number)
{
llSetTimerEvent(0);
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.5, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
g_OpenNow = FALSE;
state WaitToOpen;
}
}

state WaitToOpen // Iris is closed, and waiting to open
{
state_entry()
{
llSetTimerEvent(30);
}

timer()
{
llSetTimerEvent(0);
llResetScript();
}

touch_start(integer total_number)
{
llSetTimerEvent(0);
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.05, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
g_OpenNow = TRUE;
state WaitToClose;
}
}
Jeredin Denimore
Romani Ite Domum
Join date: 5 Jul 2008
Posts: 95
11-26-2008 11:21
With the above code, I'd add in something to keep it from ping-ponging from state WaitToOpen to state default, which it will. If nobody is there to touch it, it will go from default to WaitToOpen and wait 30 seconds, reset, and go to default...repeated.
Maihem Randt
NEXUS-6 N6FAB21416
Join date: 22 Aug 2007
Posts: 108
11-26-2008 11:29
From: Jeredin Denimore
give this a try...
CODE

integer g_OpenNow; // True (1) if iris is 'open' now

default
{
on_rez(integer param)
{
llResetScript();
}

state_entry()
{
if (g_OpenNow == TRUE) // Prim is in open state, so calculate new 'closed' size
{
state WaitToClose;
}
else // Prim is in a closed (or undefined state), so calculate new 'open' size
{
g_OpenNow = FALSE;
state WaitToOpen;
}
}
}

state WaitToClose // Iris is Open, and waiting to close
{
state_entry()
{
llSetTimerEvent(30);
}

timer()
{
llSetTimerEvent(0);
llResetScript();
}

touch_start(integer total_number)
{
llSetTimerEvent(0);
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.5, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
g_OpenNow = FALSE;
state WaitToOpen;
}
}

state WaitToOpen // Iris is closed, and waiting to open
{
state_entry()
{
llSetTimerEvent(30);
}

timer()
{
llSetTimerEvent(0);
llResetScript();
}

touch_start(integer total_number)
{
llSetTimerEvent(0);
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.05, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
g_OpenNow = TRUE;
state WaitToClose;
}
}

for some reason it doesnt seem to work, the prim hollows but still does not rest after 30 seconds
_____________________
Plasma Labs Sci-Fi gadgets, props and cool stuff!
http://www.freewebs.com/plasmalabs/
visit the shop http://snurl.com/4163n
Jeredin Denimore
Romani Ite Domum
Join date: 5 Jul 2008
Posts: 95
11-26-2008 11:50
That code as written would do the following:

state default
--state entry
----g_OpenNow = undefined
----if check -> g_OpenNow = FALSE
state WaitToOpen
--state entry
----start 30 second timer
(you click the prim)
--touch start
----timer turned off
----prim hollowed
----g_OpenNow = TRUE
state WaitToClose
--state entry
----start 30 second timer
(you don't click the prim)
--timer
----timer turned off
----script reset
(this next section repeated indefinitely)
state default
--state entry
--g_OpenNow = undefined
--if check -> g_OpenNow = FALSE
state WaitToOpen
--state entry
----start 30 second timer
(you don't click the prim)
--timer
----timer turned off
----script reset
(end repeating section)

That what you wanted it to do?
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
11-26-2008 11:53
From: Jeredin Denimore
----g_OpenNow = undefined

An integer will get a default value of 0/FALSE if you don't explicitly set it to something else..
Jeredin Denimore
Romani Ite Domum
Join date: 5 Jul 2008
Posts: 95
11-26-2008 12:01
From: Sindy Tsure
An integer will get a default value of 0/FALSE if you don't explicitly set it to something else..


Yes, I'm aware of that, just pointing out that a default should have been chosen hehe :)
Maihem Randt
NEXUS-6 N6FAB21416
Join date: 22 Aug 2007
Posts: 108
11-26-2008 12:04
From: Jeredin Denimore
That code as written would do the following:

state default
--state entry
----g_OpenNow = undefined
----if check -> g_OpenNow = FALSE
state WaitToOpen
--state entry
----start 30 second timer
(you click the prim)
--touch start
----timer turned off
----prim hollowed
----g_OpenNow = TRUE
state WaitToClose
--state entry
----start 30 second timer
(you don't click the prim)
--timer
----timer turned off
----script reset
(this next section repeated indefinitely)
state default
--state entry
--g_OpenNow = undefined
--if check -> g_OpenNow = FALSE
state WaitToOpen
--state entry
----start 30 second timer
(you don't click the prim)
--timer
----timer turned off
----script reset
(end repeating section)

That what you wanted it to do?

I just wanted to get the door to close automatically if it was not touched again after being opened :(
_____________________
Plasma Labs Sci-Fi gadgets, props and cool stuff!
http://www.freewebs.com/plasmalabs/
visit the shop http://snurl.com/4163n
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
11-26-2008 12:22
From: Maihem Randt
I just wanted to get the door to close automatically if it was not touched again after being opened :(

How about this? Untested but probably close to working..

CODE

float TIMEOUT = 30.0; // no touch = close after this time
integer START_STATE = FALSE;// default to be closed
integer g_OpenNow; // TRUE if the door's open now

Change (integer open)
{
g_OpenNow = open;

if (open)
{
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>,
<1.0, 0.05, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
}
else
{
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>,
<1.0, 0.5, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
}
}

default
{
on_rez(integer param)
{
llResetScript();
}

state_entry()
{
Change (START_STATE);
}

touch_start(integer count)
{
Change (!g_OpenNow);

float time;

if (g_OpenNow)
{
time = TIMEOUT;
}
else
{
time = 0.0;
}

llSetTimerEvent(time);
}

timer()
{
Change (FALSE);
}
}
Jeredin Denimore
Romani Ite Domum
Join date: 5 Jul 2008
Posts: 95
11-26-2008 12:36
From: Maihem Randt
I just wanted to get the door to close automatically if it was not touched again after being opened :(


should just have to change it to:
CODE

integer g_OpenNow = FALSE; // True (1) if iris is 'open' now

default
{
on_rez(integer param)
{
llResetScript();
}

state_entry()
{
if (g_OpenNow == TRUE) // Prim is in open state, so calculate new 'closed' size
{
state WaitToClose;
}
else // Prim is in a closed (or undefined state), so calculate new 'open' size
{
g_OpenNow = FALSE;
state WaitToOpen;
}
}
}

state WaitToClose // Iris is Open, and waiting to close
{
state_entry()
{
llSetTimerEvent(30);
}

timer()
{
llSetTimerEvent(0);
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.5, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
g_OpenNow = FALSE;
state WaitToOpen;}

touch_start(integer total_number)
{
llSetTimerEvent(0);
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.5, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
g_OpenNow = FALSE;
state WaitToOpen;
}
}

state WaitToOpen // Iris is closed, and waiting to open
{
touch_start(integer total_number)
{
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.05, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
g_OpenNow = TRUE;
state WaitToClose;
}
}
Jeredin Denimore
Romani Ite Domum
Join date: 5 Jul 2008
Posts: 95
11-26-2008 12:46
The above won't ping-pong between states.
It will rez and go to WaitToOpen.
It will sit there until clicked.
It will then open and go to WaitForClose and start a 30 second timer.
Whether it is clicked or the timer runs out in 30 seconds, it will close.
It will then sit in WaitForOpen until clicked again.
Maihem Randt
NEXUS-6 N6FAB21416
Join date: 22 Aug 2007
Posts: 108
11-27-2008 01:10
awesome!
_____________________
Plasma Labs Sci-Fi gadgets, props and cool stuff!
http://www.freewebs.com/plasmalabs/
visit the shop http://snurl.com/4163n
Ben Bacon
Registered User
Join date: 14 Jul 2005
Posts: 809
11-27-2008 09:23
simplified a bit...
refactored a bit...
got rid of the unneeded global variable and on_rez event...

CODE

default
{
state_entry()
{
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.5, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
}

touch_start(integer total_number)
{
state open;
}
}

state open
{
state_entry()
{
llSetTimerEvent(30.0);
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.05, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
}

touch_start(integer total_number)
{
state default;
}

timer()
{
state default;
}

state_exit()
{
llSetTimerEvent(0.0);
}
}
Hooten Haller
Wonder and Joy
Join date: 5 Feb 2007
Posts: 45
11-28-2008 03:53
The sole purpose of the default state seems to be to go to state WaitToOpen. The global flag seems to replicate what the states do for the script. The default state's on_rez handler can't ever run because the script never rests in the default state.