Add TA2 clutch

This commit is contained in:
Joachim Stolberg 2023-08-26 19:37:03 +02:00
parent c7ac277d40
commit ae8d2d3d09
2 changed files with 12 additions and 9 deletions

View File

@ -32,7 +32,7 @@ end
local function start_node(pos, nvm, state)
local outdir = M(pos):get_int("outdir")
switch_axles(pos, true)
--switch_axles(pos, true)
nvm.load = 0
power.start_storage_calc(pos, Axle, outdir)
outdir = networks.Flip[outdir]
@ -41,7 +41,7 @@ end
local function stop_node(pos, nvm, state)
local outdir = M(pos):get_int("outdir")
switch_axles(pos, false)
--switch_axles(pos, false)
power.start_storage_calc(pos, Axle, outdir)
outdir = networks.Flip[outdir]
power.start_storage_calc(pos, Axle, outdir)
@ -58,6 +58,7 @@ local State = techage.NodeStates:new({
})
local function node_timer(pos, elapsed)
local t = minetest.get_us_time()
local nvm = techage.get_nvm(pos)
local outdir2 = M(pos):get_int("outdir")
local outdir1 = networks.Flip[outdir2]
@ -66,7 +67,10 @@ local function node_timer(pos, elapsed)
if not power_flow then
power.start_storage_calc(pos, Axle, outdir1)
power.start_storage_calc(pos, Axle, outdir2)
switch_axles(pos, data.curr_load1 ~= 0)
end
t = minetest.get_us_time() - t
print("node_timer", t, power_flow, dump(data))
return true
end

View File

@ -42,7 +42,7 @@ local function chest_load(nvm, pos)
nvm.stored_items[i] = {name = stack:get_name(), count = stack:get_count()}
amount = amount + stack:get_count()
end
return amount
return amount * 3
end
local function chest_full(pos)
@ -140,20 +140,19 @@ minetest.register_node("techage:ta2_winch", {
remove_chest(pos)
nvm.running = true
power.start_storage_calc(pos, Axle, outdir)
elseif not nvm.running then
techage.renew_rope(pos, 50)
elseif nvm.running and nvm.load == 0 and not power.power_available(pos, Axle, outdir) then
elseif nvm.running and nvm.load < 2 and not power.power_available(pos, Axle, outdir) then
add_chest(pos)
nvm.running = false
power.start_storage_calc(pos, Axle, outdir)
end
if nvm.running then
local val = power.get_storage_load(pos, Axle, outdir, nvm.capa) or 0
if val > 0 then
nvm.load = val
nvm.load = power.get_storage_load(pos, Axle, outdir, nvm.capa) or 0
if nvm.load > 2 then
add_chest_entity(pos, nvm)
end
else
techage.renew_rope(pos, 50)
end
return true
end,