Thanks. One last question:
In many lua scripts I see the lines "--@module = true" and "if not dfhack_flags.module then". What is the point of these?
"--@ module = true" permits the script to be used as a module, which basically means that other scripts can call functions from it via "reqscript".
Consider the following snippet from "resurrect-adv.lua", which calls the "heal()" function of "full-heal.lua":
local fullHeal = reqscript('full-heal')
...
fullHeal.heal(adventurer, true)
If "full-heal.lua" lacked "--@ module = true", the above code would fail at the reqscript line with the error "full-heal: Cannot be used as a module."
"dfhack_flags.module" is set when the script is being called through reqscript. It's added to module-enabled scripts to prevent unnecessary code from running when they are being used as modules (if omitted, the whole script would run as if it had been called from console).
For example:
if not dfhack_flags.module then
print("foo")
end
Prevents "foo" from being printed during a reqscript call.
if dfhack_flags.module then
return
end
print("foo")
An alternative way to do the above.
"moduleMode" is sometimes used instead of "dfhack_flags.module"; they do the same thing as far as I'm aware.