-
Notifications
You must be signed in to change notification settings - Fork 0
/
oilshale.lua
380 lines (282 loc) · 8.33 KB
/
oilshale.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
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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
--[[ NEED:
textures:
oil shale
crushed oil shale
node defs:
(tweak) oil shale
craftitem:
crushed oil shale
ore reg:
(tweak) oil shale
grinder recipe:
oil shale -> crushed oil shale
extractor recipe:
crushed oil shale -> bitumen
]]
-- need to get the info for stone-type things
minetest.register_node( "bitumen:tar_sand", {
description = "Tar Sand",
tiles = { "default_sand.png^[colorize:black:180" },
is_ground_content = true,
groups = {crumbly=2, bitumen_mineral = 1, falling_node=1},
sounds = default.node_sound_sand_defaults(),
})
minetest.register_node( "bitumen:oil_shale", {
description = "Oil Shale",
tiles = { "default_stone.png^[colorize:black:180" },
is_ground_content = true,
groups = {cracky=2, bitumen_mineral = 1},
sounds = default.node_sound_stone_defaults(),
})
local function swap_node(pos, name)
local node = minetest.get_node(pos)
if node.name == name then
return
end
node.name = name
minetest.swap_node(pos, node)
end
--[[
local function grab_fuel(inv)
local list = inv:get_list("fuel")
for i,st in ipairs(list) do
print(st:get_name())
local fuel, remains
fuel, remains = minetest.get_craft_result({
method = "fuel",
width = 1,
items = {
ItemStack(st:get_name())
},
})
if fuel.time > 0 then
-- Take fuel from fuel list
st:take_item()
inv:set_stack("fuel", i, st)
return fuel.time
end
end
return 0 -- no fuel found
end
]]
bitumen.register_burner({"bitumen:mineral_oil_furnace_on"}, {
start_cook = function(pos)
local up = {x=pos.x, y=pos.y + 1, z=pos.z}
local meta = minetest.get_meta(up)
local inv = meta:get_inventory()
local item = inv:remove_item("main", "bitumen:tar_sand 1")
if item == nil or item:get_count() <= 0 then
item = inv:remove_item("main", "bitumen:oil_shale 1")
if item == nil or item:get_count() <= 0 then
print("no minerals")
return 0 -- no minerals to melt
end
return 6 -- oil shale takes longer
end
return 4
end,
finish_cook = function(pos)
local node = minetest.get_node(pos)
local back_dir = minetest.facedir_to_dir(node.param2)
local backpos = vector.add(pos, back_dir)
local backnet = bitumen.pipes.get_net(backpos)
if backnet == nil then
print("mineral furnace no backnet at "..minetest.pos_to_string(backpos))
return
end
local pushed = bitumen.pipes.push_fluid(backpos, "bitumen:crude_oil", 32, 2)
end,
get_formspec_on = get_melter_active_formspec,
turn_off = function(pos)
swap_node(pos, "bitumen:mineral_oil_furnace")
end,
})
minetest.register_node("bitumen:mineral_oil_furnace", {
description = "Mineral Deposit Furnace",
tiles = {
"default_bronze_block.png", "default_bronze_block.png",
"default_bronze_block.png", "default_bronze_block.png",
"default_bronze_block.png", "default_furnace_front.png",
},
paramtype2 = "facedir",
groups = {cracky=2, petroleum_fixture=1},
is_ground_content = false,
on_place = minetest.rotate_node,
sounds = default.node_sound_stone_defaults(),
--can_dig = can_dig,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", bitumen.get_melter_active_formspec())
local inv = meta:get_inventory()
inv:set_size('fuel', 4)
minetest.get_node_timer(pos):start(1.0)
end,
on_punch = function(pos)
swap_node(pos, "bitumen:mineral_oil_furnace_on")
minetest.get_node_timer(pos):start(1.0)
end,
})
minetest.register_node("bitumen:mineral_oil_furnace_on", {
description = "Mineral Deposit Furnace (Active)",
tiles = {
"default_bronze_block.png", "default_bronze_block.png",
"default_bronze_block.png", "default_bronze_block.png",
"default_bronze_block.png", {
image = "default_furnace_front_active.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 1.5
},
}
},
paramtype2 = "facedir",
groups = {cracky=2, petroleum_fixture=1},
is_ground_content = false,
on_place = minetest.rotate_node,
sounds = default.node_sound_stone_defaults(),
--can_dig = can_dig,
on_timer = bitumen.burner_on_timer,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", bitumen.get_melter_active_formspec())
local inv = meta:get_inventory()
inv:set_size('fuel', 4)
minetest.get_node_timer(pos):start(1.0)
end,
on_punch = function(pos)
swap_node(pos, "bitumen:mineral_oil_furnace")
minetest.get_node_timer(pos):start(1.0)
end,
})
bitumen.register_blueprint({name="bitumen:mineral_oil_furnace"})
--[[
bitumen.register_burner({"bitumen:engine_on"}, {
start_cook = function()
print("starting-")
return 8
end,
finish_cook = function()
print("ending-")
end,
get_formspec_on = get_melter_active_formspec,
})
minetest.register_node("bitumen:engine", {
description = "Engine",
tiles = {
"default_bronze_block.png", "default_bronze_block.png",
"default_bronze_block.png", "default_bronze_block.png",
"default_bronze_block.png", "default_furnace_front.png",
},
paramtype2 = "facedir",
groups = {cracky=2, petroleum_fixture=1},
is_ground_content = false,
sounds = default.node_sound_stone_defaults(),
--can_dig = can_dig,
--on_timer = burner_on_timer,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", get_melter_active_formspec())
local inv = meta:get_inventory()
inv:set_size('fuel', 4)
minetest.get_node_timer(pos):start(1.0)
end,
-- on_metadata_inventory_move = function(pos)
-- minetest.get_node_timer(pos):start(1.0)
-- end,
-- on_metadata_inventory_put = function(pos)
-- -- start timer function, it will sort out whether furnace can burn or not.
-- minetest.get_node_timer(pos):start(1.0)
-- end,
--
on_punch = function(pos)
swap_node(pos, "bitumen:engine_on")
minetest.get_node_timer(pos):start(1.0)
end,
-- on_blast = function(pos)
-- local drops = {}
-- default.get_inventory_drops(pos, "src", drops)
-- default.get_inventory_drops(pos, "fuel", drops)
-- default.get_inventory_drops(pos, "dst", drops)
-- drops[#drops+1] = "machines:machine"
-- minetest.remove_node(pos)
-- return drops
-- end,
allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_move = allow_metadata_inventory_move,
allow_metadata_inventory_take = allow_metadata_inventory_take,
})
minetest.register_node("bitumen:engine_on", {
description = "Engine",
tiles = {
"default_tin_block.png", "default_bronze_block.png",
"default_bronze_block.png", "default_tin_block.png",
"default_tin_block.png",
{
image = "default_furnace_front_active.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 1.5
},
}
},
paramtype2 = "facedir",
groups = {cracky=2, petroleum_fixture=1, not_in_creative_inventory=1},
is_ground_content = false,
sounds = default.node_sound_stone_defaults(),
--can_dig = can_dig,
on_timer = bitumen.burner_on_timer,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", get_melter_active_formspec())
local inv = meta:get_inventory()
inv:set_size('fuel', 4)
minetest.get_node_timer(pos):start(1.0)
end,
-- on_metadata_inventory_move = function(pos)
-- minetest.get_node_timer(pos):start(1.0)
-- end,
-- on_metadata_inventory_put = function(pos)
-- -- start timer function, it will sort out whether furnace can burn or not.
-- minetest.get_node_timer(pos):start(1.0)
-- end,
--
on_punch = function(pos)
swap_node(pos, "bitumen:engine")
end,
allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_move = allow_metadata_inventory_move,
allow_metadata_inventory_take = allow_metadata_inventory_take,
})
]]
--[[
minetest.register_ore({
ore_type = "stratum",
ore = "default:meselamp",
wherein = {"default:stone"},
clust_scarcity = 1,
y_min = -8,
y_max = 72,
noise_params = {
offset = 32,
scale = 16,
spread = {x = 256, y = 256, z = 256},
seed = 90122,
octaves = 3,
persist = 0.5
},
np_stratum_thickness = {
offset = 8,
scale = 4,
spread = {x = 128, y = 128, z = 128},
seed = -316,
octaves = 1,
persist = 0.0
},
})
]]