This repository was archived by the owner on Apr 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathstorage.lua
More file actions
316 lines (265 loc) · 8.2 KB
/
Copy pathstorage.lua
File metadata and controls
316 lines (265 loc) · 8.2 KB
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
-------------------------------------------------------------
local function is_owner(pos, name)
local owner = minetest.get_meta(pos):get_string("owner")
if owner == "" or owner == name or minetest.check_player_privs(name, "protection_bypass") then
return true
end
return false
end
---------------------------------------------------
local function get_storage_formspec(pos)
local formspec ="size[8,7]" ..
default.gui_bg ..
default.gui_bg_img ..
default.gui_slots ..
"list[current_name;main;0,0.3;8,2]" ..
"list[current_player;main;0,2.85;8,1]" ..
"list[current_player;main;0,4.08;8,3;8]" ..
"listring[current_name;main]" ..
"listring[current_player;main]"
return formspec
end
-------------------------------------------------------------
--Storage Pot
--Unfired pot (not usuable... must be cooked)
minetest.register_craftitem("earthbuild:storage_pot_unfired", {
description = "Unfired Clay Storage Pot",
inventory_image = "earthbuild_storage_pot_unfired.png",
stack_max = 99,
})
--Finished Pot
minetest.register_node("earthbuild:storage_pot", {
description = "Clay Storage Pot",
tiles = {"earthbuild_storage_pot_top.png",
"earthbuild_storage_pot_top.png",
"earthbuild_storage_pot.png",
"earthbuild_storage_pot.png",
"earthbuild_storage_pot.png"},
drawtype = "nodebox",
paramtype = "light",
node_box = {
type = "fixed",
fixed = {
{-0.375, -0.5, -0.375, 0.375, -0.375, 0.375},
{-0.375, 0.375, -0.375, 0.375, 0.5, 0.375},
{-0.4375, -0.375, -0.4375, 0.4375, -0.25, 0.4375},
{-0.4375, 0.25, -0.4375, 0.4375, 0.375, 0.4375},
{-0.5, -0.25, -0.5, 0.5, 0.25, 0.5},
}
},
groups = {oddly_breakable_by_hand = 3},
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", get_storage_formspec(pos, 8, 2))
local inv = meta:get_inventory()
inv:set_size("main", 8*3)
meta:set_string("infotext", "Clay Storage Pot")
end,
can_dig = function(pos, player)
local inv = minetest.get_meta(pos):get_inventory()
local name = ""
if player then
name = player:get_player_name()
end
return is_owner(pos, name) and inv:is_empty("main")
end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
if is_owner(pos, player:get_player_name()) then
return count
end
return 0
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if is_owner(pos, player:get_player_name())
and not string.match(stack:get_name(), "backpacks:") then
return stack:get_count()
end
return 0
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
if is_owner(pos, player:get_player_name()) then
return stack:get_count()
end
return 0
end,
on_blast = function(pos)
end,
})
--Craft unfired pot
minetest.register_craft({
output = "earthbuild:storage_pot_unfired",
recipe = {
{"default:clay_lump", "default:clay_lump", "default:clay_lump"},
{"default:clay_lump", "", "default:clay_lump"},
{"default:clay_lump", "default:clay_lump", "default:clay_lump"},
}
})
--Recycle unfired pot
minetest.register_craft({
output = "default:clay_lump 8",
recipe = {
{"earthbuild:storage_pot_unfired"}}
})
--Cook unfired pot to give the useable pot
minetest.register_craft({
type = "cooking",
output = "earthbuild:storage_pot",
recipe = "earthbuild:storage_pot_unfired",
cooktime = 10,
})
--------------------------------------------
--Basket
minetest.register_node("earthbuild:basket", {
description = "Basket",
tiles = {"earthbuild_basket_top.png",
"earthbuild_basket_top.png",
"earthbuild_basket.png",
"earthbuild_basket.png",
"earthbuild_basket.png"},
drawtype = "nodebox",
paramtype = "light",
node_box = {
type = "fixed",
fixed = {
{-0.25, 0.375, -0.25, 0.25, 0.5, 0.25},
{-0.375, -0.25, -0.375, 0.375, 0.3125, 0.375},
{-0.3125, -0.375, -0.3125, 0.3125, -0.25, 0.3125},
{-0.25, -0.5, -0.25, 0.25, -0.375, 0.25},
{-0.3125, 0.3125, -0.3125, 0.3125, 0.375, 0.3125},
}
},
groups = {oddly_breakable_by_hand = 3},
sounds = default.node_sound_leaves_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", get_storage_formspec(pos, 8, 2))
local inv = meta:get_inventory()
inv:set_size("main", 8*2)
meta:set_string("infotext", "Basket")
end,
can_dig = function(pos, player)
local inv = minetest.get_meta(pos):get_inventory()
local name = ""
if player then
name = player:get_player_name()
end
return is_owner(pos, name) and inv:is_empty("main")
end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
if is_owner(pos, player:get_player_name()) then
return count
end
return 0
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if is_owner(pos, player:get_player_name())
and not string.match(stack:get_name(), "backpacks:") then
return stack:get_count()
end
return 0
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
if is_owner(pos, player:get_player_name()) then
return stack:get_count()
end
return 0
end,
on_blast = function(pos)
end,
})
--Craft basket
minetest.register_craft({
output = "earthbuild:basket",
recipe = {
{"earthbuild:woven_mat", "earthbuild:woven_mat", "earthbuild:woven_mat"},
{"earthbuild:woven_mat", "", "earthbuild:woven_mat"},
{"earthbuild:woven_mat", "earthbuild:woven_mat", "earthbuild:woven_mat"},
}
})
--burn basket
minetest.register_craft({
type = "fuel",
recipe = "earthbuild:basket",
burntime = 8,
})
-----------------------------------------------------
--Gourd Container
--Vessel
minetest.register_node("earthbuild:bottlegourd_container", {
description = "Bottlegourd Container",
drawtype = "nodebox",
tiles = { "earthbuild_bottlegourd_container_top.png",
"earthbuild_bottlegourd_bot.png",
"earthbuild_bottlegourd_container.png",
"earthbuild_bottlegourd_container.png",
"earthbuild_bottlegourd_container.png",
"earthbuild_bottlegourd_container.png",
"earthbuild_bottlegourd_container.png",
"earthbuild_bottlegourd_container.png",
},
inventory_image = "earthbuild_bottlegourd_container.png",
wield_image = "earthbuild_bottlegourd_container.png",
paramtype = "light",
node_box = {
type = "fixed",
fixed = {
{-0.25, -0.5, -0.25, 0.25, -0.0, 0.25},
}
},
selection_box = {
type = "fixed",
fixed = {
{-0.25, -0.5, -0.25, 0.25, -0.0, 0.25},
}
},
groups = {dig_immediate = 3,},
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", get_storage_formspec(pos, 8, 2))
local inv = meta:get_inventory()
inv:set_size("main", 1*1)
meta:set_string("infotext", "Bottle Gourd")
end,
can_dig = function(pos, player)
local inv = minetest.get_meta(pos):get_inventory()
local name = ""
if player then
name = player:get_player_name()
end
return is_owner(pos, name) and inv:is_empty("main")
end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
if is_owner(pos, player:get_player_name()) then
return count
end
return 0
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if is_owner(pos, player:get_player_name())
and not string.match(stack:get_name(), "backpacks:") then
return stack:get_count()
end
return 0
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
if is_owner(pos, player:get_player_name()) then
return stack:get_count()
end
return 0
end,
on_blast = function(pos)
end,
})
minetest.register_craft({
output = 'earthbuild:bottlegourd_container',
recipe = {
{'earthbuild:bottlegourd_cup', 'earthbuild:bottlegourd_cup'},
}
})
minetest.register_craft({
type = "fuel",
recipe = "earthbuild:bottlegourd_container",
burntime = 1,
})