dfhack/plugins/Dfusion/luafiles/utils.lua

1 line
692 B
Lua

function findVectorsSized(size)
local ret={}
local text=GetTextRegion()
for k,v in pairs(offsets.getvectors()) do
if GetRegionIn2(k)~=nil then
--if v>4 then
local tv=engine.peek(k,ptr_vector)
if tv:size() == size then
print(string.format("%x is size %d",k,size))
table.insert(ret,k)
end
end
end
return ret
end
function findMaterial(mattype,matname) --currently only stones
local tbl=BuildMaterialTable()
return tbl[matname]
end
function iter(tbl)
if getmetatable(tbl) ~=nil then
if getmetatable(tbl).__next~= nil then
return getmetatable(tbl).__next,tbl
else
return getmetatable(tbl).__pairs(tbl) or pairs(tbl)
end
else
return pairs(tbl)
end
end