diff --git a/plugins/ruby/map.rb b/plugins/ruby/map.rb index a0438670d..c99d5b88d 100644 --- a/plugins/ruby/map.rb +++ b/plugins/ruby/map.rb @@ -107,6 +107,31 @@ module DFHack Tiletype::Direction[tiletype] end + def shape_caption + TiletypeShape::Caption[shape] + end + + def shape_basic + TiletypeShape::BasicShape[shape] + end + + def shape_passablelow + TiletypeShape::PassableLow[shape] + end + + def shape_passablehigh + TiletypeShape::PassableHigh[shape] + end + + def shape_passableflow + TiletypeShape::PassableFlow[shape] + end + + def shape_walkable + TiletypeShape::Walkable[shape] + end + + # return all veins for current mapblock def all_veins mapblock.block_events.grep(BlockSquareEventMineralst) @@ -162,5 +187,28 @@ module DFHack def inspect "#" end + + def spawn_liquid(quantity, is_magma=false, flowing=true) + designation.flow_size = quantity + designation.liquid_type = (is_magma ? :Magma : :Water) + designation.flow_forbid = true if is_magma or quantity >= 4 + + if flowing + mapblock.flags.update_liquid = true + mapblock.flags.update_liquid_twice = true + + zf = df.world.map.z_level_flags[z] + zf.update = true + zf.update_twice = true + end + end + + def spawn_water(quantity=7) + spawn_liquid(quantity) + end + + def spawn_magma(quantity=7) + spawn_liquid(quantity, true) + end end end diff --git a/scripts/magmasource.rb b/scripts/magmasource.rb index 8525d51e0..e97080834 100644 --- a/scripts/magmasource.rb +++ b/scripts/magmasource.rb @@ -12,26 +12,16 @@ when 'here' end $magma_sources.each { |x, y, z| - if tile = df.map_tile_at(x, y, z) and DFHack::TiletypeShape::PassableFlow[tile.shape] + if tile = df.map_tile_at(x, y, z) and tile.shape_passableflow des = tile.designation - des.flow_size += 1 if des.flow_size < 7 - des.liquid_type = 1 - des.flow_forbid = true - - mf = tile.mapblock.flags - mf.update_liquid = true - mf.update_liquid_twice = true - - zf = df.world.map.z_level_flags[z] - zf.update = true - zf.update_twice = true + tile.spawn_magma(des.flow_size + 1) if des.flow_size < 7 end } } if df.cursor.x != -30000 if tile = df.map_tile_at(df.cursor) - if DFHack::TiletypeShape::PassableFlow[tile.shape] + if tile.shape_passableflow $magma_sources << [df.cursor.x, df.cursor.y, df.cursor.z] else puts "Impassable tile: I'm afraid I can't do that, Dave"