No -civ FOREST won't work, at least not yet. I will update the script so that it will, but right now it is expecting a number (like if you look at a dwarf or elf with gui/gm-editor there will be a civ_id entry. I'll change it so that if you give it a string instead of a number it will assume you want all civs under entity FOREST to be effected.
You are right, there are actually several typos in the version I have uploaded.
--entity/resource-change.lua version 42.06a
local utils = require 'utils'
local split = utils.split_string
validArgs = validArgs or utils.invert({
'help',
'civ',
'type',
'obj',
'remove',
'add',
'verbose'
})
local args = utils.processArgs({...}, validArgs)
mtype = string.upper(split(args.type,':')[1])
stype = string.upper(split(args.type,':')[2])
mobj = string.upper(split(args.obj,':')[1])
sobj = string.upper(split(args.obj,':')[2])
direction = 0
if args.remove then direction = -1 end
if args.add then direction = 1 end
if args.add and args.removes then return end
if direction == 0 then
print('No valid command, use -remove or -add')
return
end
if tonumber(args.civ) then
civid = tonumber(args.civ)
civ = df.global.world.entities.all[civid]
if not civ then
print('Not a valid civ number')
return
end
dfhack.script_environment('functions/entity').changeResources(civ,mtype,stype,mobj,sobj,direction,args.verbose)
else
civs = {}
n = 0
for _,civ in pairs(df.global.world.entities.all) do
if civ.entity_raw.code == args.civ then
civs[n] = civ
n = n + 1
end
end
for _,civ in pairs(civs) do
dfhack.script_environment('functions/entity').changeResources(civ,mtype,stype,mobj,sobj,direction,args.verbose)
end
end
That should work (just replace everything in the entity/resource-change file). I don't know, however, if it will cause the entity to actually bring the correct wood and such.
EDIT: You can use -civ FOREST with the above posted code