From 2bcd02ce96d70fa51ffbb500b40bd77daaf02716 Mon Sep 17 00:00:00 2001 From: jj Date: Fri, 11 Oct 2013 19:15:56 +0200 Subject: [PATCH 1/2] add digmat script --- NEWS | 1 + Readme.rst | 10 +++++++++ scripts/digmat.rb | 54 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 scripts/digmat.rb diff --git a/NEWS b/NEWS index b41444586..43d865cd6 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,7 @@ DFHack future - multicmd: run a sequence of dfhack commands, separated by ';' - autobutcher: A GUI front-end for the autobutcher plugin. - startdwarf: change the number of dwarves for a new embark + - digmat: dig veins/layers tile by tile, as discovered Misc improvements: - exterminate: renamed from slayrace, add help message, add butcher mode - autoSyndrome: disable by default diff --git a/Readme.rst b/Readme.rst index d6ffcde23..9f1ce8c84 100644 --- a/Readme.rst +++ b/Readme.rst @@ -1996,6 +1996,16 @@ To skip a row in your design, use a single ``;``. The script takes the plan filename, starting from the root df folder. +digmat +====== +Designates a tile for digging. Monitors the tile, and when it is dug out, add +surrounding discovered tiles of the same material for digging. Similar to 'digv', +but less cheaty. Works for stone layers, soil layers, veins, etc. + +If the tile you call the script on already has a digging designation, reuse the +same designation for future digging (eg dig up/downstairs). When digging stairs, +also designate tiles on z-1 and z+1 when they are discovered. + superdwarf ========== Similar to fastdwarf, per-creature. diff --git a/scripts/digmat.rb b/scripts/digmat.rb new file mode 100644 index 000000000..22f1df81e --- /dev/null +++ b/scripts/digmat.rb @@ -0,0 +1,54 @@ +# dig a mineral vein/layer, add tiles as they are discovered + +# reuses the dig mode (upstairs etc) of the selected tile + +if df.cursor.x < 0 + puts "Place the game cursor on a tile to dig" + throw :script_finished +end + +tile = df.map_tile_at(df.cursor) +if tile.shape_basic != :Wall or tile.designation.hidden + puts "Place the game cursor on an unmined, discovered tile" + throw :script_finished +end + +def digmat_watch(tile, digmode, tilelist) + # watch the tile, expand mining operations when dug out + tilelist << [tile.x, tile.y, tile.z] + if tilelist.length == 1 + df.onupdate_register_once("digmat", 10) { + tilelist.dup.each { |x, y, z| + t = df.map_tile_at(x, y, z) + if t.shape_basic != :Wall + digmat_around(t, digmode, tilelist) + tilelist.delete [x, y, z] + end + } + tilelist.empty? + } + end + tilelist.uniq! +end + +def digmat_around(tile, digmode=tile.designation.dig, tilelist=[]) + digmode = :Default if digmode == :No + [-1, 0, 1].each { |dz| + next if digmode == :Default and dz != 0 + [-1, 0, 1].each { |dy| + [-1, 0, 1].each { |dx| + ntile = tile.offset(dx, dy, dz) + next if not ntile + next if ntile.designation.hidden + next if ntile.designation.dig != :No + next if ntile.shape_basic != :Wall + next if not ntile.mat_info === tile.mat_info + + ntile.dig(digmode) + digmat_watch(ntile, digmode, tilelist) + } + } + } +end + +digmat_around(tile) From a1d54e2074972cadca753bde9a77a7c34e3662e4 Mon Sep 17 00:00:00 2001 From: jj Date: Mon, 14 Oct 2013 00:39:32 +0200 Subject: [PATCH 2/2] digmat: ignore map borders and damp/warm stone --- scripts/digmat.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/digmat.rb b/scripts/digmat.rb index 22f1df81e..683c1d8f1 100644 --- a/scripts/digmat.rb +++ b/scripts/digmat.rb @@ -35,8 +35,11 @@ def digmat_around(tile, digmode=tile.designation.dig, tilelist=[]) digmode = :Default if digmode == :No [-1, 0, 1].each { |dz| next if digmode == :Default and dz != 0 + next if tile.z+dz < 1 or tile.z+dz > df.world.map.z_count-2 [-1, 0, 1].each { |dy| + next if tile.y+dy < 1 or tile.y+dy > df.world.map.y_count-2 [-1, 0, 1].each { |dx| + next if tile.x+dx < 1 or tile.x+dx > df.world.map.x_count-2 ntile = tile.offset(dx, dy, dz) next if not ntile next if ntile.designation.hidden @@ -44,6 +47,11 @@ def digmat_around(tile, digmode=tile.designation.dig, tilelist=[]) next if ntile.shape_basic != :Wall next if not ntile.mat_info === tile.mat_info + # ignore damp/warm stone walls + next if [-1, 0, 1].find { |ddy| [-1, 0, 1].find { |ddx| + t = ntile.offset(ddx, ddy) and t.designation.flow_size > 1 + } } + ntile.dig(digmode) digmat_watch(ntile, digmode, tilelist) }