Door Script won't work

Topics regarding Scripting with Reality Factory
Post Reply
Danimita92
Posts: 335
Joined: Sat Feb 09, 2008 5:47 pm
Location: Lanzarote/Canary Islands/Spain

Door Script won't work

Post by Danimita92 » Sun Oct 05, 2008 12:56 pm

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

User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Re: Door Script won't work

Post by Juutis » Sun Oct 05, 2008 1:09 pm

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
Pain is only psychological.

Danimita92
Posts: 335
Joined: Sat Feb 09, 2008 5:47 pm
Location: Lanzarote/Canary Islands/Spain

Re: Door Script won't work

Post by Danimita92 » Sun Oct 05, 2008 1:13 pm

Oh, thanks a lot, Juutis. Always fast and helpfull, man. I'll try it now.

Post Reply