2012-05-08 02:55:06 -06:00
|
|
|
-- List input items for the building currently being built.
|
2012-05-13 08:39:00 -06:00
|
|
|
--
|
|
|
|
-- This is where the filters in lua/dfhack/buildings.lua come from.
|
2012-05-08 02:55:06 -06:00
|
|
|
|
|
|
|
local dumper = require 'dumper'
|
2012-05-13 08:39:00 -06:00
|
|
|
local utils = require 'utils'
|
|
|
|
local buildings = require 'dfhack.buildings'
|
2012-05-08 02:55:06 -06:00
|
|
|
|
2012-05-13 08:39:00 -06:00
|
|
|
local function name_enum(tgt,name,ename,enum)
|
|
|
|
if tgt[name] ~= nil then
|
|
|
|
tgt[name] = ename..'.'..enum[tgt[name]]
|
2012-05-08 02:55:06 -06:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local lookup = {}
|
2012-05-13 08:39:00 -06:00
|
|
|
local items = df.global.world.items
|
2012-05-08 02:55:06 -06:00
|
|
|
|
|
|
|
for i=df.job_item_vector_id._first_item,df.job_item_vector_id._last_item do
|
|
|
|
local id = df.job_item_vector_id.attrs[i].other
|
|
|
|
local ptr
|
|
|
|
if id == df.items_other_id.ANY then
|
2012-05-13 08:39:00 -06:00
|
|
|
ptr = items.all
|
2012-05-08 02:55:06 -06:00
|
|
|
elseif id == df.items_other_id.BAD then
|
2012-05-13 08:39:00 -06:00
|
|
|
ptr = items.bad
|
2012-05-08 02:55:06 -06:00
|
|
|
else
|
2012-05-13 08:39:00 -06:00
|
|
|
ptr = items.other[id]
|
2012-05-08 02:55:06 -06:00
|
|
|
end
|
|
|
|
if ptr then
|
|
|
|
local _,addr = df.sizeof(ptr)
|
|
|
|
lookup[addr] = 'df.job_item_vector_id.'..df.job_item_vector_id[i]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function clone_filter(src,quantity)
|
2012-05-13 08:39:00 -06:00
|
|
|
local tgt = utils.clone_with_default(src, buildings.input_filter_defaults, true)
|
2012-05-08 02:55:06 -06:00
|
|
|
if quantity ~= 1 then
|
|
|
|
tgt.quantity = quantity
|
|
|
|
end
|
2012-05-13 08:39:00 -06:00
|
|
|
name_enum(tgt, 'item_type', 'df.item_type', df.item_type)
|
|
|
|
name_enum(tgt, 'has_tool_use', 'df.tool_uses', df.tool_uses)
|
2012-05-08 02:55:06 -06:00
|
|
|
local ptr = src.item_vector
|
|
|
|
if ptr and ptr ~= df.global.world.items.other[0] then
|
|
|
|
local _,addr = df.sizeof(ptr)
|
|
|
|
tgt.vector_id = lookup[addr]
|
|
|
|
end
|
|
|
|
return tgt
|
|
|
|
end
|
|
|
|
|
|
|
|
local function dump(name)
|
|
|
|
local out = {}
|
|
|
|
for i,v in ipairs(df.global.ui_build_selector.requirements) do
|
|
|
|
out[#out+1] = clone_filter(v.filter, v.count_required)
|
|
|
|
end
|
|
|
|
|
|
|
|
local fmt = dumper.DataDumper(out,name,false,1,4)
|
2012-05-13 08:39:00 -06:00
|
|
|
fmt = string.gsub(fmt, '"(df%.[^"]+)"','%1')
|
|
|
|
fmt = string.gsub(fmt, '%s+$', '')
|
|
|
|
print(fmt)
|
2012-05-08 02:55:06 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
local itype = df.global.ui_build_selector.building_type
|
|
|
|
local stype = df.global.ui_build_selector.building_subtype
|
|
|
|
|
|
|
|
if itype == df.building_type.Workshop then
|
|
|
|
dump(' [df.workshop_type.'..df.workshop_type[stype]..'] = ')
|
|
|
|
elseif itype == df.building_type.Furnace then
|
|
|
|
dump(' [df.furnace_type.'..df.furnace_type[stype]..'] = ')
|
|
|
|
elseif itype == df.building_type.Trap then
|
|
|
|
dump(' [df.trap_type.'..df.trap_type[stype]..'] = ')
|
|
|
|
else
|
|
|
|
dump(' [df.building_type.'..df.building_type[itype]..'] = ')
|
|
|
|
end
|