You may be better able to see the problem with the script if you indent it
begin skeletonkingfree float Gateopen set Gateopen to 0 if onactivate == 1 If Gateopen == 0 skelpole1->Disable skelpole2->Disable skelpole3->Disable Set Gateopen to 1 if Gateopen == 1 Skelpole1->enable skelpole2->enable skelpole3->enable endif endif endifend
When you activate it, it checks if gateopen is 0. If it is 0 it disables everything and sets gateopen to 1. It then checks if gateopen is 1 and enables everything
What you ment to do I think is:
begin skeletonkingfree float Gateopen set Gateopen to 0 if onactivate == 1 If Gateopen == 0 skelpole1->Disable skelpole2->Disable skelpole3->Disable Set Gateopen to 1 endif if Gateopen == 1 Skelpole1->enable skelpole2->enable skelpole3->enable Set Gateopen to 0 endif endifend
I it is also worth noting that if you shouldn't ever compare floats using equality. This is as floating point numbers can't represent all numbers exactly.
It is better to define gateopen as being a short. (Which can represent a subset of the natural numbers)
It may also
may be better to enclose the condition for the if statement in brackets. Some people say it leads to bugs if you don't. I haven't ever seen a firm example of this though.
begin skeletonkingfree short Gateopen set Gateopen to 0 if ( onactivate == 1 ) If ( Gateopen == 0 ) skelpole1->Disable skelpole2->Disable skelpole3->Disable Set Gateopen to 1 elseif ( Gateopen == 1 ) Skelpole1->enable skelpole2->enable skelpole3->enable Set Gateopen to 0 endif endifend
You could also use the getDisabled function rather than using a variable
begin skeletonkingfree if ( onactivate == 1 ) If ( skelpole1->GetDisabled == 0 ) skelpole1->Disable skelpole2->Disable skelpole3->Disable else Skelpole1->enable skelpole2->enable skelpole3->enable endif endifend