Compare commits

...

2 Commits

Author SHA1 Message Date
acdbad46c6 Re-add Mesecons compatibility 2025-04-05 18:06:48 +02:00
8e4fdb217a Re-add Logistica compatibility 2025-04-05 16:18:37 +02:00
3 changed files with 34 additions and 16 deletions

View File

@ -48,14 +48,17 @@ for _,name in ipairs(logistica.group_get_all_nodes_for_group("injectors")) do
minetest.override_item(name,override)
end
local function startNodeTimer(pos)
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
local function afterLogisticaAction(pos)
local def=minetest.registered_nodes[minetest.get_node(pos).name]
if def and def._industrialtest_self then
def._industrialtest_self:triggerIfNeeded(pos)
end
end
local function addLogisticaCompatibility(name)
local override={
_logistica_afterRequesterItemstackInsert=startNodeTimer,
_logistica_afterInjectorItemstackTake=startNodeTimer
_logistica_afterRequesterItemstackInsert=afterLogisticaAction,
_logistica_afterInjectorItemstackTake=afterLogisticaAction
}
minetest.override_item(name,override)
end

View File

@ -27,16 +27,15 @@ local override={
meta:set_int("maintainSpeed",1)
local def=minetest.registered_nodes[node.name]
def._industrialtest_updateFormspec(pos)
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
def._industrialtest_self:updateFormspec(pos)
def._industrialtest_self:trigger(pos)
end,
action_off=function(pos,node)
local meta=minetest.get_meta(pos)
meta:set_int("maintainSpeed",0)
local def=minetest.registered_nodes[node.name]
def._industrialtest_updateFormspec(pos)
def._industrialtest_self:updateFormspec(pos)
end
}
}
@ -69,13 +68,13 @@ override={
meta:set_int("stateChanged",1)
local def=minetest.registered_nodes[node.name]
def._industrialtest_updateFormspec(pos)
def._industrialtest_self:updateFormspec(pos)
if isChamber then
def._industrialtest_synchronizeToChamber(originalPos)
def._industrialtest_self:synchronizeToChamber(originalPos)
end
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
def._industrialtest_self:triggerIfNeeded(pos)
end,
action_off=function(pos,node)
local isChamber=node.name=="industrialtest:nuclear_reactor_chamber"
@ -107,10 +106,10 @@ override={
meta:set_int("stateChanged",1)
local def=minetest.registered_nodes[node.name]
def._industrialtest_updateFormspec(pos)
def._industrialtest_self:updateFormspec(pos)
if isChamber then
def._industrialtest_synchronizeToChamber(originalPos)
def._industrialtest_self:synchronizeToChamber(originalPos)
end
end
}

View File

@ -167,6 +167,13 @@ function industrialtest.GeothermalGenerator.onConstruct(self,pos)
industrialtest.ActivatedElectricMachine.onConstruct(self,pos)
end
function industrialtest.GeothermalGenerator.update(self,pos,elapsed,meta,inv)
local srcSlot=inv:get_stack("src",1)
local dstSlot=inv:get_stack("dst",1)
local shouldUpdateFormspec=takeFuelFromItem(self,pos)
return (not srcSlot:is_empty() and dstSlot:get_free_space()>0 and not industrialtest.api.isFluidStorageFull(meta)),shouldUpdateFormspec
end
function industrialtest.GeothermalGenerator.allowMetadataInventoryMove(self,pos,fromList,fromIndex,toList,toIndex,count)
return math.min(allowMetadataInventoryMove(pos,fromList,fromIndex,toList,toIndex,count),industrialtest.ActivatedElectricMachine.allowMetadataInventoryMove(self,pos,fromList,fromIndex,toList,toIndex,count))
end
@ -191,16 +198,22 @@ end
function industrialtest.GeothermalGenerator.shouldActivate(self,pos)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
local srcSlot=inv:get_stack("src",1)
local dstSlot=inv:get_stack("dst",1)
local fluidAmount=meta:get_float("fluidAmount")
return fluidAmount>0 and not industrialtest.api.isFullyCharged(meta)
return (fluidAmount>0 or (not srcSlot:is_empty() and dstSlot:get_free_space()>0)) and not industrialtest.api.isFullyCharged(meta)
end
function industrialtest.GeothermalGenerator.shouldDeactivate(self,pos)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
local srcSlot=inv:get_stack("src",1)
local dstSlot=inv:get_stack("dst",1)
local fluidAmount=meta:get_float("fluidAmount")
return fluidAmount<=0 or industrialtest.api.isFullyCharged(meta)
return (fluidAmount<=0 and (srcSlot:is_empty() or dstSlot:get_free_space()==0)) or industrialtest.api.isFullyCharged(meta)
end
function industrialtest.GeothermalGenerator.activeUpdate(self,pos,elapsed)
@ -270,9 +283,12 @@ end
function industrialtest.WaterMill.canUpdate(self,pos)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
local srcSlot=inv:get_stack("src",1)
local dstSlot=inv:get_stack("dst",1)
local fluidAmount=meta:get_float("fluidAmount")
return fluidAmount>0 and not industrialtest.api.isFullyCharged(meta)
return (fluidAmount>0 or (not srcSlot:is_empty() and dstSlot:get_free_space()>0)) and not industrialtest.api.isFullyCharged(meta)
end
function industrialtest.WaterMill.update(self,pos,elapsed)