Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Button (On) (Off)
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#2
RE: Button (On) (Off)

Your syntax is incorrect. You have the else statement, but you never asked the if statement, so it doesn't know what to do. How about this:

PHP Code: (Select All)
void button(string &in asEntity)
{
    if(
GetLocalVarInt("button") != 0// ON
    
{
        
SetLocalVarInt("button"0); // set to OFF
        // Do stuff
    
}
    else
    {
        
SetLocalVarInt("button"1); // set to ON
        // Do stuff
    
}


Here, value 0 (which is default) is treated as OFF and any other value is treated as ON. That should be safest. I'm also using the Set function rather than the Add function to be more restrictive about the possible states. This is only useful if you have only these 2 states the button can be in - using Add can be useful if you have many different states after each other.

03-07-2018, 02:46 AM
Find


Messages In This Thread
Button (On) (Off) - by User01 - 03-06-2018, 07:09 PM
RE: Button (On) (Off) - by Mudbill - 03-07-2018, 02:46 AM



Users browsing this thread: 1 Guest(s)