Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local utils = require('utils')
- local validArgs = utils.invert({
- "q",
- "b",
- "f",
- })
- local args = utils.processArgs({...}, validArgs)
- function item_description(item)
- return dfhack.df2console( dfhack.items.getDescription(item, 0, true) )
- end
- local function unit_name(unit)
- return dfhack.df2console(dfhack.TranslateName(dfhack.units.getVisibleName(unit)))
- end
- function find_squad_position(unit)
- for i, squad in pairs( df.global.world.squads.all ) do
- for i, position in pairs( squad.positions ) do
- if position.occupant == unit.hist_figure_id then
- return position
- end
- end
- end
- return nil
- end
- local unit = dfhack.gui.getSelectedUnit()
- if not unit then
- qerror('unit not selected')
- end
- local position = find_squad_position(unit)
- if not position then
- qerror("unit's squad position not found")
- end
- local items = { }
- if args.q then table.insert(items, "quiver") end
- if args.b then table.insert(items, "backpack") end
- if args.f then table.insert(items, "flask") end
- if #items == 0 then items = { "quiver", "backpack", "flask" } end
- for i, itemname in pairs( items ) do
- local item_id = position[itemname]
- local item = df.item.find(item_id)
- local item_desc
- if item then
- item_desc = item_description(item)
- end
- print("unit", unit_name(unit), itemname, position[itemname], item_id, item, item_desc)
- position[itemname] = -1
- end
- unit.military.pickup_flags.update = true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement