Rewriting the drainaquifer script
The original drainaquifer script could occasionally fail to notice aquifer layers if they happen to skip each of the special tiles that it checks, two per block. It also left the block-level aquifer flags set, which seems like a minor waste of FPS. The new script uses the block-level flags to determine which blocks to check, which seems to be both more correct and faster. It's also written in Lua instead of Ruby, for clarity and ease of debugging. The name has changed slightly to prevent problems if both scripts are installed for some reason.develop
parent
b0b6a82c92
commit
b0b1dd62d1
@ -0,0 +1,33 @@
|
||||
-- Remove all aquifers from the map
|
||||
|
||||
local function drain()
|
||||
local last_layer = nil
|
||||
local layer_count = 0
|
||||
local tile_count = 0
|
||||
|
||||
for k, block in ipairs(df.global.world.map.map_blocks) do
|
||||
if block.flags.has_aquifer then
|
||||
block.flags.has_aquifer = false
|
||||
block.flags.check_aquifer = false
|
||||
|
||||
for x, row in ipairs(block.designation) do
|
||||
for y, tile in ipairs(row) do
|
||||
if tile.water_table then
|
||||
tile.water_table = false
|
||||
tile_count = tile_count + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if block.map_pos.z ~= last_layer then
|
||||
last_layer = block.map_pos.z
|
||||
layer_count = layer_count + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
print("Cleared "..tile_count.." aquifer tile"..((tile_count ~= 1) and "s" or "")..
|
||||
" in "..layer_count.." layer"..((layer_count ~= 1) and "s" or "")..".")
|
||||
end
|
||||
|
||||
drain(...)
|
@ -1,13 +0,0 @@
|
||||
# remove all aquifers from the map
|
||||
|
||||
count = 0
|
||||
df.each_map_block { |b|
|
||||
if b.designation[0][0].water_table or b.designation[8][8].water_table
|
||||
count += 1
|
||||
df.each_map_block_z(b.map_pos.z) { |bz|
|
||||
bz.designation.each { |dx| dx.each { |dy| dy.water_table = false } }
|
||||
}
|
||||
end
|
||||
}
|
||||
|
||||
puts "cleared #{count} aquifer#{'s' if count > 1}"
|
Loading…
Reference in New Issue