Frictional Games Forum (read-only)

Full Version: What does "+=" do?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i saw it in the code lock script
( http://www.frictionalgames.com/forum/sho...e=threaded ) from NaxEla

i couldnt find it anywhere else.

Code:
void PressedButton(string &in entity)
{
    int buttonsPressed;
    
    AddLocalVarInt("ButtonsPressed", 1);
    
    playersGuessedCode += GetButtonPressed(entity);    /// HERE
    buttonsPressed = GetLocalVarInt("ButtonsPressed");
    
    AddDebugMessage("Buttons Pressed: "+buttonsPressed+"  Guessed Code: "+playersGuessedCode, false);
    
    if(playersGuessedCode == correctCode) {
        SetSwingDoorLocked("door", false, false);
        for(int i=0; i<=9; i++) {
            SetEntityActive("Button_"+i, true);
        }
        ResetCode();
        AddDebugMessage("Correct code!", false);
        
        return;
    }
    
    if(buttonsPressed == 4) {
        ResetCode();
        AddDebugMessage("Wrong code!", false);
    }
}
i += 1 is the same as i = i+1;
so it actually just says "add"?
yes, i += x "add x to i, and store in variable i"

but you can also do -=, *=, /=
Got to refresh my brain for an hour after reading this.