Bay 12 Games Forum
Dwarf Fortress => DF Modding => Utilities and 3rd Party Applications => Topic started by: Metallion on March 16, 2015, 04:21:11 pm
-
I've a script in the hack/scripts (add-syndromes) directory that require a file (syndrome-util) in the hack/lua directory, which in turn requies another file (utils) in the hack/lua directory. When I try to run add-syndromes, I get the error:
...workDF V6.2\Dwarf Fortress\hack\scripts/add-syndrome.lua:6: attempt to call field 'invert' (a nil value)
stack traceback:
...workDF V6.2\Dwarf Fortress\hack\scripts/add-syndrome.lua:6: in main chunk
(...tail calls...)
I've confirmed that invert is a function defined in utils.lua.
What am I doing wrong?
-
Lua, not LUA.
It's trying to call "invert" rather than "utils.invert".
-
I'm afraid that's not it. I should have quoted the code:
--usage: syndromeUtil.ResetPolicy.DoNothing, syndromeUtil.ResetPolicy.ResetDuration, etc
ResetPolicy = ResetPolicy or utils.invert({
"DoNothing",
"ResetDuration",
"AddDuration",
"NewInstance"
})
(Please note I take no credit for this code!)
-
Did you just copy the code from 0.40.24 to 0.34.11? I'm not sure if that'll work. utils.invert wasn't added until later.
-
That may be it. I'll see if the latest version of DFHack works with MDF. Thanks.
-
utils.invert was added in DFHack 0.40.08-r1: https://github.com/DFHack/dfhack/commit/0db0244d08e69eb36c0f31700c76b2de83fbc4ef
You could easily implement that function in your script, though:
function invert(tab)
local result = {}
for k,v in pairs(tab) do
result[v]=k
end
return result
end