OFPEC Forum

Addons & Mods Depot => Arma2 - Configs & Scripting => Topic started by: DMarkwick on 05 Sep 2009, 20:09:50

Title: Initialising a global variable.
Post by: DMarkwick on 05 Sep 2009, 20:09:50
OK, so in my Fire & Smoke addon, I'm implementing a maximum concurrent fires limit. Lets say that limit is 100, starting from 0, and that the variable I'll use will be called JTD_CurrentFires. The addon itself is driven by eventhandlers, so there is no single-run script where I can initialise global variables.

(If anyone knows how I CAN run an initialisation script from a config, that will be the best method BTW.)

So, how DO I initialise a global variable in this case? In the config I've tried:
Code: [Select]
JTD_CurrentFires = 0; but that doesn't seem to work on its own, and so in the script I've tried:
Code: [Select]
JTD_CurrentFires = getNumber(configFile >> "JTD_FireTrees");but all that does is set the number back to 0 every time, as you would expect :)

?
Title: Re: Initialising a global variable.
Post by: Wolfrug on 05 Sep 2009, 20:41:21
Code: [Select]
if (isNil "JTD_CurrentFires") then {JTD_CurrentFires = getNumber(configFile >> "JTD_FireTrees")};
Should initialize JTD_CurrentFires in the script (once). Then just add and remove from that number as you desire, I guess!

Wolfrug out.
Title: Re: Initialising a global variable.
Post by: DMarkwick on 05 Sep 2009, 23:39:08
Thanks :)