1
0
mirror of https://github.com/mt-mods/pipeworks.git synced 2024-11-15 23:10:33 +01:00
pipeworks/compat-furnaces.lua
2022-04-01 20:20:48 -04:00

115 lines
3.1 KiB
Lua

-- this file is basically a modified copy of
-- minetest_game/mods/default/furnaces.lua
local def = table.copy(minetest.registered_nodes["default:furnace"])
--local def_active = table.copy(minetest.registered_nodes["default:furnace_active"])
local tube_entry = "^pipeworks_tube_connection_stony.png"
local groups = def.groups
groups["tubedevice"] = 1
groups["tubedevice_receiver"] = 1
local groups_active = table.copy(groups)
groups_active["not_in_creative_inventory"] = 1
--
-- Node definitions
--
minetest.override_item("default:furnace", {
tiles = {
"default_furnace_top.png"..tube_entry,
"default_furnace_bottom.png"..tube_entry,
"default_furnace_side.png"..tube_entry,
"default_furnace_side.png"..tube_entry,
"default_furnace_side.png"..tube_entry,
"default_furnace_front.png"
},
groups = groups,
tube = {
insert_object = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local timer = minetest.get_node_timer(pos)
if not timer:is_started() then
timer:start(1.0)
end
if direction.y == 1 then
return inv:add_item("fuel", stack)
else
return inv:add_item("src", stack)
end
end,
can_insert = function(pos,node,stack,direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if direction.y == 1 then
return inv:room_for_item("fuel", stack)
else
if meta:get_int("split_material_stacks") == 1 then
stack = stack:peek_item(1)
end
return inv:room_for_item("src", stack)
end
end,
input_inventory = "dst",
connect_sides = {left = 1, right = 1, back = 1, front = 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("default:furnace_active", {
tiles = {
"default_furnace_top.png"..tube_entry,
"default_furnace_bottom.png"..tube_entry,
"default_furnace_side.png"..tube_entry,
"default_furnace_side.png"..tube_entry,
"default_furnace_side.png"..tube_entry,
{
image = "default_furnace_front_active.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 1.5
},
}
},
groups = groups_active,
tube = {
insert_object = function(pos,node,stack,direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local timer = minetest.get_node_timer(pos)
if not timer:is_started() then
timer:start(1.0)
end
if direction.y == 1 then
return inv:add_item("fuel", stack)
else
return inv:add_item("src", stack)
end
end,
can_insert = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if direction.y == 1 then
return inv:room_for_item("fuel", stack)
else
return inv:room_for_item("src", stack)
end
end,
input_inventory = "dst",
connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
},
after_place_node = pipeworks.after_place,
after_dig_node = pipeworks.after_dig,
on_rotate = pipeworks.on_rotate
})