summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlexander Gavrilov2012-09-06 22:45:19 +0400
committerAlexander Gavrilov2012-09-06 22:45:19 +0400
commitc971a819def1c5cc29dc926f62456c336a1dfa17 (patch)
treea03b4fd14884603b15a5e96609408603c6566b12 /scripts
parentd0e630d4c35717bad682894e33e7dd57f86ac126 (diff)
downloaddfhack-c971a819def1c5cc29dc926f62456c336a1dfa17.tar.gz
dfhack-c971a819def1c5cc29dc926f62456c336a1dfa17.tar.bz2
dfhack-c971a819def1c5cc29dc926f62456c336a1dfa17.tar.xz
Experimental creation of map blocks in gui/liquids script.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/gui/liquids.lua41
1 files changed, 40 insertions, 1 deletions
diff --git a/scripts/gui/liquids.lua b/scripts/gui/liquids.lua
index 869cac90..89f08b7c 100644
--- a/scripts/gui/liquids.lua
+++ b/scripts/gui/liquids.lua
@@ -3,6 +3,7 @@
local utils = require 'utils'
local gui = require 'gui'
local guidm = require 'gui.dwarfmode'
+local dlg = require 'gui.dialogs'
local liquids = require('plugins.liquids')
@@ -199,6 +200,42 @@ function LiquidsUI:onRenderBody(dc)
dc:string("Enter", COLOR_LIGHTGREEN):string(": Paint")
end
+function ensure_blocks(cursor, size, cb)
+ local cx,cy,cz = pos2xyz(cursor)
+ local all = true
+ for x=1,size.x or 1,16 do
+ for y=1,size.y or 1,16 do
+ for z=1,size.z do
+ if not dfhack.maps.getTileBlock(cx+x-1, cy+y-1, cz+z-1) then
+ all = false
+ end
+ end
+ end
+ end
+ if all then
+ cb()
+ return
+ end
+ dlg.showYesNoPrompt(
+ 'Instantiate Blocks',
+ 'Not all map blocks are allocated - instantiate?\n\nWarning: new untested feature.',
+ COLOR_YELLOW,
+ function()
+ for x=1,size.x or 1,16 do
+ for y=1,size.y or 1,16 do
+ for z=1,size.z do
+ dfhack.maps.ensureTileBlock(cx+x-1, cy+y-1, cz+z-1)
+ end
+ end
+ end
+ cb()
+ end,
+ function()
+ cb()
+ end
+ )
+end
+
function LiquidsUI:onInput(keys)
local paint = self.paint:get()
local liquid = paint.liquid
@@ -239,13 +276,15 @@ function LiquidsUI:onInput(keys)
else
guidm.clearSelection()
end
- liquids.paint(
+ local cb = curry(
+ liquids.paint,
cursor,
self.brush:get().tag, self.paint:get().tag,
self.amount, size,
self.set:get().tag, self.flow:get().tag,
self.permaflow:get().tag
)
+ ensure_blocks(cursor, size, cb)
elseif self:propagateMoveKeys(keys) then
return
elseif keys.D_LOOK_ARENA_WATER then