Home   Help Search Login Register  

Author Topic: variable corruption  (Read 1300 times)

0 Members and 1 Guest are viewing this topic.

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
variable corruption
« on: 13 Dec 2007, 18:34:10 »
how many global variables can you get away with?
Campaigns are hard, I'll stick with scripting for now!

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: variable corruption
« Reply #1 on: 13 Dec 2007, 18:58:13 »
Also remember lots of user-created addons create new global vars - depending on, of course. Then again, this is supposed to be fixed in 1.09....  :dry:

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline Baddo

  • Former Staff
  • ****
  • Reservist Jaeger
Re: variable corruption
« Reply #2 on: 13 Dec 2007, 19:02:14 »
If it's possible in your case, you could try to reduce them by using loadFile and nil to get at data and to destroy it when it's not needed anymore. This could work if you have constant data which is not dynamically changed. Such data would not be necessary to keep loaded all the time.

Offline Killswitch

  • Members
  • *
  • Peace, cheese and ArmA
Re: variable corruption
« Reply #3 on: 22 Dec 2007, 19:47:10 »
how many global variables can you get away with?
ArmA < 1.09: 240, IIRC
Arma >= 1.09...who knows. If it's really fixed, then "a high number".

Meanwhile, a possible solution to get around GV namespace pollution and overpopulation: use setVariable and getVariable on an object of your choosing (perhaps a game logic):

Example:
Code: [Select]
// init.sqf

// Create a GL to use for variable storage
KLS_MyVars = "Logic" createVehicleLocal [0,0,0];
// Create two utility functions
KLS_fSet = { KLS_MyVars setVariable _this };
KLS_fGet = { KLS_MyVars getVariable _this };

Then, use the utility functions like this:

Code: [Select]
["count",3] call KLS_fSet;

...
...
_count = "count" call KLS_fGet;

hint format ["Count is currently %1",_count];

Yes, it's cumbersome.  :D
« Last Edit: 22 Dec 2007, 19:48:51 by Killswitch »

Offline LeeHunt

  • Former Staff
  • ****
  • John 21:25
Re: variable corruption
« Reply #4 on: 22 Dec 2007, 22:06:38 »
I had the too many global variables problem with the first beta version of Punishment Battalion.  Ultimately it helped me edit and write scripts better though and imroved the mission.  I reduced overall lag by constantly deleting old triggers, objects, variable names etc.  I think i ended up with about 50 global variables and then the saved game works.  But at 200 i had problems.

see this quick tutorial:
http://www.ofpec.com/ed_depot/index.php?action=details&id=413&page=0&game=ArmA&type=tu&cat=xyz

also everytime i use a variable and know i don't need it again, i render the variables nil as Baddo mentioned:

Tank1 domove getmarkerpos "Destination"
~2
tank1 = nil
deletemarker "destination"
destination = nil

exit