commit | author | age
|
ee0765
|
1 |
-- A geothermal EU generator |
S |
2 |
-- Using hot lava and water this device can create energy from steam |
|
3 |
-- The machine is only producing LV EUs and can thus not drive more advanced equipment |
|
4 |
-- The output is a little more than the coal burning generator (max 300EUs) |
|
5 |
|
|
6 |
minetest.register_alias("geothermal", "technic:geothermal") |
|
7 |
|
be2f30
|
8 |
local S = technic.getter |
S |
9 |
|
ee0765
|
10 |
minetest.register_craft({ |
S |
11 |
output = 'technic:geothermal', |
|
12 |
recipe = { |
83c649
|
13 |
{'technic:granite', 'default:diamond', 'technic:granite'}, |
44cb8d
|
14 |
{'basic_materials:copper_wire', 'technic:machine_casing', 'basic_materials:copper_wire'}, |
83c649
|
15 |
{'technic:granite', 'technic:lv_cable', 'technic:granite'}, |
44cb8d
|
16 |
}, |
VD |
17 |
replacements = { |
|
18 |
{"basic_materials:copper_wire", "basic_materials:empty_spool"}, |
|
19 |
{"basic_materials:copper_wire", "basic_materials:empty_spool"} |
|
20 |
}, |
ee0765
|
21 |
}) |
S |
22 |
|
|
23 |
minetest.register_craftitem("technic:geothermal", { |
7c4b70
|
24 |
description = S("Geothermal %s Generator"):format("LV"), |
ee0765
|
25 |
}) |
S |
26 |
|
563a4c
|
27 |
local check_node_around = function(pos) |
N |
28 |
local node = minetest.get_node(pos) |
|
29 |
if node.name == "default:water_source" or node.name == "default:water_flowing" then return 1 end |
|
30 |
if node.name == "default:lava_source" or node.name == "default:lava_flowing" then return 2 end |
|
31 |
return 0 |
|
32 |
end |
|
33 |
|
|
34 |
local run = function(pos, node) |
|
35 |
local meta = minetest.get_meta(pos) |
|
36 |
local water_nodes = 0 |
|
37 |
local lava_nodes = 0 |
|
38 |
local production_level = 0 |
|
39 |
local eu_supply = 0 |
|
40 |
|
|
41 |
-- Correct positioning is water on one side and lava on the other. |
|
42 |
-- The two cannot be adjacent because the lava the turns into obsidian or rock. |
|
43 |
-- To get to 100% production stack the water and lava one extra block down as well: |
|
44 |
-- WGL (W=Water, L=Lava, G=the generator, |=an LV cable) |
|
45 |
-- W|L |
|
46 |
|
|
47 |
local positions = { |
|
48 |
{x=pos.x+1, y=pos.y, z=pos.z}, |
|
49 |
{x=pos.x+1, y=pos.y-1, z=pos.z}, |
|
50 |
{x=pos.x-1, y=pos.y, z=pos.z}, |
|
51 |
{x=pos.x-1, y=pos.y-1, z=pos.z}, |
|
52 |
{x=pos.x, y=pos.y, z=pos.z+1}, |
|
53 |
{x=pos.x, y=pos.y-1, z=pos.z+1}, |
|
54 |
{x=pos.x, y=pos.y, z=pos.z-1}, |
|
55 |
{x=pos.x, y=pos.y-1, z=pos.z-1}, |
|
56 |
} |
|
57 |
for _, p in pairs(positions) do |
|
58 |
local check = check_node_around(p) |
|
59 |
if check == 1 then water_nodes = water_nodes + 1 end |
|
60 |
if check == 2 then lava_nodes = lava_nodes + 1 end |
|
61 |
end |
|
62 |
|
|
63 |
if water_nodes == 1 and lava_nodes == 1 then production_level = 25; eu_supply = 50 end |
|
64 |
if water_nodes == 2 and lava_nodes == 1 then production_level = 50; eu_supply = 100 end |
|
65 |
if water_nodes == 1 and lava_nodes == 2 then production_level = 75; eu_supply = 200 end |
|
66 |
if water_nodes == 2 and lava_nodes == 2 then production_level = 100; eu_supply = 300 end |
|
67 |
|
|
68 |
if production_level > 0 then |
|
69 |
meta:set_int("LV_EU_supply", eu_supply) |
|
70 |
end |
|
71 |
|
|
72 |
meta:set_string("infotext", |
|
73 |
S("Geothermal %s Generator"):format("LV").." ("..production_level.."%)") |
|
74 |
|
|
75 |
if production_level > 0 and minetest.get_node(pos).name == "technic:geothermal" then |
|
76 |
technic.swap_node (pos, "technic:geothermal_active") |
|
77 |
return |
|
78 |
end |
|
79 |
if production_level == 0 then |
|
80 |
technic.swap_node(pos, "technic:geothermal") |
|
81 |
meta:set_int("LV_EU_supply", 0) |
|
82 |
end |
|
83 |
end |
|
84 |
|
ee0765
|
85 |
minetest.register_node("technic:geothermal", { |
7c4b70
|
86 |
description = S("Geothermal %s Generator"):format("LV"), |
ee0765
|
87 |
tiles = {"technic_geothermal_top.png", "technic_machine_bottom.png", "technic_geothermal_side.png", |
S |
88 |
"technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png"}, |
83c649
|
89 |
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, |
S |
90 |
technic_machine=1, technic_lv=1}, |
ee0765
|
91 |
paramtype2 = "facedir", |
S |
92 |
legacy_facedir_simple = true, |
|
93 |
sounds = default.node_sound_wood_defaults(), |
|
94 |
on_construct = function(pos) |
|
95 |
local meta = minetest.get_meta(pos) |
7c4b70
|
96 |
meta:set_string("infotext", S("Geothermal %s Generator"):format("LV")) |
ee0765
|
97 |
meta:set_int("LV_EU_supply", 0) |
563a4c
|
98 |
end, |
N |
99 |
technic_run = run, |
ee0765
|
100 |
}) |
S |
101 |
|
|
102 |
minetest.register_node("technic:geothermal_active", { |
7c4b70
|
103 |
description = S("Geothermal %s Generator"):format("LV"), |
ee0765
|
104 |
tiles = {"technic_geothermal_top_active.png", "technic_machine_bottom.png", "technic_geothermal_side.png", |
S |
105 |
"technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png"}, |
|
106 |
paramtype2 = "facedir", |
83c649
|
107 |
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, |
S |
108 |
technic_machine=1, technic_lv=1, not_in_creative_inventory=1}, |
ee0765
|
109 |
legacy_facedir_simple = true, |
S |
110 |
sounds = default.node_sound_wood_defaults(), |
|
111 |
drop = "technic:geothermal", |
563a4c
|
112 |
technic_run = run, |
ee0765
|
113 |
}) |
S |
114 |
|
|
115 |
technic.register_machine("LV", "technic:geothermal", technic.producer) |
|
116 |
technic.register_machine("LV", "technic:geothermal_active", technic.producer) |
|
117 |
|