Add reverse mode for ta5 pump
This commit is contained in:
parent
6b07399bf3
commit
8ab2835141
@ -31,6 +31,14 @@ local WRENCH_MENU = {{
|
|||||||
name = "flowrate",
|
name = "flowrate",
|
||||||
label = S("Total flow rate"),
|
label = S("Total flow rate"),
|
||||||
tooltip = S("Total flow rate in liquid units"),
|
tooltip = S("Total flow rate in liquid units"),
|
||||||
|
},{
|
||||||
|
type = "dropdown",
|
||||||
|
choices = "normal,reverse",
|
||||||
|
name = "operation",
|
||||||
|
label = S("Operation"),
|
||||||
|
tooltip = S("Pump direction"),
|
||||||
|
values = {0, 1},
|
||||||
|
default = "1",
|
||||||
}}
|
}}
|
||||||
|
|
||||||
local State = techage.NodeStates:new({
|
local State = techage.NodeStates:new({
|
||||||
@ -43,20 +51,39 @@ local State = techage.NodeStates:new({
|
|||||||
|
|
||||||
local function pumping(pos, nvm)
|
local function pumping(pos, nvm)
|
||||||
local outdir = M(pos):get_int("outdir")
|
local outdir = M(pos):get_int("outdir")
|
||||||
local taken, name = liquid.take(pos, Pipe2, Flip[outdir], nil, CAPA)
|
local reverse = M(pos):get_int("operation")
|
||||||
if taken > 0 then
|
if reverse == 1 then
|
||||||
local leftover = liquid.put(pos, Pipe3, outdir, name, taken)
|
local taken, name = liquid.take(pos, Pipe3, outdir, nil, CAPA)
|
||||||
if leftover and leftover > 0 then
|
if taken > 0 then
|
||||||
liquid.untake(pos, Pipe2, Flip[outdir], name, leftover)
|
local leftover = liquid.put(pos, Pipe2, Flip[outdir], name, taken)
|
||||||
if leftover == taken then
|
if leftover and leftover > 0 then
|
||||||
State:blocked(pos, nvm)
|
liquid.untake(pos, Pipe3, outdir, name, leftover)
|
||||||
return 0
|
if leftover == taken then
|
||||||
|
State:blocked(pos, nvm)
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
State:keep_running(pos, nvm, COUNTDOWN_TICKS)
|
||||||
|
return taken - leftover
|
||||||
end
|
end
|
||||||
State:keep_running(pos, nvm, COUNTDOWN_TICKS)
|
State:keep_running(pos, nvm, COUNTDOWN_TICKS)
|
||||||
return taken - leftover
|
return taken
|
||||||
|
end
|
||||||
|
else
|
||||||
|
local taken, name = liquid.take(pos, Pipe2, Flip[outdir], nil, CAPA)
|
||||||
|
if taken > 0 then
|
||||||
|
local leftover = liquid.put(pos, Pipe3, outdir, name, taken)
|
||||||
|
if leftover and leftover > 0 then
|
||||||
|
liquid.untake(pos, Pipe2, Flip[outdir], name, leftover)
|
||||||
|
if leftover == taken then
|
||||||
|
State:blocked(pos, nvm)
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
State:keep_running(pos, nvm, COUNTDOWN_TICKS)
|
||||||
|
return taken - leftover
|
||||||
|
end
|
||||||
|
State:keep_running(pos, nvm, COUNTDOWN_TICKS)
|
||||||
|
return taken
|
||||||
end
|
end
|
||||||
State:keep_running(pos, nvm, COUNTDOWN_TICKS)
|
|
||||||
return taken
|
|
||||||
end
|
end
|
||||||
State:idle(pos, nvm)
|
State:idle(pos, nvm)
|
||||||
return 0
|
return 0
|
||||||
|
Loading…
Reference in New Issue
Block a user