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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
-- Storage buffer. Builder nodes draw from this inventory and digger nodes deposit into it.
-- Note that inventories are digtron group 2.
minetest.register_node("digtron:inventory",
{
description = "Digtron Inventory Hopper",
groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 2, tubedevice = 1, tubedevice_receiver = 1},
drop = "digtron:inventory",
sounds = digtron.metal_sounds,
paramtype2= "facedir",
is_ground_content = false,
tiles = {"digtron_inventory.png"},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec",
"size[8,9.3]" ..
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
"label[0,0;Inventory items]" ..
"list[current_name;main;0,0.6;8,4;]" ..
"list[current_player;main;0,5.15;8,1;]" ..
"list[current_player;main;0,6.38;8,3;8]" ..
"listring[current_name;main]" ..
"listring[current_player;main]" ..
default.get_hotbar_bg(0,5.15)
)
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return inv:is_empty("main")
end,
-- Pipeworks compatibility
----------------------------------------------------------------
tube = (function() if minetest.get_modpath("pipeworks") then return {
insert_object = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return inv:add_item("main", stack)
end,
can_insert = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return inv:room_for_item("main", stack)
end,
input_inventory = "main",
connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
} end end)(),
after_place_node = (function() if minetest.get_modpath("pipeworks") then return pipeworks.after_place end end)(),
after_dig_node = (function() if minetest.get_modpath("pipeworks") then return pipeworks.after_dig end end)()
})
-- Fuel storage. Controller node draws fuel from here.
-- Note that fuel stores are digtron group 5.
minetest.register_node("digtron:fuelstore",
{
description = "Digtron Fuel Hopper",
groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 5, tubedevice = 1, tubedevice_receiver = 1},
drop = "digtron:fuelstore",
sounds = digtron.metal_sounds,
paramtype2= "facedir",
is_ground_content = false,
tiles = {"digtron_fuelstore.png"},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec",
"size[8,9.3]" ..
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
"label[0,0;Fuel items]" ..
"list[current_name;fuel;0,0.6;8,4;]" ..
"list[current_player;main;0,5.15;8,1;]" ..
"list[current_player;main;0,6.38;8,3;8]" ..
"listring[current_name;fuel]" ..
"listring[current_player;main]" ..
default.get_hotbar_bg(0,5.15)
)
local inv = meta:get_inventory()
inv:set_size("fuel", 8*4)
end,
-- Only allow fuel items to be placed in fuel
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then
return 0
end
if listname == "fuel" then
if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then
return stack:get_count()
else
return 0
end
end
return 0
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return inv:is_empty("fuel")
end,
-- Pipeworks compatibility
----------------------------------------------------------------
tube = (function() if minetest.get_modpath("pipeworks") then return {
insert_object = function(pos, node, stack, direction)
if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return inv:add_item("fuel", stack)
end
return stack
end,
can_insert = function(pos, node, stack, direction)
if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return inv:room_for_item("fuel", stack)
end
return false
end,
input_inventory = "fuel",
connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
} end end)(),
after_place_node = (function() if minetest.get_modpath("pipeworks") then return pipeworks.after_place end end)(),
after_dig_node = (function() if minetest.get_modpath("pipeworks")then return pipeworks.after_dig end end)()
})
-- Combined storage. Group 6 has both an inventory and a fuel store
minetest.register_node("digtron:combined_storage",
{
description = "Digtron Combined Storage",
groups = {cracky = 3, oddly_breakable_by_hand=3, digtron = 6, tubedevice = 1, tubedevice_receiver = 1},
drop = "digtron:combined_storage",
sounds = digtron.metal_sounds,
paramtype2= "facedir",
is_ground_content = false,
tiles = {"digtron_combined_storage.png"},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec",
"size[8,9.9]" ..
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
"label[0,0;Inventory items]" ..
"list[current_name;main;0,0.6;8,3;]" ..
"label[0,3.5;Fuel items]" ..
"list[current_name;fuel;0,4.1;8,1;]" ..
"list[current_player;main;0,5.75;8,1;]" ..
"list[current_player;main;0,6.98;8,3;8]" ..
"listring[current_name;fuel]" ..
"listring[current_player;main]" ..
default.get_hotbar_bg(0,5.75)
)
local inv = meta:get_inventory()
inv:set_size("main", 8*3)
inv:set_size("fuel", 8*1)
end,
-- Only allow fuel items to be placed in fuel
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then
return 0
end
if listname == "fuel" then
if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then
return stack:get_count()
else
return 0
end
end
return stack:get_count() -- otherwise, allow all drops
end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
if to_list == "main" then
return count
end
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local stack = inv:get_stack(from_list, from_index)
if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then
return stack:get_count()
end
return 0
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return inv:is_empty("fuel") and inv:is_empty("main")
end,
-- Pipeworks compatibility
----------------------------------------------------------------
tube = (function() if minetest.get_modpath("pipeworks") then return {
insert_object = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 and direction.y == 1 then
return inv:add_item("fuel", stack)
end
return inv:add_item("main", stack)
end,
can_insert = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 and direction.y == 1 then
return inv:room_for_item("fuel", stack)
end
return inv:room_for_item("main", stack)
end,
input_inventory = "main",
connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
} end end)(),
after_place_node = (function() if minetest.get_modpath("pipeworks") then return pipeworks.after_place end end)(),
after_dig_node = (function() if minetest.get_modpath("pipeworks") then return pipeworks.after_dig end end)()
})
|