Rockslide

Caete

Scientist Lady of Science
Joined
Sep 20, 2018
Messages
2,926
Location
20 Minutes into the future
SL Rez
2006
Ok, no surprise that while I can troubleshoot most script issues, I am fairly crap at creating a script from scratch.

So as I am revamping my haunted hous, I want to put a rockslide in it. I want to use a prim to trigger it when it is walked on. I know I'll have to play with the xyz rez spot for the rocks but that's no problem, just trial and error. My issue is the script I have triggers way more than once. So I need it to trigger just once and then a delay before it resets. I have the rocks already set to temp so th delay should be maybe 3-5 minutes. Too late at night for my brain to work so here's what I have started with:

// This script is essentially the example pn the wiki page for llRezObject
// http://wiki.secondlife.com/wiki/LlRezObject
// where some scammer got it from, and is charging 49L for it
// Give away freely!

string object = "Object"; // Name of object in inventory
vector relativePosOffset = <2.0, 0.0, 1.0>; // "Forward" and a little "above" this prim
vector relativeVel = <1.0, 0.0, 0.0>; // Traveling in this prim's "forward" direction at 1m/s
rotation relativeRot = <0.707107, 0.0, 0.0, 0.707107>; // Rotated 90 degrees on the x-axis compared to this prim
integer startParam = 10;

default
{
collision(integer num_detected)
{
vector myPos = llGetPos();
rotation myRot = llGetRot();
vector rezPos = myPos+relativePosOffset*myRot;
vector rezVel = relativeVel*myRot;
rotation rezRot = relativeRot*myRot;
llRezObject(object, rezPos, rezVel, rezRot, startParam);
}
}
 

Fenix

I know how it's spelled!
Joined
Sep 20, 2018
Messages
19
SL Rez
2005
Joined SLU
Nov 9, 2012
My issue is the script I have triggers way more than once. So I need it to trigger just once and then a delay before it resets.
The multiple triggers occur because you're using a collision event, which will continue to trigger as long as something is colliding with it. Even in the short amount of time it might take for an avatar to walk over it, that can easily result in multiple collision events. An easy fix would be to replace the collision event with the collision_start event.

Regarding the delay, this could be accomplished by adding another global variable which will be used to check if the contraption is ready to trigger, or if it's in cooldown. When the collision_start first triggers, check this variable. If we're in cooldown, immediately return to exit out of the event. Otherwise if we are ready, then perform the normal rockslide stuff. In addition, set the new global variable to a value to signify we're in cooldown and start a timer. When the timer pops, set the global variable back to a value to signify we're ready and clear the timer.
Code:
integer READY = TRUE;

default
{
    collision_start(integer num_detected)
    {
        if(!READY){
            return;
        }
      
        llOwnerSay("Rez object");
      
        READY=FALSE;
        llSetTimerEvent(10.0);
    }
  
    timer()
    {
        llSetTimerEvent(0.0);
        READY=TRUE;
    }
}
 
Last edited:
  • 2Thanks
Reactions: Caete and Clara D.