HUGE thanks for your answers, I'm a total noob with those scripts.
(If you ever needed some Osiris answers, I'm much better with that ;-)

Originally Posted by Tinkerer
Originally Posted by FrauBlake
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.

But still 'function local', having no connection to the other event's variables of that name, correct ?

BurningItem.itemScript obviously only starts and stops a candle's flame if it's lit or unlit, only stores the loop effect handle.

Must be that the BURNING status is stored with the object itself, because I see no other way it could be re-initialized by the script after a load.

Looking through the script and trying to understand it, in the case of the Torch, it does not seem to matter at all if local or static or 'script global', the variable seems to be nothing more than a 'target dump' for a potentially existing global variable.
Originally Posted by Tinkerer
Originally Posted by FrauBlake

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.

My bad, sorry for being so stupid, should have figured that out myself.

Originally Posted by Tinkerer
Originally Posted by FrauBlake

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.

Does it only return FALSE because the variable is not found in global space or does it also set the local (static) _IsStatusOn to 'null' ?

Also, can globals (%xyz) be accessed in 'parallel' scripts that do not #include them or must there be some 'connection' ?
Originally Posted by Tinkerer
Originally Posted by FrauBlake

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.

Originally Posted by FrauBlake

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.

So put together, all that variable querying and setting is only for additional scripts that might get attached to an item and have that variable ? It serves no purpose if only Torch.itemScript is attached ?

Sorry again for asking stupidly. This script greatly confused me and finding no global variable of that name made me suspect that some 'hidden magic' was going on behind the scene. I never would have thought that a script contained some 'pro-active' stuff. But then, maybe it's just left over from something that existed before. (Cleaning up is not easy ;-)

The reason I picked just that script was that I want to create a candle that always burns if I move it out of inventory. Currently it is way too easy to trigger the OnUse event which might leave a candle off when used as a 'grenade'. Happened to me quite often and there's no way to check the state while a candle is in the inventory.

Do you also happen to know, what the 'data "Flags" "Torch"' in stat entries means ?
Could it have something to do with only items with it receiving the events handled in BurningItem.itemScript at all ? (Only found the events there)
All root templates that have the Torch.itemScript seem to use Stats with this flag.


BTW, your videos with the moving wagons are quite impressive !!