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
Scripts with AddLocalVarInt
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#5
RE: Scripts with AddLocalVarInt

You may want to use SetLocalVarInt rather than AddLocalVarInt - 'Set' merely sets the variable you specify to the value you specify, wheras 'Add' actually adds the value you specify to the total that the variable holds. That should explain why it worked the first time, although there might be another problem as well.

SetLocalVarInt("Int", 1);
AddLocalVarInt("Int", 1);
// "Int" now equals 2

SetLocalVarInt("Int", 1);
SetLocalVarInt("Int", 1);
// "Int" still equals 1

(06-12-2013, 09:59 PM)Bridge Wrote: Well I don't know what's wrong with your script but seeing as integers generally take up 4 bytes and Boolean variables only 1 you save a whole bunch of space that otherwise goes towards doing nothing. A good general rule of thumb is to use as few resources as you possibly can to achieve what you want. Doesn't do anything to make your code more functional, just more efficient.

The potential problem with using a bool is that there is no engine function to set a bool variable, and only variables set by the engine functions will be saved when you exit/reload your game. Any variables declared simply using bool MyBool = true; in the global scope of the script will therefore be re-initialized when the map reloads. It could then present some weird behaviors for the puzzle if the player saves & exits, or just goes out of the map and back in, although your absolutely right if that risk is managed correctly

(This post was last modified: 06-13-2013, 12:31 PM by Adrianis.)
06-13-2013, 12:25 PM
Find


Messages In This Thread
Scripts with AddLocalVarInt - by Neelke - 06-12-2013, 08:08 PM
RE: Scripts with AddLocalVarInt - by Bridge - 06-12-2013, 09:14 PM
RE: Scripts with AddLocalVarInt - by Neelke - 06-12-2013, 09:30 PM
RE: Scripts with AddLocalVarInt - by Bridge - 06-12-2013, 09:59 PM
RE: Scripts with AddLocalVarInt - by Adrianis - 06-13-2013, 12:25 PM
RE: Scripts with AddLocalVarInt - by Bridge - 06-13-2013, 10:09 PM



Users browsing this thread: 1 Guest(s)