Page 1 of 1

Door Script won't work

Posted: Sun Oct 05, 2008 12:56 pm
by Danimita92
I am making a script for a door that opens and closes with various animations. It isn't complete, but it won't work. No console, no model in the scene. Just an open space where the door should be. here's the script. Every { has a } and every [ has a ]. The script starts with a { and ends with a } and I still can't see where it goes wrong:

Code: Select all

{
    ACCIONSLOTS [0]
    OPENORCLOSED [0] //Open is 1, closed is 0

Spawn[()
{
    Console(true);
    LowLevel("IsClose");
    return 0;
}]

IsClose[()
{
    AnimationSpeed(1.50);
    if(OPENORCLOSED = 0)
    {
    if(FastDistance("jugador", 50))
    {
        if(GetAttribute("Acciones", "jugador") = 0)
        {
            ACCIONSLOTS = 1;
            self.think = "Closed";
            return 0;
        }
        if(GetAttribute("Acciones", "jugador") = 1)
        {
            ACCIONSLOTS = 2;
            self.think = "Closed";
            return 0;
        }
        if(GetAttribute("Acciones", "jugador") = 2)
        {
            ACCIONSLOTS = 3;
            self.think = "Closed";
            return 0;
        }
        if(GetAttribute("Acciones", "jugador") = 3)
        {
            return 0;
        }
    }
    }
    if(OPENORCLOSED = 1)
    {
        if(FastDistance("jugador", 50))
        {
        if(GetAttribute("Acciones", "jugador") = 0)
        {
            ACCIONSLOTS = 1;
            self.think = "Open";
            return 0;
        }
        if(GetAttribute("Acciones", "jugador") = 1)
        {
            ACCIONSLOTS = 2;
            self.think = "Open";
            return 0;
        }
        if(GetAttribute("Acciones", "jugador") = 2)
        {
            ACCIONSLOTS = 3;
            self.think = "Open";
            return 0;
        }
        if(GetAttribute("Acciones", "jugador") = 3)
        {
            return 0;
        }
        }
    }
}]

Closed[()
{
    if(FastDistance("jugador", 50) = false)
    {
        self.think = "IsClose";
        return 0;
    }
    SetTarget("jugador");
    SetFOV(179);  //Si lo ve, es que es para empujar.
    SetAttribute("Acciones", ACCIONSLOTS, "jugador");
    if(ACCIONSLOTS = 1)
    {
        if(IsKeyDown(29))
        {
            if(self.enemy_vis = true)
            {
                SetPosition("jugador", self.current_X , self.current_Y, self.current_Z - 8);                 
                Animate("opendoor");
                AnimateEntity("Pulldoor", "jugador", true);
                if(jugador.animate_at_end)
                {
                    SetAttribute("Accionando", 0, "jugador");
                    AnimateBlend("opened", 1);
                    OPENORCLOSED = 1;
                    Self.think = "Open";
                }
            }
        }
    }
}]

Open [()
{
    if(FastDistance("jugador", 50) = false)
    {
        self.think = "IsClose";
        return 0;
    }
    SetTarget("jugador");
    SetFOV(179);  //Si lo ve, es que es para empujar.
    SetAttribute("Acciones", ACCIONSLOTS, "jugador");
    if(ACCIONSLOTS = 1)
    {
        if(IsKeyDown(29))
        {
            if(self.enemy_vis = true)
            {
                SetPosition("jugador", self.current_X , self.current_Y, self.current_Z - 8);                 
                Animate("closedoor");
                AnimateEntity("Pulldoor", "jugador", true);
                if(jugador.animate_at_end)
                {
                    SetAttribute("Accionando", 0, "jugador");
                    AnimateBlend("closed", 1);
                    OPENORCLOSED = 0;
                    Self.think = "Closed";
                }
            }
        }
    }
}]

}
Thanks for reading, and I hope you can help me

Re: Door Script won't work

Posted: Sun Oct 05, 2008 1:09 pm
by Juutis
It's the comment in the start of the script:

Code: Select all

//Open is 1, closed is 0
The manual:
Never start a line with the // , /* or */. Place a space or a tab first.

Don't put the name of an order at the start of the comment.

Don't use ( or ) in a comment

Re: Door Script won't work

Posted: Sun Oct 05, 2008 1:13 pm
by Danimita92
Oh, thanks a lot, Juutis. Always fast and helpfull, man. I'll try it now.