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
What does "+=" do?
tonitoni1998 Offline
Member

Posts: 163
Threads: 54
Joined: Oct 2012
Reputation: 1
#1
What does "+=" do?

i saw it in the code lock script
( http://www.frictionalgames.com/forum/sho...e=threaded ) from NaxEla

i couldnt find it anywhere else.

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);
    }
}

When you are looking for someone, to do the scripting for your Custom Story, ask me!
(This post was last modified: 02-25-2013, 04:58 PM by tonitoni1998.)
02-25-2013, 04:57 PM
Find
darksky Offline
Member

Posts: 52
Threads: 8
Joined: Nov 2012
Reputation: 2
#2
RE: What does "+=" do?

i += 1 is the same as i = i+1;
02-25-2013, 05:01 PM
Find
tonitoni1998 Offline
Member

Posts: 163
Threads: 54
Joined: Oct 2012
Reputation: 1
#3
RE: What does "+=" do?

so it actually just says "add"?

When you are looking for someone, to do the scripting for your Custom Story, ask me!
02-25-2013, 05:03 PM
Find
darksky Offline
Member

Posts: 52
Threads: 8
Joined: Nov 2012
Reputation: 2
#4
RE: What does "+=" do?

yes, i += x "add x to i, and store in variable i"

but you can also do -=, *=, /=
02-25-2013, 05:10 PM
Find
No Author Offline
Posting Freak

Posts: 962
Threads: 10
Joined: Jun 2012
Reputation: 13
#5
RE: What does "+=" do?

Got to refresh my brain for an hour after reading this.

[Image: the-cabin-in-the-woods-masked-people.jpg]
02-26-2013, 12:16 AM
Find




Users browsing this thread: 1 Guest(s)