2024-02-27 21:02:12 +01:00
|
|
|
-- 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/>.
|
|
|
|
|
|
|
|
-- Iron Furnace
|
|
|
|
local def=table.copy(minetest.registered_nodes["industrialtest:iron_furnace"])
|
|
|
|
|
|
|
|
def.groups.tubedevice=1
|
|
|
|
def.groups.tubedevice_receiver=1
|
|
|
|
|
|
|
|
local override={
|
|
|
|
groups=def.groups,
|
|
|
|
tube={
|
|
|
|
insert_object=function(pos,node,stack,direction)
|
|
|
|
local meta=minetest.get_meta(pos)
|
|
|
|
local inv=meta:get_inventory()
|
|
|
|
local result=inv:add_item(direction.y==1 and "fuel" or "src",stack)
|
|
|
|
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
|
|
|
return result
|
|
|
|
end,
|
|
|
|
can_insert=function(pos,node,stack,direction)
|
|
|
|
local meta=minetest.get_meta(pos)
|
|
|
|
local inv=meta:get_inventory()
|
|
|
|
return inv:room_for_item(direction.y==1 and "fuel" or "src",stack)
|
|
|
|
end,
|
|
|
|
input_inventory="dst",
|
|
|
|
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:iron_furnace",override)
|
|
|
|
minetest.override_item("industrialtest:iron_furnace_active",override)
|
2024-02-28 18:37:20 +01:00
|
|
|
|
|
|
|
-- Generator
|
|
|
|
def=table.copy(minetest.registered_nodes["industrialtest:generator"])
|
|
|
|
|
|
|
|
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 "fuel" or "charged"
|
|
|
|
if listname=="charged" and 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 "fuel" or "charged"
|
|
|
|
if listname=="charged" and 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,
|
|
|
|
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:generator",override)
|
|
|
|
minetest.override_item("industrialtest:generator_active",override)
|