-
Notifications
You must be signed in to change notification settings - Fork 0
/
wells.lua
1916 lines (1471 loc) · 48.4 KB
/
wells.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
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
local node_oil_yield = {
["geology:shale"] = 1,
["bitumen:oil_shale"] = 3,
}
--[[
The new general plan:
drill hoist --> [H] [T] <-- rig track
steel cable --> | [T] (not crafted, part of the hoist)
drill motor --> [M] [T] (moves up and down)
drill pipe --> | [T][C] (pushed into ground)
well head --> XX[W]XXXXX (on the ground, check for anchoring)
|
drill pipe --> |
|
[C] control boxes, must be connected to the rig track
---- top view ----
[ ][s][ ][C]
[ ][W][T][e]
[ ][d][ ][C]
[s] drill mud supply
[d] drill mud drain
[e] engine
]]
local function find_bottom_of_stack(opos, name)
local pos = vector.new(opos)
while 1 == 1 do
pos.y = pos.y - 1
local n = minetest.get_node(pos)
if n.name ~= name then
pos.y = pos.y + 1
return pos
end
end
return nil
end
local function find_top_of_stack(opos, name)
local pos = vector.new(opos)
while 1 == 1 do
pos.y = pos.y + 1
local n = minetest.get_node(pos)
if n.name ~= name then
pos.y = pos.y - 1
return pos
end
end
return nil
end
local function find_horizontal(pos, name)
if pos == nil then
return nil
end
local tracks = minetest.find_nodes_in_area(
{x=pos.x-1, y=pos.y, z=pos.z-1},
{x=pos.x+1, y=pos.y, z=pos.z+1},
{name}
)
if not tracks or #tracks ~= 1 then
return nil
end
return tracks[1]
end
local function find_wellhead_from_track(trackpos)
if trackpos == nil then return nil end
local pos = find_bottom_of_stack(trackpos, "bitumen:drill_track")
local head = find_horizontal(pos, "bitumen:well_head")
if head then print("found wellhead ".. dump(head)) end
return head
end
local function find_wellhead(pos)
local t = find_horizontal(pos, "bitumen:drill_track")
return find_wellhead_from_track(t), t
end
local function find_well_parts(pos)
local wh, tr = find_wellhead(pos)
if wh == nil then return nil end
local dir = {x = wh.x - tr.x, y = 0, z = wh.z - tr.z}
local ttop = find_top_of_stack(tr, "bitumen:drill_track")
print(dump(ttop))
local parts = minetest.find_nodes_in_area(
{x=wh.x, y=wh.y + 1, z=wh.z},
{x=wh.x, y=ttop.y, z=wh.z},
{"bitumen:drill_hoist", "bitumen:drill_motor"},
true
)
local ret = {
wh = wh,
tr_b = tr,
tr_t = ttop,
controls = {},
cur_dir = ""
}
print(dump(parts))
if parts["bitumen:drill_motor"] then
ret.motor = parts["bitumen:drill_motor"][1]
end
if parts["bitumen:drill_hoist"] then
ret.hoist = parts["bitumen:drill_hoist"][1]
end
local controls = minetest.find_nodes_in_area(
{x=tr.x-1, y=tr.y, z=tr.z-1},
{x=tr.x+1, y=ttop.y, z=tr.z+1},
{"group:bitumen_drill_control"},
true
)
if controls["bitumen:drill_direction_control_down"] then
ret.controls.dir = controls["bitumen:drill_direction_control_down"][1]
ret.cur_dir = "down"
end
if controls["bitumen:drill_direction_control_up"] then
ret.controls.dir = controls["bitumen:drill_direction_control_up"][1]
ret.cur_dir = "up"
end
if controls["bitumen:drill_control_on"] then
ret.controls.power = controls["bitumen:drill_control_on"][1]
end
if controls["bitumen:drill_control_off"] then
ret.controls.power = controls["bitumen:drill_control_off"][1]
end
if controls["bitumen:drill_control_mode_drill"] then
ret.controls.mode = controls["bitumen:drill_control_mode_drill"][1]
ret.cur_mode = "drill"
end
if controls["bitumen:drill_control_mode_retract"] then
ret.controls.mode = controls["bitumen:drill_control_mode_retract"][1]
ret.cur_mode = "retract"
end
if controls["bitumen:drill_oil_pressure_0"] then
ret.controls.pressure = controls["bitumen:drill_oil_pressure_0"][1]
end
if controls["bitumen:drill_oil_pressure_1"] then
ret.controls.pressure = controls["bitumen:drill_oil_pressure_1"][1]
end
if controls["bitumen:drill_oil_pressure_2"] then
ret.controls.pressure = controls["bitumen:drill_oil_pressure_2"][1]
end
if controls["bitumen:drill_oil_pressure_3"] then
ret.controls.pressure = controls["bitumen:drill_oil_pressure_3"][1]
end
if controls["bitumen:drill_oil_pressure_4"] then
ret.controls.pressure = controls["bitumen:drill_oil_pressure_4"][1]
end
return ret
end
local function verify_drill_parts(parts)
if not parts then return false end
if not parts.wh then return false end
if not parts.motor then return false end
if not parts.hoist then return false end
if not parts.controls.dir then return false end
if not parts.controls.power then return false end
if not parts.controls.mode then return false end
return true
end
local function hoist_motor_up(mpos, replacement)
local above = {x=mpos.x, y=mpos.y+1, z=mpos.z}
local an = minetest.get_node(above)
if an.name ~= "bitumen:steel_cable" then
return false -- todo: error vs reached the top
end
minetest.set_node(above, {name = "bitumen:drill_motor"})
minetest.set_node(mpos, {name = replacement})
return true
end
local function hoist_motor_down(mpos)
local below = {x=mpos.x, y=mpos.y-1, z=mpos.z}
local bn = minetest.get_node(below)
if bn.name ~= "air" and bn.name ~= "bitumen:drill_pipe" then
return false -- todo: error vs reached the bottom
end
minetest.set_node(below, {name = "bitumen:drill_motor"})
minetest.set_node(mpos, {name = "bitumen:steel_cable"})
return bn.name
end
local stone_oil_content = {
["default:stone"] = .01,
["default:desert_stone"] = .01,
["default:silver_sandstone"] = .02,
["default:desert_sandstone"] = .02,
["default:sandstone"] = .02,
["default:gravel"] = .03,
["default:sand"] = .01,
["default:desert_sand"] = .01,
["default:silver_sand"] = .01,
["bitumen:oil_shale"] = .1,
["bitumen:tar_sand"] = .1,
["geology:shale"] = .05,
["geology:granite"] = .01,
["geology:marble"] = .01,
["technic:granite"] = .01,
["technic:marble"] = .01,
["geology:basalt"] = .01,
["geology:chalk"] = .02,
["geology:gneiss"] = .01,
["geology:ors"] = .02,
["geology:serpentine"] = .005,
["geology:jade"] = .005,
["geology:schist"] = .01,
["geology:slate"] = .02,
["geology:anthracite"] = .1,
["default:coalblock"] = .1,
}
local function scan_oil_slice(pos, depth)
local depth_min = 50;
local depth_ratio = 5;
local depth_max = 500;
local depth_range = depth_max - depth_min
local d = depth - depth_min;
if d < 0 then
d = 0
elseif d > depth_max then
d = depth_max
end
d = depth_ratio * (d / depth_range)
minetest.forceload_block({x=pos.x-8, y=pos.y, z=pos.z-8}, true)
minetest.forceload_block({x=pos.x-8, y=pos.y, z=pos.z+8}, true)
minetest.forceload_block({x=pos.x+8, y=pos.y, z=pos.z-8}, true)
minetest.forceload_block({x=pos.x+8, y=pos.y, z=pos.z+8}, true)
local nodes = minetest.find_nodes_in_area(
{x=pos.x-8, y=pos.y, z=pos.z-8},
{x=pos.x+8, y=pos.y, z=pos.z+8},
{"group:stone", "group:bitumen_mineral", "default:coalblock", "geology:chalk", "geology:anthracite" },
true
)
local sum = d
for k,v in pairs(nodes) do
if stone_oil_content[k] then
for _,v2 in ipairs(v) do
local x = v2.x - pos.x
local y = v2.y - pos.y
sum = sum + stone_oil_content[k] * (((1.4*8) - math.sqrt(x*x + y*y)) / (1.4*8))
end
end
end
return sum
end
local function check_drill_stack(opos)
local pos = vector.new(opos)
pos.y = pos.y - 1
while 1 == 1 do
local name = minetest.get_node(pos).name
if name == "bitumen:drill_pipe" then
elseif name == "bitumen:drill_mud_extractor" then
elseif name == "bitumen:drill_mud_injector" then
-- noop
else
-- end of the stack
break
end
pos.y = pos.y - 1
end
print("check stack well depth: "..pos.y)
return {x=pos.x, y=pos.y, z=pos.z}
end
-- returns the next node to be drilled
local function get_drill_depth(parts)
local meta = minetest.get_meta(parts.wh)
local dp = meta:get_string("drilldepth") or ""
print("dp" .. dump(dp))
if dp == "" then
--dp = check_drill_stack(pos)
dp = {x=parts.wh.x, y=parts.wh.y, z=parts.wh.z}
meta:set_string("drilldepth", minetest.serialize(dp))
else
dp = minetest.deserialize(dp)
--print("deserialized " .. dump(pos))
end
dp.y = dp.y - 1
return dp
end
-- saves the deepest node with a drill pipe
local function set_drill_depth(parts, dp)
local meta = minetest.get_meta(parts.wh)
meta:set_string("drilldepth", minetest.serialize(dp))
end
local function get_oil_pressure(parts)
local meta = minetest.get_meta(parts.wh)
return meta:get_int("oil_pressure") or 0
end
local function add_oil_pressure(parts, amt)
local meta = minetest.get_meta(parts.wh)
local dp = meta:get_int("oil_pressure")
if dp == nil then
dp = 0
end
dp = dp + amt
meta:set_int("oil_pressure", dp)
return dp
end
local function update_oil_pressure_gauge(parts, oil)
if not parts.controls.pressure then return end
local nn = minetest.get_node(parts.controls.pressure)
if oil < 100 then
minetest.set_node(parts.controls.pressure, {param2 = nn.param2, name = "bitumen:drill_oil_pressure_0"})
elseif oil < 200 then
minetest.set_node(parts.controls.pressure, {param2 = nn.param2, name = "bitumen:drill_oil_pressure_1"})
elseif oil < 500 then
minetest.set_node(parts.controls.pressure, {param2 = nn.param2, name = "bitumen:drill_oil_pressure_2"})
elseif oil < 700 then
minetest.set_node(parts.controls.pressure, {param2 = nn.param2, name = "bitumen:drill_oil_pressure_3"})
else
minetest.set_node(parts.controls.pressure, {param2 = nn.param2, name = "bitumen:drill_oil_pressure_4"})
end
local pmeta = minetest.get_meta(parts.controls.pressure)
pmeta:set_string("infotext", math.floor(oil + .5))
end
local function mul(t, x)
local o = {}
for n,i in ipairs(t) do
o[n] = i * x
end
o[2] = o[2] / x
o[5] = o[5] / x
return o
end
minetest.register_node("bitumen:drill_pipe", {
paramtype = "light",
description = "Drill Pipe",
tiles = {"default_copper_block.png", "default_copper_block.png", "default_copper_block.png",
"default_copper_block.png", "default_copper_block.png", "default_copper_block.png"},
node_box = {
type = "fixed",
fixed = {
--11.25
mul({-0.49, -0.5, -0.10, 0.49, 0.5, 0.10}, .3),
mul({-0.10, -0.5, -0.49, 0.10, 0.5, 0.49}, .3),
--22.5
mul({-0.46, -0.5, -0.19, 0.46, 0.5, 0.19}, .3),
mul({-0.19, -0.5, -0.46, 0.19, 0.5, 0.46}, .3),
-- 33.75
mul({-0.416, -0.5, -0.28, 0.416, 0.5, 0.28}, .3),
mul({-0.28, -0.5, -0.416, 0.28, 0.5, 0.416}, .3),
--45
mul({-0.35, -0.5, -0.35, 0.35, 0.5, 0.35}, .3),
},
},
selection_box = {
type = "fixed",
fixed = {
mul({-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, .3),
},
},
drawtype = "nodebox",
groups = {cracky=3,oddly_breakable_by_hand=3 },
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_punch = function(pos)
check_drill_stack(pos)
end,
})
minetest.register_node("bitumen:drill_track", {
description = "Drilling Track",
tiles = {"bitumen_x_frame.png", "bitumen_x_frame.png", "bitumen_x_frame.png",
"bitumen_x_frame.png", "bitumen_x_frame.png", "bitumen_x_frame.png"},
use_texture_alpha = "clip",
drawtype = "allfaces",
paramtype = "light",
paramtype2 = "facedir",
groups = { cracky=3, oddly_breakable_by_hand=3 }, -- undiggable: part of the drill rig
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("bitumen:drill_hoist", {
description = "Drilling Hoist",
tiles = {"bitumen_dark_metal.png", "bitumen_dark_metal.png", "bitumen_dark_metal.png",
"bitumen_dark_metal.png", "bitumen_dark_metal.png", "bitumen_dark_metal.png"},
use_texture_alpha = "clip",
drawtype = "normal",
paramtype = "light",
paramtype2 = "facedir",
groups = { cracky=3, oddly_breakable_by_hand=3 }, -- undiggable: part of the drill rig
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("bitumen:drill_motor", {
description = "Drilling Motor",
tiles = {"bitumen_dark_metal.png", "bitumen_dark_metal.png", "bitumen_dark_metal.png",
"bitumen_dark_metal.png", "bitumen_dark_metal.png", "bitumen_dark_metal.png"},
use_texture_alpha = "clip",
drawtype = "normal",
paramtype = "light",
paramtype2 = "facedir",
groups = { cracky=3, oddly_breakable_by_hand=3 }, -- undiggable: part of the drill rig
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("bitumen:well_head", {
description = "Well Head",
tiles = {"bitumen_well_top.png", "bitumen_dark_metal.png", "bitumen_dark_metal.png",
"bitumen_dark_metal.png", "bitumen_dark_metal.png", "bitumen_dark_metal.png"},
drawtype = "normal",
paramtype = "light",
paramtype2 = "facedir",
groups = { cracky=3, oddly_breakable_by_hand=3 }, -- undiggable: part of the drill rig
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("bitumen:steel_cable", {
paramtype = "light",
description = "Steel Cable",
tiles = {"default_steel_block.png", "default_steel_block.png", "default_steel_block.png",
"default_steel_block.png", "default_steel_block.png", "default_steel_block.png"},
node_box = {
type = "fixed",
fixed = {
{-0.02, -0.5, -0.02, 0.02, 0.5, 0.02},
},
},
selection_box = {
type = "fixed",
fixed = {
{-0.02, -0.5, -0.02, 0.02, 0.5, 0.02},
},
},
drawtype = "nodebox",
groups = {cracky=3, oddly_breakable_by_hand=3, },
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("bitumen:drill_direction_control_up", {
description = "Drilling Controls (Up)",
tiles = {"default_steel_block.png", "default_steel_block.png", "default_steel_block.png",
"default_steel_block.png", "default_steel_block.png", "default_steel_block.png^bitumen_arrow_up.png"},
drawtype = "normal",
paramtype = "light",
paramtype2 = "facedir",
groups = { cracky=3, oddly_breakable_by_hand=3, bitumen_drill_control=1 }, -- undiggable: part of the drill rig
sounds = default.node_sound_wood_defaults(),
on_punch = function(pos)
local nn = minetest.get_node(pos)
minetest.set_node(pos, {param2 = nn.param2, name="bitumen:drill_direction_control_down"})
end,
})
minetest.register_node("bitumen:drill_direction_control_down", {
description = "Drilling Controls (Down)",
tiles = {"default_steel_block.png", "default_steel_block.png", "default_steel_block.png",
"default_steel_block.png", "default_steel_block.png", "default_steel_block.png^bitumen_arrow_down.png"},
drawtype = "normal",
paramtype = "light",
paramtype2 = "facedir",
groups = { cracky=3, oddly_breakable_by_hand=3, bitumen_drill_control=1 }, -- undiggable: part of the drill rig
sounds = default.node_sound_wood_defaults(),
on_punch = function(pos)
local nn = minetest.get_node(pos)
minetest.set_node(pos, {param2 = nn.param2, name="bitumen:drill_direction_control_up"})
end,
})
local function siphon_pump_oil(parts)
end
minetest.register_node("bitumen:drill_control_on", {
description = "Drilling Controls (On)",
tiles = {"default_steel_block.png", "default_steel_block.png", "default_steel_block.png",
"default_steel_block.png", "default_steel_block.png", "default_steel_block.png^bitumen_green_button.png"},
drawtype = "normal",
paramtype = "light",
paramtype2 = "facedir",
groups = { cracky=3, oddly_breakable_by_hand=3, bitumen_drill_control=1 }, -- undiggable: part of the drill rig
sounds = default.node_sound_wood_defaults(),
on_punch = function(pos)
local nn = minetest.get_node(pos)
minetest.swap_node(pos, {param2 = nn.param2, name="bitumen:drill_control_off"})
end,
on_timer = function(pos, elapsed)
local parts = find_well_parts(pos)
local nn = minetest.get_node(pos)
--print(dump(parts))
-- incomplete drill rig
if not parts or not parts.motor then
minetest.swap_node(pos, {param2 = nn.param2, name="bitumen:drill_control_off"})
return
end
if parts.cur_dir == "down" then
local pipe = hoist_motor_down(parts.motor)
if parts.cur_mode == "drill" then
if pipe == "bitumen:drill_pipe" then -- dig a node
local dp = get_drill_depth(parts)
minetest.forceload_block(dp, true)
minetest.set_node(dp, {name = "bitumen:drill_pipe"})
local oil = scan_oil_slice(dp, parts.wh.y - dp.y)
oil = add_oil_pressure(parts, oil)
print(dump(oil))
update_oil_pressure_gauge(parts, oil)
set_drill_depth(parts, dp)
minetest.get_node_timer(pos):start(2.0)
else
minetest.swap_node(pos, {param2 = nn.param2, name="bitumen:drill_control_off"})
local dn = minetest.get_node(parts.controls.dir)
minetest.swap_node(parts.controls.dir, {param2 = dn.param2, name="bitumen:drill_direction_control_up"})
end
else
if pipe then
minetest.get_node_timer(pos):start(1.0)
else
minetest.swap_node(pos, {param2 = nn.param2, name="bitumen:drill_control_off"})
local dn = minetest.get_node(parts.controls.dir)
minetest.swap_node(parts.controls.dir, {param2 = dn.param2, name="bitumen:drill_direction_control_up"})
end
end
else -- up
-- todo: check the "grab" option
local replacement
local dp
if parts.cur_mode == "drill" then -- raise the drill motor, unconnected to the pipe string
replacement = "air"
elseif parts.cur_mode == "retract" then
dp = get_drill_depth(parts)
dp.y = dp.y + 1
minetest.forceload_block(dp, true)
local dn = minetest.get_node(dp)
print(dump(dn))
if dn.name == "bitumen:drill_pipe" then
replacement = "bitumen:drill_pipe"
else
replacement = "air"
end
else
return
end
if hoist_motor_up(parts.motor, replacement) then
minetest.get_node_timer(pos):start(1.0)
if replacement == "bitumen:drill_pipe" then
minetest.forceload_block(dp, true)
minetest.set_node(dp, {name="air"})
dp.y = dp.y + 1
set_drill_depth(parts, dp)
end
else
minetest.swap_node(pos, {param2 = nn.param2, name="bitumen:drill_control_off"})
local dn = minetest.get_node(parts.controls.dir)
minetest.swap_node(parts.controls.dir, {param2 = dn.param2, name="bitumen:drill_direction_control_down"})
end
end
end
})
minetest.register_node("bitumen:drill_control_off", {
description = "Drilling Controls (Off)",
tiles = {"default_steel_block.png", "default_steel_block.png", "default_steel_block.png",
"default_steel_block.png", "default_steel_block.png", "default_steel_block.png^bitumen_red_button.png"},
drawtype = "normal",
paramtype = "light",
paramtype2 = "facedir",
groups = { cracky=3, oddly_breakable_by_hand=3, bitumen_drill_control=1 }, -- undiggable: part of the drill rig
sounds = default.node_sound_wood_defaults(),
on_punch = function(pos)
local nn = minetest.get_node(pos)
minetest.swap_node(pos, {param2 = nn.param2, name="bitumen:drill_control_on"})
minetest.get_node_timer(pos):start(2.0)
end,
})
minetest.register_node("bitumen:drill_control_mode_drill", {
description = "Drilling Controls (Drill)",
tiles = {"default_steel_block.png", "default_steel_block.png", "default_steel_block.png",
"default_steel_block.png", "default_steel_block.png", "default_steel_block.png^bitumen_drill_icon.png"},
drawtype = "normal",
paramtype = "light",
paramtype2 = "facedir",
groups = { cracky=3, oddly_breakable_by_hand=3, bitumen_drill_control=1 },
sounds = default.node_sound_wood_defaults(),
on_punch = function(pos)
local nn = minetest.get_node(pos)
minetest.swap_node(pos, {param2 = nn.param2, name="bitumen:drill_control_mode_retract"})
end,
})
minetest.register_node("bitumen:drill_control_mode_retract", {
description = "Drilling Controls (Retract)",
tiles = {"default_steel_block.png", "default_steel_block.png", "default_steel_block.png",
"default_steel_block.png", "default_steel_block.png", "default_steel_block.png^bitumen_retract_icon.png"},
drawtype = "normal",
paramtype = "light",
paramtype2 = "facedir",
groups = { cracky=3, oddly_breakable_by_hand=3, bitumen_drill_control=1 },
sounds = default.node_sound_wood_defaults(),
on_punch = function(pos)
local nn = minetest.get_node(pos)
minetest.swap_node(pos, {param2 = nn.param2, name="bitumen:drill_control_mode_drill"})
end,
})
minetest.register_node("bitumen:drill_oil_pressure_0", {
description = "Oil Pressure Guage",
tiles = {"default_steel_block.png", "default_steel_block.png", "default_steel_block.png",
"default_steel_block.png", "default_steel_block.png", "default_steel_block.png^bitumen_bar_background.png"},
drawtype = "normal",
paramtype = "light",
paramtype2 = "facedir",
groups = { cracky=3, oddly_breakable_by_hand=3, bitumen_drill_control=1 },
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("bitumen:drill_oil_pressure_1", {
description = "Oil Pressure Guage",
tiles = {"default_steel_block.png", "default_steel_block.png", "default_steel_block.png",
"default_steel_block.png", "default_steel_block.png", "default_steel_block.png^bitumen_bar_background.png^bitumen_red_bar.png"},
drawtype = "normal",
paramtype = "light",
paramtype2 = "facedir",
groups = { cracky=3, oddly_breakable_by_hand=3, bitumen_drill_control=1, not_in_creative_inventory=1 },
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("bitumen:drill_oil_pressure_2", {
description = "Oil Pressure Guage",
tiles = {"default_steel_block.png", "default_steel_block.png", "default_steel_block.png",
"default_steel_block.png", "default_steel_block.png", "default_steel_block.png^bitumen_bar_background.png^bitumen_red_bar.png^bitumen_orange_bar.png"},
drawtype = "normal",
paramtype = "light",
paramtype2 = "facedir",
groups = { cracky=3, oddly_breakable_by_hand=3, bitumen_drill_control=1, not_in_creative_inventory=1 },
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("bitumen:drill_oil_pressure_3", {
description = "Oil Pressure Guage",
tiles = {"default_steel_block.png", "default_steel_block.png", "default_steel_block.png",
"default_steel_block.png", "default_steel_block.png", "default_steel_block.png^bitumen_bar_background.png^bitumen_red_bar.png^bitumen_orange_bar.png^bitumen_yellow_bar.png"},
drawtype = "normal",
paramtype = "light",
paramtype2 = "facedir",
groups = { cracky=3, oddly_breakable_by_hand=3, bitumen_drill_control=1, not_in_creative_inventory=1 },
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("bitumen:drill_oil_pressure_4", {
description = "Oil Pressure Guage",
tiles = {"default_steel_block.png", "default_steel_block.png", "default_steel_block.png",
"default_steel_block.png", "default_steel_block.png", "default_steel_block.png^bitumen_bar_background.png^bitumen_red_bar.png^bitumen_orange_bar.png^bitumen_yellow_bar.png^bitumen_green_bar.png"},
drawtype = "normal",
paramtype = "light",
paramtype2 = "facedir",
groups = { cracky=3, oddly_breakable_by_hand=3, bitumen_drill_control=1, not_in_creative_inventory=1 },
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("bitumen:drill_pump_on", {
description = "Drilling Pump (On)",
tiles = {"default_bronze_block.png", "default_bronze_block.png", "default_bronze_block.png",
"default_bronze_block.png", "default_bronze_block.png", "default_bronze_block.png"},
drawtype = "normal",
paramtype = "light",
paramtype2 = "facedir",
groups = { cracky=3, oddly_breakable_by_hand=3, bitumen_drill_control=1 }, -- undiggable: part of the drill rig
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("bitumen:drill_pump_off", {
description = "Drilling Pump (Off)",
tiles = {"default_bronze_block.png", "default_bronze_block.png", "default_bronze_block.png",
"default_bronze_block.png", "default_bronze_block.png", "default_bronze_block.png"},
drawtype = "normal",
paramtype = "light",
paramtype2 = "facedir",
groups = { cracky=3, oddly_breakable_by_hand=3, bitumen_drill_control=1 }, -- undiggable: part of the drill rig
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("bitumen:well_siphon", {
paramtype = "light",
description = "Well Siphon",
tiles = {"default_bronze_block.png", "default_bronze_block.png", "default_bronze_block.png",
"default_bronze_block.png", "default_bronze_block.png", "default_bronze_block.png"},
node_box = {
type = "connected",
fixed = {
--11.25
{-0.49, -0.5, -0.10, 0.49, 0.4, 0.10},
{-0.10, -0.5, -0.49, 0.10, 0.4, 0.49},
--22.5
{-0.46, -0.5, -0.19, 0.46, 0.4, 0.19},
{-0.19, -0.5, -0.46, 0.19, 0.4, 0.46},
-- 33.75
{-0.416, -0.5, -0.28, 0.416, 0.4, 0.28},
{-0.28, -0.5, -0.416, 0.28, 0.4, 0.416},
--45
{-0.35, -0.5, -0.35, 0.35, 0.4, 0.35},
},
connect_top = {{ -.1, .3, -.1, .1, .5, .1}},
},
selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
},
},
connects_to = { "group:petroleum_pipe"--[[, "group:petroleum_fixture"]]},
drawtype = "nodebox",
groups = {cracky=3,oddly_breakable_by_hand=3, petroleum_fixture=1 },
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = bitumen.pipes.on_construct,
after_destruct = bitumen.pipes.after_destruct,
})
minetest.register_abm({
nodenames = {"bitumen:well_siphon"},
neighbors = {"bitumen:well_head"},
interval = 5,
chance = 1,
action = function(pos)
local exnet = bitumen.pipes.get_net(pos)
if exnet and (exnet.fluid == "bitumen:crude_oil" or exnet.fluid == "air") then
-- pump oil
local dp = {x=pos.x, y=pos.y-1, z=pos.z}
local oil = get_oil_pressure({wh = dp})
local p = bitumen.pipes.push_fluid(pos, "bitumen:crude_oil", oil / 10, 20)
else
-- must empty the mud out of the pipe first
print("well not connected " .. dump(exnet))
end
end
})
bitumen.register_blueprint({
name="bitumen:drill_track",
no_constructor_craft = true,
})
bitumen.register_blueprint({
name="bitumen:well_head",
no_constructor_craft = true,
})
bitumen.register_blueprint({
name="bitumen:well_siphon",
no_constructor_craft = true,
})
bitumen.register_blueprint({
name="bitumen:drill_motor",
no_constructor_craft = true,
})
bitumen.register_blueprint({
name="bitumen:drill_hoist",
no_constructor_craft = true,
})
bitumen.register_blueprint({
name="bitumen:drill_control_mode_retract",
no_constructor_craft = true,
})
bitumen.register_blueprint({
name="bitumen:drill_oil_pressure_0",
no_constructor_craft = true,
})
bitumen.register_blueprint({
name="bitumen:drill_control_off",
no_constructor_craft = true,
})
bitumen.register_blueprint({
name="bitumen:drill_direction_control_down",
no_constructor_craft = true,
})
minetest.register_craft({
output = 'bitumen:drill_track',
type = "shapeless",
recipe = {
'bitumen:drill_track_blueprint',
'default:steel_ingot',
'default:steel_ingot'
},
replacements = {
{ 'bitumen:drill_track_blueprint', 'bitumen:drill_track_blueprint' },
}
})
minetest.register_craft({
output = 'bitumen:well_head',
type = "shapeless",
recipe = {
'bitumen:well_head_blueprint',
'default:steelblock',
},
replacements = {
{ 'bitumen:well_head_blueprint', 'bitumen:well_head_blueprint' },
}
})
minetest.register_craft({
output = 'bitumen:well_siphon',
type = "shapeless",
recipe = {
'bitumen:well_siphon_blueprint',
'default:steelblock',
},
replacements = {
{ 'bitumen:well_siphon_blueprint', 'bitumen:well_siphon_blueprint' },
}
})
minetest.register_craft({
output = 'bitumen:drill_motor',
type = "shapeless",
recipe = {
'bitumen:drill_motor_blueprint',
'default:steelblock',
},
replacements = {
{ 'bitumen:drill_motor_blueprint', 'bitumen:drill_motor_blueprint' },
}
})
minetest.register_craft({
output = 'bitumen:drill_hoist',
type = "shapeless",
recipe = {
'bitumen:drill_hoist_blueprint',
'default:steelblock',
},
replacements = {
{ 'bitumen:drill_hoist_blueprint', 'bitumen:drill_hoist_blueprint' },