Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

can't get this to reset

Maihem Randt
NEXUS-6 N6FAB21416
Join date: 22 Aug 2007
Posts: 108
10-29-2008 23:44
i found thise script here in scripting tips and it works very well, i was trying to get it to automatically reset its self after about 5 seconds without the need for anyone to touch it but being rather noobish at scripting i have failed terribly :(

here it is:

//////////
// Slide Toggler
// Version 1.1
//
// Author: Peter R. Bloomfield (SL: Pedro McMillan)
// Web: http://www.avid-insight.co.uk
//
// If you want to present a few slides in Second Life, then you can rez each
// one in relatively small form, and put this script in. The "front" of the slide
// should be on the +X side.
//
// You can then click each slide to make it toggle forward to the foreground.
// By default, background slides are faded and transparent.
// Foreground slides are full bright and opaque.
//
// Notes:
// - the "foreground" size is always relative to the starting size.
// - the "foreground" position is +X LOCAL of the start position (so you can rotate your slides however you like)
// - can be customized to respond to owner-only, group-only, or anybody
// - this is only really suitable for a small number of slides
// - nearly everything can be customized using the variables below.
//
//////////
//
// GPL:
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
//////////

///// DATA /////
// Amount to move forward by when activated (in metres)
float movementToForeground = -0.15;
// Amount to increase size by when activated (fraction of original size)
float scaleToForeground = 1.5;
// Colours when activated and deactivated
vector foregroundColour = <1.0, 1.0, 1.0>;
vector backgroundColour = <0.9, 0.9, 0.9>;
// Alpha values when activated and deactivated
float foregroundAlpha = 1.0;
float backgroundAlpha = 0.75;
// Access level:
// 0 = public (responds to anybody)
// 1 = group (responds to avatars in the same group, but they have to be in the same sim)
// 2 = owner (responds only to the owner)
integer accessLevel = 0;

///// FUNCTIONS /////
// Checks if the identified avatar is allowed to control this object.
// Returns TRUE if so or FALSE if not.
integer checkAccess( key av )
{
// Always give the owner access
if (av == llGetOwner()) return TRUE;
// Public access
if (accessLevel == 0) return TRUE;
// Group access
if (accessLevel == 1) return llSameGroup(av);
return FALSE;
}
///// STATES /////
// In this state, the slide is small, in the background
default
{
touch_start(integer total_number)
{
// Activate this slide if the owner touched us
if (!checkAccess(llDetectedKey(0))) return;
state focus;
}
}

// In this state, the slide is enlarged in the foreground
state focus
{
state_entry()
{
// Go to full visibility
llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_COLOR, ALL_SIDES, foregroundColour, foregroundAlpha]);
// Scale up
vector bgscale = llGetScale();
vector fgscale = <bgscale.x, bgscale.y * scaleToForeground, bgscale.z * scaleToForeground>;
llSetScale(fgscale);
// Move forward
vector bgpos = llGetPos();
vector fgpos = llGetPos() + (<movementToForeground, 0.0, 0.0> * llGetRot());
llSetPos(fgpos);
}
state_exit()
{
// Go to reduced visibility
llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, FALSE, PRIM_COLOR, ALL_SIDES, backgroundColour, backgroundAlpha]);
// Scale down
vector fgscale = llGetScale();
vector bgscale = <fgscale.x, fgscale.y / scaleToForeground, fgscale.z / scaleToForeground>;
llSetScale(bgscale);
// Move back
vector fgpos = llGetPos();
vector bgpos = llGetPos() - (<movementToForeground, 0.0, 0.0> * llGetRot());
llSetPos(bgpos);
}
touch_start(integer total_number)
{
// Deactivate this slide if the owner touched us
if (!checkAccess(llDetectedKey(0))) return;
state default;
}
}


any help would be awesome
_____________________
Plasma Labs Sci-Fi gadgets, props and cool stuff!
http://www.freewebs.com/plasmalabs/
visit the shop http://snurl.com/4163n
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
10-30-2008 00:56
before the last bracket add

CODE

timer()
state default;
llSetTimerEvent( 0.0 );
}


