Advertisement

Author Topic: Call Nil  (Read 522 times)

0 Members and 1 Guest are viewing this topic.

Offline Rommel92

  • Members
  • *
Call Nil
« on: 17 Oct 2009, 10:29:02 »
Just wondering, in my script (disablefx.sqf) below, I can't decide whether to use up memory (however small!) with {} or just nil the entire functions. But I know that the event handlers are called from the unit config, so I was wondering, seeing as neither causes an error, which should I use?

Code: [Select]
waituntil {!isnil "BIS_Effects_Secondaries"};
BIS_Effects_EH_Fired=nil;
BIS_Effects_EH_Killed=nil;

BIS_Effects_Rifle=nil;
BIS_Effects_Cannon=nil;
BIS_Effects_HeavyCaliber=nil;
BIS_Effects_HeavySniper=nil;
BIS_Effects_Rocket=nil;
BIS_Effects_SmokeShell=nil;
BIS_Effects_SmokeLauncher=nil;
BIS_Effects_Flares=nil;

BIS_Effects_Burn=nil;
BIS_Effects_AircraftVapour=nil;
BIS_Effects_AirDestruction=nil;
BIS_Effects_AirDestructionStage2=nil;
BIS_Effects_Secondaries=nil;
BIS_Effects_RocketTrail=nil;
« Last Edit: 05 May 2013, 05:21:21 by Rommel92 »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Call Nil
« Reply #1 on: 21 Oct 2009, 12:46:51 »
Well, there is a difference. If you use Nil, then the variable or function is deleted, if you use = {}, then it is not deleted, it simply has no code inside. So, if something checks the existance of a function to call it, with Nil it will detect the function doesnt exist and will do nothing, with {} the function exists, so the calling process might try to execute it and the results will never be the expected ones.