Merge remote-tracking branch 'jjyg/digmat' into 0.34.11-r4

Conflicts:
	Readme.rst
develop
expwnent 2013-10-24 19:39:40 -04:00
commit 237251ce0c
3 changed files with 72 additions and 0 deletions

@ -18,6 +18,7 @@ DFHack v0.34.11-r4
- masspit: designate caged creatures in a zone for pitting
- multicmd: run a sequence of dfhack commands, separated by ';'
- startdwarf: change the number of dwarves for a new embark
- digmat: dig veins/layers tile by tile, as discovered
Misc improvements:
- autoSyndrome:
disable by default

@ -2185,6 +2185,15 @@ Triggers an invasion, or several in the near future.
`invasion-now civName start end` trigger an invasion from civName in about 10*start ticks, and continue triggering invasions every ten ticks afterward until about 10*end ticks have passed
Probably fails if the start time of a triggered invasion is later than the start of the next year.
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
==========

@ -0,0 +1,62 @@
# 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
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
next if ntile.designation.dig != :No
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)
}
}
}
end
digmat_around(tile)