and in the end of state_entry of state focus add the line
llSetTimerEvent( 5.0 );
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Pedro McMillan
SLOODLE Developer
Join date: 28 Jul 2007
Posts: 231
10-30-2008 02:21
That's a good idea, Maihem. I'll add it as an optional feature to the next version. :-)
Maihem Randt
NEXUS-6 N6FAB21416
Join date: 22 Aug 2007
Posts: 108
10-30-2008 02:28
awesome! ill give that a try when i get home:) i'm using this as part of a control pannel for ressing small vehicles for people to use, beats the heck out of a pop up menu
_____________________
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
10-30-2008 05:52
this is how i patched it in, it doesnt seem to have an effect though so i think i may have goofed it..

//////////
// Slide Toggler
// Version 1.1
//
// Author: Peter R. Bloomfield (SL: Pedro McMillan)
// Web: http://www.avid-insight.co.uk
//
// If you want to present a few slides in Second Life, then you can rez each
// one in relatively small form, and put this script in. The "front" of the slide
// should be on the +X side.
//
// You can then click each slide to make it toggle forward to the foreground.
// By default, background slides are faded and transparent.
// Foreground slides are full bright and opaque.
//
// Notes:
// - the "foreground" size is always relative to the starting size.
// - the "foreground" position is +X LOCAL of the start position (so you can rotate your slides however you like)
// - can be customized to respond to owner-only, group-only, or anybody
// - this is only really suitable for a small number of slides
// - nearly everything can be customized using the variables below.
//
//////////
//
// GPL:
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
//////////


///// DATA /////

// Amount to move forward by when activated (in metres)
float movementToForeground = -0.15;
// Amount to increase size by when activated (fraction of original size)
float scaleToForeground = 1.5;

// Colours when activated and deactivated
vector foregroundColour = <1.0, 1.0, 1.0>;
vector backgroundColour = <0.9, 0.9, 0.9>;
// Alpha values when activated and deactivated
float foregroundAlpha = 1.0;
float backgroundAlpha = 0.75;

// Access level:
// 0 = public (responds to anybody)
// 1 = group (responds to avatars in the same group, but they have to be in the same sim)
// 2 = owner (responds only to the owner)
integer accessLevel = 0;


///// FUNCTIONS /////

// Checks if the identified avatar is allowed to control this object.
// Returns TRUE if so or FALSE if not.
integer checkAccess( key av )
{
// Always give the owner access
if (av == llGetOwner()) return TRUE;

// Public access
if (accessLevel == 0) return TRUE;
// Group access
if (accessLevel == 1) return llSameGroup(av);

return FALSE;
}

///// STATES /////

// In this state, the slide is small, in the background
default
{
touch_start(integer total_number)
{
// Activate this slide if the owner touched us
if (!checkAccess(llDetectedKey(0))) return;
state focus;
}
}


// In this state, the slide is enlarged in the foreground
state focus
{
state_entry()
{
// Go to full visibility
llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_COLOR, ALL_SIDES, foregroundColour, foregroundAlpha]);

// Scale up
vector bgscale = llGetScale();
vector fgscale = <bgscale.x, bgscale.y * scaleToForeground, bgscale.z * scaleToForeground>;
llSetScale(fgscale);
// Move forward
vector bgpos = llGetPos();
vector fgpos = llGetPos() + (<movementToForeground, 0.0, 0.0> * llGetRot());
llSetPos(fgpos);
}

state_exit()
{
// Go to reduced visibility
llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, FALSE, PRIM_COLOR, ALL_SIDES, backgroundColour, backgroundAlpha]);

// Scale down
vector fgscale = llGetScale();
vector bgscale = <fgscale.x, fgscale.y / scaleToForeground, fgscale.z / scaleToForeground>;
llSetScale(bgscale);
// Move back
vector fgpos = llGetPos();
vector bgpos = llGetPos() - (<movementToForeground, 0.0, 0.0> * llGetRot());
llSetPos(bgpos);
}

touch_start(integer total_number)
{
// Deactivate this slide if the owner touched us
if (!checkAccess(llDetectedKey(0))) return;
state default;
}

timer()
{
state default;
llSetTimerEvent( 2.0 );
}

}
_____________________
Plasma Labs Sci-Fi gadgets, props and cool stuff!
http://www.freewebs.com/plasmalabs/
visit the shop http://snurl.com/4163n
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
10-30-2008 08:29
From: someone
and in the end of state_entry of state focus add the line
llSetTimerEvent( 5.0 );

probably right after
llSetPos(fgpos);
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
10-30-2008 09:32
From: Void Singer
before the last bracket add

CODE

timer()
state default;
llSetTimerEvent( 0.0 );
}


