It won't work, let me clarify it for you:
void OnStart ()
{
AddEntityCollideCallback("box1","area_red","BOX1RED", false, 1);
}
void BOX1RED(string &in asParent, string &in asChild, int alState)
{if(asChild == "area_red") {
SetLightVisible("redy", true);
// "redy" is a pointlight
}
else SetLightVisible("redy", false);
}
1. the alState in AddEntityCollideCallback doesn't mean - "1" means that the "BOX1RED" runs on collide (-1 runs when they're not colliding) - it means
alStates = 1=only call when entity enters, -1=only call when entity leaves 0=both
2. a solution to your problem I can think of is:
void OnStart ()
{
AddEntityCollideCallback("box1","area_red","BOX1RED", false, 0);
SetLocalVarInt("RedLightOn", 1);
}
void BOX1RED(string &in asParent, string &in asChild, int alState)
{
//Why this? Do you want to trigger this function from multiple areas? If not, remove it.
if(asChild == "area_red") {
if(GetLocalVarInt("RedLightOn") == 1) SetLocalVarInt("RedLightOn", 0);
else SetLocalVarInt("RedLightOn", 1);
if(GetLocalVarInt("RedLightOn") == 1) SetLightVisible("redy", true);
else SetLightVisible("redy", false);
}
}
Could have made the script much easier if the game had local booleans though.