forked from mt-mods/pipeworks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compat-furnaces.lua
128 lines (118 loc) · 3.61 KB
/
compat-furnaces.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
-- this file is basically a modified copy of
-- minetest_game/mods/default/furnaces.lua
local def--, def_active
if minetest.get_modpath("default") then
def = table.copy(minetest.registered_nodes["default:furnace"])
--def_active = table.copy(minetest.registered_nodes["default:furnace_active"])
elseif minetest.get_modpath("hades_furnaces") then
def = table.copy(minetest.registered_nodes["hades_furnaces:furnace"])
--def_active = table.copy(minetest.registered_nodes["hades_furnaces:furnace_active"])
end
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
--
local override = {
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, bottom = 1, top = 1}
},
after_place_node = pipeworks.after_place,
after_dig_node = pipeworks.after_dig,
on_rotate = pipeworks.on_rotate
}
local override_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, bottom = 1, top = 1}
},
after_place_node = pipeworks.after_place,
after_dig_node = pipeworks.after_dig,
on_rotate = pipeworks.on_rotate
}
if minetest.get_modpath("default") then
minetest.override_item("default:furnace", override)
minetest.override_item("default:furnace_active", override_active)
elseif minetest.get_modpath("hades_furnaces") then
minetest.override_item("hades_furnaces:furnace", override)
minetest.override_item("hades_furnaces:furnace_active", override_active)
end