function getxyz() -- this will return pointers x,y and z coordinates. local x=df.global.cursor.x local y=df.global.cursor.y local z=df.global.cursor.z return x,y,z -- return the coords end function getCreatureAtPos(x,y,z) -- gets the creature index @ x,y,z coord --local x,y,z=getxyz() --get 'X' coords local vector=df.global.world.units.all -- load all creatures for i = 0, #vector-1 do -- look into all creatures offsets local curpos=vector[i].pos --get its coordinates local cx=curpos.x local cy=curpos.y local cz=curpos.z if cx==x and cy==y and cz==z then --compare them return vector[i] --return index end end --print("Creature not found!") return nil end unit=getCreatureAtPos(getxyz()) item=getItemAtPos(getxyz()) for a,b in ipairs(df.global.world.items.all) do for c,d in ipairs(b.general_refs) do end end local u_ref=df.general_ref_contains_unitst:new() u_ref.unit_id=unit.id item.general_refs:insert(#item.general_refs,u_ref) local u_cr_ref=df.general_ref_contained_in_itemst:new() unit.flags1.caged=true u_cr_ref.item_id=item.id general_refs:insert(#general_refs,u_cr_ref)