summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorKelly Martin2012-07-16 20:52:15 -0500
committerKelly Martin2012-07-16 20:52:15 -0500
commitab4c4b63c0e5f8a8c984d32c175548c16707d415 (patch)
tree6ebe02788715b68564960342ab337a0f94dac047 /scripts
parent70ac2ffa17a8f233872797bce6cafa994ce21697 (diff)
parent9c0bc3144a9a7c6979b76c6edb012b80b14cbed7 (diff)
downloaddfhack-ab4c4b63c0e5f8a8c984d32c175548c16707d415.tar.gz
dfhack-ab4c4b63c0e5f8a8c984d32c175548c16707d415.tar.bz2
dfhack-ab4c4b63c0e5f8a8c984d32c175548c16707d415.tar.xz
Merge remote-tracking branch 'jjyg/master'
Diffstat (limited to 'scripts')
-rw-r--r--scripts/magmasource.rb66
1 files changed, 66 insertions, 0 deletions
diff --git a/scripts/magmasource.rb b/scripts/magmasource.rb
new file mode 100644
index 00000000..8525d51e
--- /dev/null
+++ b/scripts/magmasource.rb
@@ -0,0 +1,66 @@
+# create an infinite magma source at the cursor
+
+$magma_sources ||= []
+
+case $script_args[0]
+when 'here'
+ $magma_onupdate ||= df.onupdate_register(12) {
+ # called every 12 game ticks (100x a dwarf day)
+ if $magma_sources.empty?
+ df.onupdate_unregister($magma_onupdate)
+ $magma_onupdate = nil
+ end
+
+ $magma_sources.each { |x, y, z|
+ if tile = df.map_tile_at(x, y, z) and DFHack::TiletypeShape::PassableFlow[tile.shape]
+ 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
+ end
+ }
+ }
+
+ if df.cursor.x != -30000
+ if tile = df.map_tile_at(df.cursor)
+ if DFHack::TiletypeShape::PassableFlow[tile.shape]
+ $magma_sources << [df.cursor.x, df.cursor.y, df.cursor.z]
+ else
+ puts "Impassable tile: I'm afraid I can't do that, Dave"
+ end
+ else
+ puts "Unallocated map block - build something here first"
+ end
+ else
+ puts "Please put the game cursor where you want a magma source"
+ end
+
+when 'delete-here'
+ $magma_sources.delete [df.cursor.x, df.cursor.y, df.cursor.z]
+
+when 'stop'
+ $magma_sources.clear
+
+else
+ puts <<EOS
+Creates a new infinite magma source at the cursor.
+
+Arguments:
+ here - create a new source at the current cursor position
+ (call multiple times for higher flow)
+ delete-here - delete the source under the cursor
+ stop - delete all created magma sources
+EOS
+
+ if $magma_sources.first
+ puts '', 'Current magma sources:', $magma_sources.map { |s| " #{s.inspect}" }
+ end
+end