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