and in the end of state_entry of state focus add the line
llSetTimerEvent( 5.0 );


Note that the 'llSetTimerEvent(0.0)' statement from that suggestion will never execute. Switching states implicitly returns from the current event handler. You'll have to switch the order of the statements. There's also a missing open curly brace, though that's a minor syntax issue that most people will probably figure out on their own.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
10-31-2008 04:41
good catch on the order... and apparently maihem did catch the missing brace, good for them =)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Pedro McMillan
SLOODLE Developer
Join date: 28 Jul 2007
Posts: 231
10-31-2008 15:21
Here's the complete script with timer added, for anybody else who wants to use it:

CODE

//////////
// Slide Toggler
// Version 1.1 - modified to add reset timer
//
// Author: Peter R. Bloomfield (SL: Pedro McMillan)
// Web: http://www.avid-insight.co.uk
//
// If you want to present a few slides in Second Life, then you can rez each
// one in relatively small form, and put this script in. The "front" of the slide
// should be on the +X side.
//
// You can then click each slide to make it toggle forward to the foreground.
// By default, background slides are faded and transparent.
// Foreground slides are full bright and opaque.
//
// Notes:
// - the "foreground" size is always relative to the starting size.
// - the "foreground" position is +X LOCAL of the start position (so you can rotate your slides however you like)
// - can be customized to respond to owner-only, group-only, or anybody
// - this is only really suitable for a small number of slides
// - nearly everything can be customized using the variables below.
//
//////////
//
// GPL:
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
//////////


///// DATA /////

// Number of seconds before foreground slide should automatically reset (0.0 for no auto reset)
float resetTime = 5.0;

// Amount to move forward by when activated (in metres)
float movementToForeground = 0.75;
// Amount to increase size by when activated (fraction of original size)
float scaleToForeground = 2.5;

// Colours when activated and deactivated
vector foregroundColour = <1.0, 1.0, 1.0>;
vector backgroundColour = <0.9, 0.9, 0.9>;
// Alpha values when activated and deactivated
float foregroundAlpha = 1.0;
float backgroundAlpha = 0.75;

// Access level:
// 0 = public (responds to anybody)
// 1 = group (responds to avatars in the same group, but they have to be in the same sim)
// 2 = owner (responds only to the owner)
integer accessLevel = 2;


///// FUNCTIONS /////

// Checks if the identified avatar is allowed to control this object.
// Returns TRUE if so or FALSE if not.
integer checkAccess( key av )
{
// Always give the owner access
if (av == llGetOwner()) return TRUE;

// Public access
if (accessLevel == 0) return TRUE;
// Group access
if (accessLevel == 1) return llSameGroup(av);

return FALSE;
}

///// STATES /////

// In this state, the slide is small, in the background
default
{
touch_start(integer total_number)
{
// Activate this slide if the owner touched us
if (!checkAccess(llDetectedKey(0))) return;
state focus;
}
}


// In this state, the slide is enlarged in the foreground
state focus
{
state_entry()
{
// Go to full visibility
llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_COLOR, ALL_SIDES, foregroundColour, foregroundAlpha]);

// Scale up
vector bgscale = llGetScale();
vector fgscale = <bgscale.x, bgscale.y * scaleToForeground, bgscale.z * scaleToForeground>;
llSetScale(fgscale);
// Move forward
vector bgpos = llGetPos();
vector fgpos = llGetPos() + (<movementToForeground, 0.0, 0.0> * llGetRot());
llSetPos(fgpos);

llSetTimerEvent(resetTime);
}

state_exit()
{
llSetTimerEvent(0.0);

// Go to reduced visibility
llSetPrimitiveParams([PRIM_FULLBRIGHT, ALL_SIDES, FALSE, PRIM_COLOR, ALL_SIDES, backgroundColour, backgroundAlpha]);

// Scale down
vector fgscale = llGetScale();
vector bgscale = <fgscale.x, fgscale.y / scaleToForeground, fgscale.z / scaleToForeground>;
llSetScale(bgscale);
// Move back
vector fgpos = llGetPos();
vector bgpos = llGetPos() - (<movementToForeground, 0.0, 0.0> * llGetRot());
llSetPos(bgpos);
}

touch_start(integer total_number)
{
// Deactivated this slide if the owner touched us
if (!checkAccess(llDetectedKey(0))) return;
state default;
}

timer()
{
state default;
}
}