Created
May 9, 2012 20:36
-
-
Save warmist/2648613 to your computer and use it in GitHub Desktop.
A script to return bodypart with item ref
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getInv(unit) | |
local ret={} | |
if unit==nil then | |
error("Failed to list unit's items. Unit not selected/valid") | |
end | |
for k,v in ipairs(unit.inventory) do | |
local caste=df.global.world.raws.creatures.all[unit.race].caste[unit.caste] | |
local bp_code=caste.body_info.body_parts[v.body_part_id].part_code | |
local key=bp_code | |
--print("Item:"..tostring(v.item).." "..key) | |
ret[key]=ret[key] or {} | |
table.insert(ret[key],{v:_field('mode')._type[v.mode],v}) | |
end | |
return ret | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment