forked from mrkubax10/industrialtest
Trigger network master if endpoint is not fully charged
This commit is contained in:
parent
8724b563c4
commit
bd51f1d18f
7
api.lua
7
api.lua
@ -473,10 +473,11 @@ industrialtest.api.getConnections=function(pos,direction)
|
||||
for key,conn in ipairs(neighbourPositions) do
|
||||
local meta=minetest.get_meta(conn)
|
||||
local def=minetest.registered_nodes[minetest.get_node(conn).name]
|
||||
local powerOutput=(sourceDef.groups._industrialtest_cable or industrialtest.api.isPowerOutput(sourceMeta,key))
|
||||
local powerInput=(sourceDef.groups._industrialtest_cable or industrialtest.api.isPowerInput(sourceMeta,key))
|
||||
local normalizedKey=industrialtest.api.normalizeSide(pos,key)
|
||||
local powerOutput=(sourceDef.groups._industrialtest_cable or industrialtest.api.isPowerOutput(sourceMeta,normalizedKey))
|
||||
local powerInput=(sourceDef.groups._industrialtest_cable or industrialtest.api.isPowerInput(sourceMeta,normalizedKey))
|
||||
if def.groups._industrialtest_cable or industrialtest.api.hasPowerStorage(meta) then
|
||||
local side=industrialtest.api.getOppositeSide(key)
|
||||
local side=industrialtest.api.getOppositeSide(normalizedKey)
|
||||
if (powerOutput and directionInput and (def.groups._industrialtest_cable or industrialtest.api.isPowerInput(meta,side))) or ((def.groups._industrialtest_cable or industrialtest.api.isPowerOutput(meta,side)) and powerInput and directionOutput) then
|
||||
table.insert(result,conn)
|
||||
end
|
||||
|
@ -134,6 +134,16 @@ machine.onTimer=function(pos,elapsed,config)
|
||||
shouldRerunTimer,shouldUpdateFormspec=config.onTimer(pos,elapsed,meta,inv)
|
||||
end
|
||||
|
||||
local def=minetest.registered_nodes[minetest.get_node(pos).name]
|
||||
if def.groups and def.groups._industrialtest_hasPowerInput and not industrialtest.api.isFullyCharged(meta) then
|
||||
local networks=industrialtest.api.isAttachedToNetwork(meta)
|
||||
if networks then
|
||||
for _,network in ipairs(networks) do
|
||||
minetest.get_node_timer(network):start(industrialtest.updateDelay)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if shouldUpdateFormspec then
|
||||
machine.updateFormspec(pos,config)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user