summaryrefslogtreecommitdiff
path: root/plugins/ruby/map.rb
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/ruby/map.rb')
-rw-r--r--plugins/ruby/map.rb32
1 files changed, 31 insertions, 1 deletions
diff --git a/plugins/ruby/map.rb b/plugins/ruby/map.rb
index c99d5b88..37161470 100644
--- a/plugins/ruby/map.rb
+++ b/plugins/ruby/map.rb
@@ -26,7 +26,7 @@ module DFHack
end
end
- def map_tile_at(x, y=nil, z=nil)
+ def map_tile_at(x=df.cursor, y=nil, z=nil)
x = x.pos if x.respond_to?(:pos)
x, y, z = x.x, x.y, x.z if x.respond_to?(:x)
b = map_block_at(x, y, z)
@@ -67,6 +67,14 @@ module DFHack
@mapblock = b
end
+ def offset(dx, dy=nil, dz=0)
+ if dx.respond_to?(:x)
+ dz = dx.z if dx.respond_to?(:z)
+ dx, dy = dx.x, dx.y
+ end
+ df.map_tile_at(@x+dx, @y+dy, @z+dz)
+ end
+
def designation
@mapblock.designation[@dx][@dy]
end
@@ -188,6 +196,28 @@ module DFHack
"#<MapTile pos=[#@x, #@y, #@z] shape=#{shape} tilemat=#{tilemat} material=#{mat_info.token}>"
end
+ def dig(mode=:Default)
+ if mode == :Smooth
+ if (tilemat == :STONE or tilemat == :MINERAL) and caption !~ /smooth|pillar|fortification/i and # XXX caption..
+ designation.smooth == 0 and (designation.hidden or not df.world.job_list.find { |j|
+ # the game removes 'smooth' designation as soon as it assigns a job, if we
+ # re-set it the game may queue another :DetailWall that will carve a fortification
+ (j.job_type == :DetailWall or j.job_type == :DetailFloor) and df.same_pos?(j, self)
+ })
+ designation.dig = :No
+ designation.smooth = 1
+ mapblock.flags.designated = true
+ end
+ else
+ return if mode != :No and designation.dig == :No and not designation.hidden and df.world.job_list.find { |j|
+ # someone already enroute to dig here, avoid 'Inappropriate dig square' spam
+ JobType::Type[j.job_type] == :Digging and df.same_pos?(j, self)
+ }
+ designation.dig = mode
+ mapblock.flags.designated = true if mode != :No
+ end
+ end
+
def spawn_liquid(quantity, is_magma=false, flowing=true)
designation.flow_size = quantity
designation.liquid_type = (is_magma ? :Magma : :Water)