But what about all those GetVar()s and SetVar()s ?
I thought that all 'VARS' were 'local' variables that exist throughout the function only. (Like auto variables in C)
They're like "static" variables in C: if you give them a value during one invocation, they will still have the value during the next invocation. I don't know how it works when saving/restoring a game.
Do those queries and calls turn them into variables persistent through saves and make a connection between all variables of that name ? (the same variable name is used in all functions in that item script)
Note that there are two different variables in play here: the local/static _IsStatusOn ones, and then the global one that is accessed using the string constant name parameter of SetVar/GetVar ("IsStatusOn").
The former just refers to the local/static variable of the same name declared in the VARS block of the current function.
The latter will (attempt to) access a variable in the global VARS block with the name %IsStatusOn.
The GetVar() in the IF does not make any sense to me, because the queried value is never used in the THEN part (only if it triggered something 'invisible' behind the scenes would it make sense)
The GetVar() query returns FALSE if a global variable with the specified name (prepended with "%") is not defined in any script associated with the current item. So in this case it is only used to determine whether or not the current item has such a variable.
Since Torch.itemScript nor BurningItem.itemScript (included in Torch.itemScript) have a variable with this name, those GetVar() queries will fail if Torch.itemScript is associated with an item that does not declare a global %IsStatusOn in another script associated with the same item.
It appears that the only other script included in DOS:EE that defines such a variable is PUZZLE_StatusApplier.itemScript. This script also contains an EVENT that checks for %IsStatusOn's value, and hence would be affected by changes made by the Torch.itemScript.
Also, simple setting of a value could be done with Set() but here, 'external' calls are used on __Me.
You probably already know the answer to this one by now, but the Set() cannot be used to set %IsStatusOn here because it is not declared in the current script.
And also, when is OnInit() thrown, only once when the object is created for the first time or on every savegame load as well ?
I don't know the answer to this one.