Jump to content

Door that closes on a timer - Syntax error - timer()


snakeyoslo
 Share

You are about to reply to a thread that has been inactive for 2672 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hey there, I'm really new to the whole scripting business and I have found a script online for a sliding door, the full script also has colision which I don't want (for some reason my breedables can open the doors). Anyway I'm only using a portion of the script to make it open or close on click, and I'd love to make it close automatically, but everytime I add that portion of the script in I get a syntax error. Heres the script with the time section added in:

// Sliding door 
// Handles the touch event.

vector delta = <0.0, 1.8, 0.0>;             // amount to move door 
                                            // when we open it

vector closed_position;                     // original position of the 
                                            // door when closed

// Processing for the script when it first starts up

default {
    // What we do when we first enter this state

    state_entry() {
        closed_position = llGetPos();       // Save position when door is closed
        state closed;                       // Move to the closed state
    }
}

// Processing for the script when it is in the closed state

state closed {
    // What we do when we first enter this state

    state_entry() {
        llSetPos(closed_position);          // Move door to closed position
    }

    // What we do when the door is clicked ("touched") with the mouse

    touch_start(integer total_number) {
        state open;                         // Move to the open state
    }
}

// Processing for the script when it is in the open state

state open {
    // What we do when we first enter this state

    state_entry() {
        llSetPos(closed_position + delta);  // Move door to open position
    }

    // What we do when the door is clicked ("touched") with the mouse

    touch_start(integer total_number) {
        state closed;                       // Move to the closed state
    }
}
    // What to do when the timer goes off

    timer()
    {
        llSetTimerEvent(0.0);               // Set the timer to 0.0 to turn it off
    }
}

// Processing for the script when it is in the open state

state open {
    // What we do when we first enter this state

    state_entry() {
        llSetPos(closed_position + delta);  // Move door to open position
        llSetTimerEvent(delay);             // Set the timer to automatically close it
    }

    // What we do when the door is clicked ("touched") with the mouse

    touch_start(integer total_number) {
        state closed;                       // Move to the closed state
    }

    // What to do when the timer goes off

    timer()
    {
        llSetTimerEvent(0.0);               // Set the timer to 0.0 to turn it off
        state closed;                       // Move to the closed state
    }
}  

I've highlighted the line that is giving me the syntax error, but I can't see where I've gone wrong, I'd appreciate all the help I can get, thank you.

Link to comment
Share on other sites

You're closing state open too early, leaving timer() stateless. Check your parantheses below the end of touch_start in state open.

e.g. (with comments and event contents removed for clarity):-

state open{    state_entry() { ... }    touch_start(integer total_number) { ... }    timer() { ... }}

You also have two state opens. I don't think this will compile, either.

Hope this helps. :)

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2672 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...