-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathzonefind.lua
More file actions
35 lines (32 loc) · 1.17 KB
/
zonefind.lua
File metadata and controls
35 lines (32 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
-- zonefind.lua
-- Print all civzones on the map along with player's position
-- Usage: zonefind
local adv = dfhack.world and dfhack.world.getAdventurer and dfhack.world.getAdventurer()
local px, py, pz
if adv and adv.pos then
px, py, pz = adv.pos.x, adv.pos.y, adv.pos.z
print(("Player position: x=%d y=%d z=%d"):format(px, py, pz))
else
print("Player position: unknown")
end
print("")
local total = 0
for _, bld in ipairs(df.global.world.buildings.all) do
if df.building_civzonest:is_instance(bld) then
local type_name = df.civzone_type[bld:getSubtype()] or tostring(bld:getSubtype())
local here = px and px >= bld.x1 and px <= bld.x2
and py >= bld.y1 and py <= bld.y2
and pz == bld.z
local marker = here and " <== YOU ARE HERE" or ""
print(("[%s] x=%d-%d y=%d-%d z=%d (size %dx%d)%s"):format(
type_name, bld.x1, bld.x2, bld.y1, bld.y2, bld.z,
bld.x2 - bld.x1 + 1, bld.y2 - bld.y1 + 1, marker))
total = total + 1
end
end
print("")
if total == 0 then
print("No civzones found on this map.")
else
print(("Total: %d civzone(s)"):format(total))
end