Hi, I was trying to improve the "Flooder V2" script, but some things were not working as I wanted to.
The problem with this script is that it doesn't change the incompatable water, and the section where it creates the water.
Script:
function flood(height) -- Maybe make it "function flood(height, pressure)" so we don't need to ask it later
if (height == nil) then
height = tpt.input("Water Level", "Enter the selected height for the water to continue")
end
-- If height is integer, it will continue.
if tonumber(height) ~= nil then
answer = tpt.input("Pressure", "Do you want to reset the pressure? (May have impact) Yes/No")
if (answer == "yes") then
sim.resetPressure()
end
tpt.message_box("Flood!", "There is a flood coming with height of "..height.." pixels") -- This message is not needed
-- Create a box so the water can't escape
sim.createLine(4, 378, 607, 378, 0, 0, elem.DEFAULT_PT_DMND)
sim.createLine(4, 379, 607, 379, 0, 0, elem.DEFAULT_PT_DMND)
sim.createLine(4, 379, 4, 4, 0, 0, elem.DEFAULT_PT_DMND)
sim.createLine(5, 379, 5, 4, 0, 0, elem.DEFAULT_PT_DMND)
sim.createLine(606, 379, 606, 4, 0, 0, elem.DEFAULT_PT_DMND)
sim.createLine(607, 379, 607, 4, 0, 0, elem.DEFAULT_PT_DMND)
--Replace incompatable water
sim.partChangeType(elem.DEFAULT_PT_WATR, elem.DEFAULT_PT_DSTW)
sim.partChangeType(elem.DEFAULT_PT_SLTW, elem.DEFAULT_PT_DSTW)
sim.partChangeType(elem.DEFAULT_PT_BUBW, elem.DEFAULT_PT_DSTW)
--Flood with water
tpt.log("Creating water")
local int h = 377;
repeat
sim.createLine(6, h, 605, h, 0, 0, elements.DEFAULT_PT_DSTW)
h = h - 1;
until (h == height) or (h >= 0)
tpt.log("Done")
tpt.set_pause(1)
else
tpt.throw_error("You must enter a valid number")
end;
end