Implement Logistica compatibility
This commit is contained in:
parent
3419fcb660
commit
19c97f0173
66
compat/logistica.lua
Normal file
66
compat/logistica.lua
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
-- IndustrialTest
|
||||||
|
-- Copyright (C) 2024 mrkubax10
|
||||||
|
|
||||||
|
-- This program is free software: you can redistribute it and/or modify
|
||||||
|
-- it under the terms of the GNU General Public License as published by
|
||||||
|
-- the Free Software Foundation, either version 3 of the License, or
|
||||||
|
-- (at your option) any later version.
|
||||||
|
|
||||||
|
-- This program is distributed in the hope that it will be useful,
|
||||||
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
-- GNU General Public License for more details.
|
||||||
|
|
||||||
|
-- You should have received a copy of the GNU General Public License
|
||||||
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
local oldInsertItemstackForRequester=logistica.insert_itemstack_for_requester
|
||||||
|
|
||||||
|
-- Logistica overrides
|
||||||
|
function logistica.insert_itemstack_for_requester(requesterPos,itemstack,limitByRequest)
|
||||||
|
local result=oldInsertItemstackForRequester(requesterPos, itemstack, limitByRequest)
|
||||||
|
|
||||||
|
local targetPos=logistica.get_requester_target(requesterPos)
|
||||||
|
local def=minetest.registered_nodes[minetest.get_node(targetPos).name]
|
||||||
|
if def._logistica_afterRequesterItemstackInsert then
|
||||||
|
def._logistica_afterRequesterItemstackInsert(targetPos)
|
||||||
|
end
|
||||||
|
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
local onInjectorTimer=logistica.on_timer_powered(function(pos,elapsed)
|
||||||
|
local result=logistica.on_injector_timer(pos,elapsed)
|
||||||
|
minetest.debug("here")
|
||||||
|
|
||||||
|
local targetPos=logistica.get_injector_target(pos)
|
||||||
|
local def=minetest.registered_nodes[minetest.get_node(targetPos).name]
|
||||||
|
if def._logistica_afterInjectorItemstackTake then
|
||||||
|
def._logistica_afterInjectorItemstackTake(targetPos)
|
||||||
|
end
|
||||||
|
|
||||||
|
return result
|
||||||
|
end)
|
||||||
|
|
||||||
|
for _,name in ipairs(logistica.group_get_all_nodes_for_group("injectors")) do
|
||||||
|
local override={
|
||||||
|
on_timer=onInjectorTimer
|
||||||
|
}
|
||||||
|
minetest.override_item(name,override)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function startNodeTimer(pos)
|
||||||
|
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function addLogisticaCompatibility(name)
|
||||||
|
local override={
|
||||||
|
_logistica_afterRequesterItemstackInsert=startNodeTimer,
|
||||||
|
_logistica_afterInjectorItemstackTake=startNodeTimer
|
||||||
|
}
|
||||||
|
minetest.override_item(name,override)
|
||||||
|
end
|
||||||
|
|
||||||
|
for _,name in ipairs(industrialtest.api.tags.usesTimer) do
|
||||||
|
addLogisticaCompatibility(name)
|
||||||
|
end
|
@ -40,6 +40,7 @@ elseif industrialtest.mclAvailable then
|
|||||||
industrialtest.mods.mclRubber=minetest.get_modpath("mcl_rubber")
|
industrialtest.mods.mclRubber=minetest.get_modpath("mcl_rubber")
|
||||||
end
|
end
|
||||||
industrialtest.mods.pipeworks=minetest.get_modpath("pipeworks")
|
industrialtest.mods.pipeworks=minetest.get_modpath("pipeworks")
|
||||||
|
industrialtest.mods.logistica=minetest.get_modpath("logistica")
|
||||||
industrialtest.mods.mesecons=minetest.get_modpath("mesecons")
|
industrialtest.mods.mesecons=minetest.get_modpath("mesecons")
|
||||||
|
|
||||||
if industrialtest.mtgAvailable and not industrialtest.mods._3dArmor then
|
if industrialtest.mtgAvailable and not industrialtest.mods._3dArmor then
|
||||||
|
3
init.lua
3
init.lua
@ -90,6 +90,9 @@ dofile(modpath.."/crafts.lua")
|
|||||||
if industrialtest.mods.pipeworks then
|
if industrialtest.mods.pipeworks then
|
||||||
dofile(modpath.."/compat/pipeworks.lua")
|
dofile(modpath.."/compat/pipeworks.lua")
|
||||||
end
|
end
|
||||||
|
if industrialtest.mods.logistica then
|
||||||
|
dofile(modpath.."/compat/logistica.lua")
|
||||||
|
end
|
||||||
if industrialtest.mods.mesecons then
|
if industrialtest.mods.mesecons then
|
||||||
dofile(modpath.."/compat/mesecons.lua")
|
dofile(modpath.."/compat/mesecons.lua")
|
||||||
end
|
end
|
||||||
|
@ -439,6 +439,7 @@ function industrialtest.internal.registerMachine(config)
|
|||||||
end
|
end
|
||||||
minetest.register_node("industrialtest:"..config.name.."_active",definition)
|
minetest.register_node("industrialtest:"..config.name.."_active",definition)
|
||||||
end
|
end
|
||||||
|
industrialtest.api.addTag("industrialtest:"..config.name,"usesTimer")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function craftResultProxy(method,item)
|
local function craftResultProxy(method,item)
|
||||||
|
2
mod.conf
2
mod.conf
@ -1,5 +1,5 @@
|
|||||||
name=industrialtest
|
name=industrialtest
|
||||||
description=Adds various machinery
|
description=Adds various machinery
|
||||||
optional_depends=default,bucket,3d_armor,mcl_core,mcl_copper,mcl_armor,mcl_deepslate,mcl_nether,mcl_buckets,mcl_util,mcl_dye,mcl_rubber,pipeworks,mesecons
|
optional_depends=default,bucket,3d_armor,mcl_core,mcl_copper,mcl_armor,mcl_deepslate,mcl_nether,mcl_buckets,mcl_util,mcl_dye,mcl_rubber,pipeworks,logistica,mesecons
|
||||||
author=IndustrialTest Team
|
author=IndustrialTest Team
|
||||||
title=IndustrialTest
|
title=IndustrialTest
|
||||||
|
Loading…
Reference in New Issue
Block a user