Pipeworks compatibility: Power storage

This commit is contained in:
mrkubax10 2024-02-29 20:52:34 +01:00
parent a8b625f782
commit 73232db9a0

View File

@ -271,3 +271,66 @@ override={
minetest.override_item("industrialtest:nuclear_reactor",override)
minetest.override_item("industrialtest:nuclear_reactor_active",override)
-- BatBox
def=table.copy(minetest.registered_nodes["industrialtest:batbox"])
def.groups.tubedevice=1
def.groups.tubedevice_receiver=1
override={
groups=def.groups,
tube={
insert_object=function(pos,node,stack,direction)
local listname=direction.y==1 and "discharged" or "charged"
if not industrialtest.api.hasPowerStorage(stack:get_meta()) then
return nil
end
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
local result=inv:add_item(listname,stack)
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
return result
end,
can_insert=function(pos,node,stack,direction)
local listname=direction.y==1 and "discharged" or "charged"
if not industrialtest.api.hasPowerStorage(stack:get_meta()) then
return false
end
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
return inv:room_for_item(listname,stack)
end,
input_inventory="charged",
connect_sides={
left=1,
right=1,
back=1,
bottom=1,
top=1
}
},
after_place_node=pipeworks.after_place,
after_dig_node=pipeworks.after_dig,
on_rotate=pipeworks.on_rotate
}
minetest.override_item("industrialtest:batbox",override)
-- CESU
override.groups=minetest.registered_nodes["industrialtest:cesu"].groups
override.groups.tubedevice=1
override.groups.tubedevice_receiver=1
minetest.override_item("industrialtest:cesu",override)
-- MFE
override.groups=minetest.registered_nodes["industrialtest:mfe"].groups
override.groups.tubedevice=1
override.groups.tubedevice_receiver=1
minetest.override_item("industrialtest:mfe",override)
-- MFSU
override.groups=minetest.registered_nodes["industrialtest:mfsu"].groups
override.groups.tubedevice=1
override.groups.tubedevice_receiver=1
minetest.override_item("industrialtest:mfsu",override)