Attribute scripting 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

Attribute scripting won't work

Post by Danimita92 » Wed Aug 06, 2008 5:43 pm

Hi everybody, I was scripting, and suddenly this happened. I have this in the order:

Code: Select all

CogerArma[()
    {
    if(FastDistance("Player", 20) = true)
    {
        BALASTOTALES = (GetAttribute("BalasTotales", "Arma1")); 
        if(BALASTOTALES > 0)
        {
            ModifyAttribute("BalasTotales", +20, "Arma1");
            HighLevel("Eliminar");
            return 0;
        }
}
}]
THe console says Parse error near ""*
Now if I take away
HighLevel("Eliminar");
return 0;
It works.
And if I take away
ModifyAttribute("BalasTotales", +20, "Arma1");
It also works.

So

Code: Select all

CogerArma[()
    {
    if(FastDistance("Player", 20) = true)
    {
        BALASTOTALES = (GetAttribute("BalasTotales", "Arma1")); 
        if(BALASTOTALES > 0)
        {
            HighLevel("Eliminar");
            return 0;
        }
}
}]
and

Code: Select all

CogerArma[()
    {
    if(FastDistance("Player", 20) = true)
    {
        BALASTOTALES = (GetAttribute("BalasTotales", "Arma1")); 
        if(BALASTOTALES > 0)
        {
            ModifyAttribute("BalasTotales", +20, "Arma1");
        }
}
}]
work, but together they won't. Why?

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

Re: Attribute scripting won't work

Post by Danimita92 » Thu Aug 07, 2008 4:26 pm

BTW, i added the attribute in the previous order, like this:

Code: Select all

AddAttribute("BalasTotales", -1, 100, "Arma1");

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

Re: Attribute scripting won't work

Post by Juutis » Thu Aug 07, 2008 4:35 pm

I see nothing wrong with it. Could the bracets around the GetAttribute() mess it up?

Could you post the Eliminar order? Or even better, the whole script.
Pain is only psychological.

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

Re: Attribute scripting won't work

Post by Danimita92 » Thu Aug 07, 2008 4:48 pm

Okay, so I've changed a few things. For example add the order Idle which I didn't have before since it never actually got passed the CogerArma order. Anyway, so now it won't even let me play, because the "Send Report" message appears. The three triggers it asks for are already on the map.

Code: Select all

{
    BALAS [0]
    SLOT [0]
    BALASTOTALES [0]
 
Spawn[()
    {
        Console(true);
        AddAttribute("BalasTotales", -1, 100, "Arma1");
        LowLevel("CogerArma");
    }]

CogerArma[()
{
    if(FastDistance("Player", 20) = true)
    {
        BALASTOTALES = (GetAttribute("BalasTotales", "Arma1")); 
        if(BALASTOTALES > 0)
        {
            ModifyAttribute("BalasTotales", +20, "Arma1");
            HighLevel("Eliminar");
            return 0;
        }
        if(BALASTOTALES -1)
        {
            ModifyAttribute("BalasTotales", +20, "Arma1");
            HighLevel("Eliminar");
            return 0;
        }
        if(BALASTOTALES = 0)
        {
            ModifyAttribute("BalasTotales", +20, "Arma1");
            self.think = "Buscarslot";
            return 0;
        }
    }
}]

Buscarslot[()
    {
        if(GetEventState("Slot1") = false)
        {
            SLOT = 1;
            ActivateTrigger("Slot1");
            self.think = "Idle";
        }
        else
        {
            if(GetEventState("Slot2") = false)
            {
                SLOT = 2;
                ActivateTrigger("Slot2");
                self.think = "Idle";
            }
            else
            {
                if(GetEventState("Slot3") = false)
                {
                    SLOT = 3;
                    ActivateTrigger("Slot3");
                    self.think = "Idle";
                }
                else
                {
                    HighLevel("Eliminar");
                }
            }
        }
    }]

Eliminar[()
{
    Remove(true);
}]

Idle[()
{
    //Nothing yet
}]
    
}

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

Re: Attribute scripting won't work

Post by Juutis » Thu Aug 07, 2008 5:17 pm

Removed some unneeded stuff; brackets, spaces, plus signs. Works fine for me now:

Code: Select all

{
    BALAS [0]
    SLOT [0]
    BALASTOTALES [0]

Spawn[()
    {
        Console(true);
        AddAttribute("BalasTotales",-1,100,"Arma1");
        LowLevel("CogerArma");
    }]

CogerArma[()
{
    if(FastDistance("Player",20))
    {
        BALASTOTALES = GetAttribute("BalasTotales", "Arma1");
        if(BALASTOTALES > 0)
        {
            ModifyAttribute("BalasTotales",20,"Arma1");
            HighLevel("Eliminar");
            return 0;
        }
        if(BALASTOTALES -1)
        {
            ModifyAttribute("BalasTotales",20,"Arma1");
            HighLevel("Eliminar");
            return 0;
        }
        if(BALASTOTALES = 0)
        {
            ModifyAttribute("BalasTotales",20,"Arma1");
            self.think = "Buscarslot";
            return 0;
        }
    }
}]

Buscarslot[()
    {
        if(GetEventState("Slot1") = false)
        {
            SLOT = 1;
            ActivateTrigger("Slot1");
            self.think = "Idle";
        }
        else
        {
            if(GetEventState("Slot2") = false)
            {
                SLOT = 2;
                ActivateTrigger("Slot2");
                self.think = "Idle";
            }
            else
            {
                if(GetEventState("Slot3") = false)
                {
                    SLOT = 3;
                    ActivateTrigger("Slot3");
                    self.think = "Idle";
                }
                else
                {
                    HighLevel("Eliminar");
                }
            }
        }
    }]

Eliminar[()
{
    Remove(true);
}]

Idle[()
{
    //Nothing yet
}]
   
}
If it crashes, double check that you have a pawn called Arma1 in the level.
Pain is only psychological.

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

Re: Attribute scripting won't work

Post by Danimita92 » Thu Aug 07, 2008 6:32 pm

Well, yet again, it was a problem from the program. I reinstalled it in another folder and it worked fine :evil:

Post Reply