add scripts/magmasource to generate an infinite magma source

develop
jj 2012-07-12 14:35:49 +02:00
parent 0615a27663
commit c823f12737
1 changed files with 65 additions and 0 deletions

@ -0,0 +1,65 @@
# create an infinite magma source at the cursor
$magma_sources ||= []
$magma_onupdate ||= nil
case $script_args[0]
when 'here'
$magma_onupdate ||= df.onupdate_register(12) {
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