commit | author | age
|
82cba9
|
1 |
minetest.register_alias("geothermal", "technic:geothermal") |
R |
2 |
|
|
3 |
minetest.register_craft({ |
|
4 |
output = 'technic:geothermal', |
|
5 |
recipe = { |
|
6 |
{'default:stone', 'default:stone', 'default:stone'}, |
cdb368
|
7 |
{'default:copper_ingot', 'default:diamond', 'default:copper_ingot'}, |
R |
8 |
{'default:stone', 'default:copper_ingot', 'default:stone'}, |
82cba9
|
9 |
} |
R |
10 |
}) |
|
11 |
|
|
12 |
minetest.register_craftitem("technic:geothermal", { |
|
13 |
description = "Geothermal Generator", |
|
14 |
stack_max = 99, |
|
15 |
}) |
|
16 |
|
|
17 |
geothermal_formspec = |
|
18 |
"invsize[8,4;]".. |
|
19 |
"image[1,1;1,2;technic_power_meter_bg.png]".. |
|
20 |
"label[0,0;Geothermal Generator]".. |
|
21 |
"label[1,3;Power level]".. |
|
22 |
"list[current_player;main;0,5;8,4;]" |
|
23 |
|
|
24 |
|
|
25 |
minetest.register_node("technic:geothermal", { |
|
26 |
description = "Geothermal Generator", |
|
27 |
tiles = {"technic_geothermal_top.png", "technic_machine_bottom.png", "technic_geothermal_side.png", |
|
28 |
"technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png"}, |
|
29 |
paramtype2 = "facedir", |
|
30 |
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, |
|
31 |
legacy_facedir_simple = true, |
|
32 |
sounds = default.node_sound_wood_defaults(), |
|
33 |
technic_power_machine=1, |
|
34 |
internal_EU_buffer=0; |
|
35 |
internal_EU_buffer_size=5000; |
|
36 |
burn_time=0; |
|
37 |
on_construct = function(pos) |
|
38 |
local meta = minetest.env:get_meta(pos) |
|
39 |
meta:set_string("infotext", "Geothermal Generator") |
|
40 |
meta:set_float("technic_power_machine", 1) |
|
41 |
meta:set_float("internal_EU_buffer", 0) |
|
42 |
meta:set_float("internal_EU_buffer_size", 2000) |
|
43 |
meta:set_string("formspec", geothermal_formspec) |
|
44 |
end, |
|
45 |
|
|
46 |
}) |
|
47 |
|
|
48 |
minetest.register_node("technic:geothermal_active", { |
|
49 |
description = "Geothermal Generator", |
|
50 |
tiles = {"technic_geothermal_top_active.png", "technic_machine_bottom.png", "technic_geothermal_side.png", |
|
51 |
"technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png"}, |
|
52 |
paramtype2 = "facedir", |
|
53 |
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1}, |
|
54 |
legacy_facedir_simple = true, |
|
55 |
sounds = default.node_sound_wood_defaults(), |
|
56 |
drop="technic:geothermal", |
|
57 |
technic_power_machine=1, |
|
58 |
internal_EU_buffer=0; |
|
59 |
internal_EU_buffer_size=0; |
|
60 |
}) |
|
61 |
|
|
62 |
minetest.register_abm({ |
|
63 |
nodenames = {"technic:geothermal","technic:geothermal_active"}, |
|
64 |
interval = 1, |
|
65 |
chance = 1, |
|
66 |
action = function(pos, node, active_object_count, active_object_count_wider) |
|
67 |
|
|
68 |
local meta = minetest.env:get_meta(pos) |
|
69 |
local charge= meta:get_float("internal_EU_buffer") |
|
70 |
local max_charge= meta:get_float("internal_EU_buffer_size") |
|
71 |
local water_nodes = 0 |
|
72 |
local lava_nodes = 0 |
|
73 |
local production_level=0 |
|
74 |
local load_step=0 |
|
75 |
|
|
76 |
pos.x=pos.x+1 |
|
77 |
local check=check_node_around (pos) |
|
78 |
if check==1 then water_nodes=water_nodes+1 end |
|
79 |
if check==2 then lava_nodes=lava_nodes+1 end |
|
80 |
pos.x=pos.x-2 |
|
81 |
check=check_node_around (pos) |
|
82 |
if check==1 then water_nodes=water_nodes+1 end |
|
83 |
if check==2 then lava_nodes=lava_nodes+1 end |
|
84 |
pos.x=pos.x+1 |
|
85 |
pos.z=pos.z+1 |
|
86 |
check=check_node_around (pos) |
|
87 |
if check==1 then water_nodes=water_nodes+1 end |
|
88 |
if check==2 then lava_nodes=lava_nodes+1 end |
|
89 |
pos.z=pos.z-2 |
|
90 |
check=check_node_around (pos) |
|
91 |
if check==1 then water_nodes=water_nodes+1 end |
|
92 |
if check==2 then lava_nodes=lava_nodes+1 end |
|
93 |
pos.z=pos.z+1 |
|
94 |
|
|
95 |
if water_nodes==1 and lava_nodes==1 then production_level=50 load_step=30 end |
|
96 |
if water_nodes==2 and lava_nodes==1 then production_level=75 load_step=45 end |
|
97 |
if water_nodes==1 and lava_nodes==2 then production_level=75 load_step=45 end |
|
98 |
if water_nodes==2 and lava_nodes==2 then production_level=100 load_step=60 end |
|
99 |
if water_nodes==3 and lava_nodes==1 then production_level=25 load_step=15 end |
|
100 |
if water_nodes==1 and lava_nodes==3 then production_level=25 load_step=15 end |
|
101 |
|
|
102 |
if production_level>0 then |
|
103 |
if charge+load_step>max_charge then |
|
104 |
load_step=max_charge-charge |
|
105 |
end |
|
106 |
if load_step>0 then |
|
107 |
charge=charge+load_step |
|
108 |
meta:set_float("internal_EU_buffer",charge) |
|
109 |
end |
|
110 |
end |
|
111 |
|
|
112 |
local load = math.floor((charge/max_charge)*100) |
|
113 |
meta:set_string("formspec", |
|
114 |
"invsize[8,4;]".. |
|
115 |
"image[1,1;1,2;technic_power_meter_bg.png^[lowpart:".. |
|
116 |
(load)..":technic_power_meter_fg.png]".. |
|
117 |
"label[0,0;Geothermal Generator]".. |
|
118 |
"label[1,3;Power level]".. |
|
119 |
"label[4,0;Production at "..tostring(production_level).."%]" |
|
120 |
) |
|
121 |
|
|
122 |
if production_level>0 and minetest.env:get_node(pos).name=="technic:geothermal" then |
|
123 |
hacky_swap_node (pos,"technic:geothermal_active") |
|
124 |
return |
|
125 |
end |
|
126 |
if production_level==0 then hacky_swap_node (pos,"technic:geothermal") end |
|
127 |
end |
|
128 |
}) |
|
129 |
|
|
130 |
function check_node_around (pos) |
|
131 |
local node=minetest.env:get_node(pos) |
|
132 |
if node.name=="default:water_source" or node.name=="default:water_flowing" then return 1 end |
|
133 |
if node.name=="default:lava_source" or node.name=="default:lava_flowing" then return 2 end |
|
134 |
return 0 |
612349
|
135 |
end |
R |
136 |
|
|
137 |
register_LV_machine ("technic:geothermal","PR") |
|
138 |
register_LV_machine ("technic:geothermal_active","PR") |