Fix ta4_doser bug

This commit is contained in:
Joachim Stolberg 2021-08-01 10:33:25 +02:00
parent 4dbf460715
commit 70b909ef5b
2 changed files with 35 additions and 8 deletions

View File

@ -177,9 +177,35 @@ local function dosing(pos, nvm, elapsed)
end end
end end
end end
-- check leftover
local leftover
local mem = techage.get_mem(pos)
if mem.waste_leftover then
leftover = reactor_cmnd(pos, "waste", {
name = mem.waste_leftover.name,
amount = mem.waste_leftover.num}) or mem.waste_leftover.num
if leftover > 0 then
mem.waste_leftover.num = leftover
State:blocked(pos, nvm)
return
end
mem.waste_leftover = nil
end
if mem.output_leftover then
leftover = reactor_cmnd(pos, "output", {
name = mem.output_leftover.name,
amount = mem.output_leftover.num}) or mem.output_leftover.num
if leftover > 0 then
mem.output_leftover.num = leftover
State:blocked(pos, nvm)
return
end
mem.output_leftover = nil
end
-- inputs -- inputs
local taken = {} local taken = {}
local mem = techage.get_mem(pos)
mem.dbg_cycles = (mem.dbg_cycles or 0) - 1 mem.dbg_cycles = (mem.dbg_cycles or 0) - 1
for _,item in pairs(recipe.input) do for _,item in pairs(recipe.input) do
@ -203,13 +229,13 @@ local function dosing(pos, nvm, elapsed)
end end
end end
-- waste -- waste
local leftover
if recipe.waste.name ~= "" then if recipe.waste.name ~= "" then
leftover = reactor_cmnd(pos, "waste", { leftover = reactor_cmnd(pos, "waste", {
name = recipe.waste.name, name = recipe.waste.name,
amount = recipe.waste.num}) amount = recipe.waste.num}) or recipe.waste.num
if not leftover or (tonumber(leftover) or 1) > 0 then if leftover > 0 then
untake(pos, taken) mem.waste_leftover = {name = recipe.waste.name, num = leftover}
mem.output_leftover = {name = recipe.output.name, num = recipe.output.num}
State:blocked(pos, nvm) State:blocked(pos, nvm)
reactor_cmnd(pos, "stop") reactor_cmnd(pos, "stop")
return return
@ -218,9 +244,9 @@ local function dosing(pos, nvm, elapsed)
-- output -- output
leftover = reactor_cmnd(pos, "output", { leftover = reactor_cmnd(pos, "output", {
name = recipe.output.name, name = recipe.output.name,
amount = recipe.output.num}) amount = recipe.output.num}) or recipe.output.num
if not leftover or (tonumber(leftover) or 1) > 0 then if leftover > 0 then
untake(pos, taken) mem.output_leftover = {name = recipe.output.name, num = leftover}
State:blocked(pos, nvm) State:blocked(pos, nvm)
reactor_cmnd(pos, "stop") reactor_cmnd(pos, "stop")
return return

View File

@ -124,6 +124,7 @@ minetest.register_node("techage:filler", {
on_rotate = screwdriver.disallow, -- important! on_rotate = screwdriver.disallow, -- important!
paramtype = "light", paramtype = "light",
sunlight_propagates = true, sunlight_propagates = true,
use_texture_alpha = techage.CLIP,
is_ground_content = false, is_ground_content = false,
groups = {cracky=2, crumbly=2, choppy=2}, groups = {cracky=2, crumbly=2, choppy=2},
sounds = default.node_sound_defaults(), sounds = default.node_sound_defaults(),