mirror of
https://github.com/minetest-mods/technic.git
synced 2024-11-14 22:40:41 +01:00
added multi-tier geothermal
This commit is contained in:
parent
43ab974f1c
commit
dd185b228e
18
technic/machines/HV/geothermal.lua
Normal file
18
technic/machines/HV/geothermal.lua
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
|
||||||
|
--- An HV geothermal EU generator
|
||||||
|
--- Using hot lava and water this device can create energy from steam
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'technic:geothermal_hv 1',
|
||||||
|
recipe = {
|
||||||
|
{'technic:geothermal_mv', 'technic:geothermal_mv', 'technic:geothermal_mv'},
|
||||||
|
{'technic:carbon_plate', 'technic:hv_transformer', 'technic:composite_plate'},
|
||||||
|
{'', 'technic:hv_cable0', ''},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
technic.register_geothermal({tier="HV", power=100})
|
||||||
|
|
|
@ -11,6 +11,7 @@ dofile(path.."/battery_box.lua")
|
||||||
dofile(path.."/solar_array.lua")
|
dofile(path.."/solar_array.lua")
|
||||||
dofile(path.."/nuclear_reactor.lua")
|
dofile(path.."/nuclear_reactor.lua")
|
||||||
dofile(path.."/generator.lua")
|
dofile(path.."/generator.lua")
|
||||||
|
dofile(path.."/geothermal.lua")
|
||||||
|
|
||||||
-- Machines
|
-- Machines
|
||||||
dofile(path.."/quarry.lua")
|
dofile(path.."/quarry.lua")
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
-- A geothermal EU generator
|
|
||||||
-- Using hot lava and water this device can create energy from steam
|
|
||||||
-- The machine is only producing LV EUs and can thus not drive more advanced equipment
|
|
||||||
-- The output is a little more than the coal burning generator (max 300EUs)
|
|
||||||
|
|
||||||
minetest.register_alias("geothermal", "technic:geothermal")
|
|
||||||
|
|
||||||
local S = technic.getter
|
--- A geothermal EU generator
|
||||||
|
--- Using hot lava and water this device can create energy from steam
|
||||||
|
--- The machine is only producing LV EUs and can thus not drive more advanced equipment
|
||||||
|
--- The output is a little more than the coal burning generator (max 300EUs)
|
||||||
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'technic:geothermal',
|
output = 'technic:geothermal_lv 1',
|
||||||
recipe = {
|
recipe = {
|
||||||
{'technic:granite', 'default:diamond', 'technic:granite'},
|
{'technic:granite', 'default:diamond', 'technic:granite'},
|
||||||
{'technic:fine_copper_wire', 'technic:machine_casing', 'technic:fine_copper_wire'},
|
{'technic:fine_copper_wire', 'technic:machine_casing', 'technic:fine_copper_wire'},
|
||||||
|
@ -16,96 +15,7 @@ minetest.register_craft({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craftitem("technic:geothermal", {
|
technic.register_geothermal({tier="LV", power=10})
|
||||||
description = S("Geothermal %s Generator"):format("LV"),
|
|
||||||
})
|
|
||||||
|
|
||||||
local check_node_around = function(pos)
|
|
||||||
local node = minetest.get_node(pos)
|
|
||||||
if node.name == "default:water_source" or node.name == "default:water_flowing" then return 1 end
|
|
||||||
if node.name == "default:lava_source" or node.name == "default:lava_flowing" then return 2 end
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
|
|
||||||
local run = function(pos, node)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local water_nodes = 0
|
|
||||||
local lava_nodes = 0
|
|
||||||
local production_level = 0
|
|
||||||
local eu_supply = 0
|
|
||||||
|
|
||||||
-- Correct positioning is water on one side and lava on the other.
|
|
||||||
-- The two cannot be adjacent because the lava the turns into obsidian or rock.
|
|
||||||
-- To get to 100% production stack the water and lava one extra block down as well:
|
|
||||||
-- WGL (W=Water, L=Lava, G=the generator, |=an LV cable)
|
|
||||||
-- W|L
|
|
||||||
|
|
||||||
local positions = {
|
|
||||||
{x=pos.x+1, y=pos.y, z=pos.z},
|
|
||||||
{x=pos.x+1, y=pos.y-1, z=pos.z},
|
|
||||||
{x=pos.x-1, y=pos.y, z=pos.z},
|
|
||||||
{x=pos.x-1, y=pos.y-1, z=pos.z},
|
|
||||||
{x=pos.x, y=pos.y, z=pos.z+1},
|
|
||||||
{x=pos.x, y=pos.y-1, z=pos.z+1},
|
|
||||||
{x=pos.x, y=pos.y, z=pos.z-1},
|
|
||||||
{x=pos.x, y=pos.y-1, z=pos.z-1},
|
|
||||||
}
|
|
||||||
for _, p in pairs(positions) do
|
|
||||||
local check = check_node_around(p)
|
|
||||||
if check == 1 then water_nodes = water_nodes + 1 end
|
|
||||||
if check == 2 then lava_nodes = lava_nodes + 1 end
|
|
||||||
end
|
|
||||||
|
|
||||||
if water_nodes == 1 and lava_nodes == 1 then production_level = 25; eu_supply = 50 end
|
|
||||||
if water_nodes == 2 and lava_nodes == 1 then production_level = 50; eu_supply = 100 end
|
|
||||||
if water_nodes == 1 and lava_nodes == 2 then production_level = 75; eu_supply = 200 end
|
|
||||||
if water_nodes == 2 and lava_nodes == 2 then production_level = 100; eu_supply = 300 end
|
|
||||||
|
|
||||||
if production_level > 0 then
|
|
||||||
meta:set_int("LV_EU_supply", eu_supply)
|
|
||||||
end
|
|
||||||
|
|
||||||
meta:set_string("infotext",
|
|
||||||
S("Geothermal %s Generator"):format("LV").." ("..production_level.."%)")
|
|
||||||
|
|
||||||
if production_level > 0 and minetest.get_node(pos).name == "technic:geothermal" then
|
|
||||||
technic.swap_node (pos, "technic:geothermal_active")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if production_level == 0 then
|
|
||||||
technic.swap_node(pos, "technic:geothermal")
|
|
||||||
meta:set_int("LV_EU_supply", 0)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_node("technic:geothermal", {
|
|
||||||
description = S("Geothermal %s Generator"):format("LV"),
|
|
||||||
tiles = {"technic_geothermal_top.png", "technic_machine_bottom.png", "technic_geothermal_side.png",
|
|
||||||
"technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png"},
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1},
|
|
||||||
legacy_facedir_simple = true,
|
|
||||||
sounds = default.node_sound_wood_defaults(),
|
|
||||||
on_construct = function(pos)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
meta:set_string("infotext", S("Geothermal %s Generator"):format("LV"))
|
|
||||||
meta:set_int("LV_EU_supply", 0)
|
|
||||||
end,
|
|
||||||
technic_run = run,
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("technic:geothermal_active", {
|
|
||||||
description = S("Geothermal %s Generator"):format("LV"),
|
|
||||||
tiles = {"technic_geothermal_top_active.png", "technic_machine_bottom.png", "technic_geothermal_side.png",
|
|
||||||
"technic_geothermal_side.png", "technic_geothermal_side.png", "technic_geothermal_side.png"},
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1},
|
|
||||||
legacy_facedir_simple = true,
|
|
||||||
sounds = default.node_sound_wood_defaults(),
|
|
||||||
drop = "technic:geothermal",
|
|
||||||
technic_run = run,
|
|
||||||
})
|
|
||||||
|
|
||||||
technic.register_machine("LV", "technic:geothermal", technic.producer)
|
|
||||||
technic.register_machine("LV", "technic:geothermal_active", technic.producer)
|
|
||||||
|
|
||||||
|
minetest.register_alias("geothermal", "technic:geothermal_lv")
|
||||||
|
minetest.register_alias("technic:geothermal", "technic:geothermal_lv")
|
||||||
|
|
|
@ -13,6 +13,7 @@ dofile(path.."/solar_array.lua")
|
||||||
dofile(path.."/geothermal.lua")
|
dofile(path.."/geothermal.lua")
|
||||||
dofile(path.."/water_mill.lua")
|
dofile(path.."/water_mill.lua")
|
||||||
dofile(path.."/generator.lua")
|
dofile(path.."/generator.lua")
|
||||||
|
dofile(path.."/oldgeo.lua")
|
||||||
|
|
||||||
-- Machines
|
-- Machines
|
||||||
dofile(path.."/alloy_furnace.lua")
|
dofile(path.."/alloy_furnace.lua")
|
||||||
|
|
14
technic/machines/LV/oldgeo.lua
Normal file
14
technic/machines/LV/oldgeo.lua
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
|
||||||
|
|
||||||
|
--- old non tiered one
|
||||||
|
--- A geothermal EU generator
|
||||||
|
--- Using hot lava and water this device can create energy from steam
|
||||||
|
--- The machine is only producing LV EUs and can thus not drive more advanced equipment
|
||||||
|
--- The output is a little more than the coal burning generator (max 300EUs)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
technic.register_geothermal({tier="LV", power=10, old=true})
|
||||||
|
|
35
technic/machines/MV/geothermal.lua
Normal file
35
technic/machines/MV/geothermal.lua
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
|
||||||
|
|
||||||
|
--- An MV geothermal EU generator
|
||||||
|
--- Using hot lava and water this device can create energy from steam
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'technic:geothermal_mv 1',
|
||||||
|
recipe = {
|
||||||
|
{'technic:geothermal_lv', 'technic:geothermal_lv', 'technic:geothermal_lv'},
|
||||||
|
{'technic:carbon_steel_ingot', 'technic:mv_transformer', 'technic:carbon_steel_ingot'},
|
||||||
|
{'', 'technic:mv_cable0', ''},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'technic:geothermal_mv 1',
|
||||||
|
recipe = {
|
||||||
|
{'technic:geothermal', 'technic:geothermal', 'technic:geothermal'},
|
||||||
|
{'technic:carbon_steel_ingot', 'technic:mv_transformer', 'technic:carbon_steel_ingot'},
|
||||||
|
{'', 'technic:mv_cable0', ''},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
technic.register_geothermal({tier="MV", power=30})
|
||||||
|
|
||||||
|
-- compatibility alias for upgrading from old versions of technic
|
||||||
|
--minetest.register_alias("technic:geothermal_mv", "technic:geothermal_mv")
|
|
@ -13,6 +13,7 @@ if technic.config:get_bool("enable_wind_mill") then
|
||||||
end
|
end
|
||||||
dofile(path.."/generator.lua")
|
dofile(path.."/generator.lua")
|
||||||
dofile(path.."/solar_array.lua")
|
dofile(path.."/solar_array.lua")
|
||||||
|
dofile(path.."/geothermal.lua")
|
||||||
|
|
||||||
-- Machines
|
-- Machines
|
||||||
dofile(path.."/alloy_furnace.lua")
|
dofile(path.."/alloy_furnace.lua")
|
||||||
|
|
139
technic/machines/register/geothermal.lua
Normal file
139
technic/machines/register/geothermal.lua
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
local S = technic.getter
|
||||||
|
|
||||||
|
function technic.register_geothermal(data)
|
||||||
|
local tier = data.tier
|
||||||
|
local ltier = string.lower(tier)
|
||||||
|
|
||||||
|
local off_name = "technic:geothermal_"..ltier
|
||||||
|
local on_name = "technic:geothermal_active_"..ltier
|
||||||
|
|
||||||
|
local texture_name = "technic_"..ltier .. "_geothermal"
|
||||||
|
|
||||||
|
local groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, technic_machine=1}
|
||||||
|
local description = S("Geothermal %s Generator"):format(tier)
|
||||||
|
|
||||||
|
if data.old then
|
||||||
|
|
||||||
|
off_name = "technic:geothermal"
|
||||||
|
on_name = "technic:geothermal_active"
|
||||||
|
groups.not_in_creative_inventory=1
|
||||||
|
description = "Old "..description
|
||||||
|
texture_name = "technic_geothermal"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local check_node_around = function(pos)
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
if node.name == "default:water_source" or node.name == "default:water_flowing" then return 1 end
|
||||||
|
if node.name == "default:lava_source" or node.name == "default:lava_flowing" then return 2 end
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local run = function(pos, node)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local water_nodes = 0
|
||||||
|
local lava_nodes = 0
|
||||||
|
local production_level = 0
|
||||||
|
local eu_supply = 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- Correct positioning is water on one side and lava on the other.
|
||||||
|
-- The two cannot be adjacent because the lava the turns into obsidian or rock.
|
||||||
|
-- To get to 100% production stack the water and lava one extra block down as well:
|
||||||
|
-- WGL (W=Water, L=Lava, G=the generator, |=an LV cable)
|
||||||
|
-- W|L
|
||||||
|
|
||||||
|
local positions = {
|
||||||
|
{x=pos.x+1, y=pos.y, z=pos.z},
|
||||||
|
{x=pos.x+1, y=pos.y-1, z=pos.z},
|
||||||
|
{x=pos.x-1, y=pos.y, z=pos.z},
|
||||||
|
{x=pos.x-1, y=pos.y-1, z=pos.z},
|
||||||
|
{x=pos.x, y=pos.y, z=pos.z+1},
|
||||||
|
{x=pos.x, y=pos.y-1, z=pos.z+1},
|
||||||
|
{x=pos.x, y=pos.y, z=pos.z-1},
|
||||||
|
{x=pos.x, y=pos.y-1, z=pos.z-1},
|
||||||
|
}
|
||||||
|
for _, p in pairs(positions) do
|
||||||
|
local check = check_node_around(p)
|
||||||
|
if check == 1 then water_nodes = water_nodes + 1 end
|
||||||
|
if check == 2 then lava_nodes = lava_nodes + 1 end
|
||||||
|
end
|
||||||
|
|
||||||
|
if water_nodes == 1 and lava_nodes == 1 then production_level = 25; eu_supply = 5 * data.power end
|
||||||
|
if water_nodes == 2 and lava_nodes == 1 then production_level = 50; eu_supply = 10 * data.power end
|
||||||
|
if water_nodes == 1 and lava_nodes == 2 then production_level = 75; eu_supply = 20 * data.power end
|
||||||
|
if water_nodes == 2 and lava_nodes == 2 then production_level = 100; eu_supply = 30 * data.power end
|
||||||
|
|
||||||
|
if production_level > 0 then
|
||||||
|
meta:set_int(tier.."_EU_supply", eu_supply)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
meta:set_string("infotext", description.." ("..production_level.."%) "..technic.prettynum(eu_supply) .." EU")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if production_level > 0 and minetest.get_node(pos).name == off_name then
|
||||||
|
technic.swap_node (pos, on_name)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if production_level == 0 then
|
||||||
|
technic.swap_node(pos, off_name)
|
||||||
|
meta:set_int(tier.."_EU_supply", 0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if data.old then
|
||||||
|
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node(off_name, {
|
||||||
|
description = description,
|
||||||
|
tiles = {texture_name.."_top.png", "technic_machine_bottom.png", texture_name.."_side.png",
|
||||||
|
texture_name.."_side.png", texture_name.."_side.png", texture_name.."_side.png"},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = groups,
|
||||||
|
legacy_facedir_simple = true,
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
on_construct = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("infotext", S("Geothermal %s Generator"):format(tier))
|
||||||
|
meta:set_int(tier.."_EU_supply", 0)
|
||||||
|
end,
|
||||||
|
technic_run = run,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node(on_name, {
|
||||||
|
description = description,
|
||||||
|
tiles = {texture_name.."_top_active.png", "technic_machine_bottom.png", texture_name.."_side.png",
|
||||||
|
texture_name.."_side.png", texture_name.."_side.png", texture_name.."_side.png"},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1},
|
||||||
|
legacy_facedir_simple = true,
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
drop = off_name,
|
||||||
|
technic_run = run,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
technic.register_machine(tier, off_name, technic.producer)
|
||||||
|
technic.register_machine(tier, on_name, technic.producer)
|
||||||
|
|
||||||
|
|
||||||
|
end
|
|
@ -9,6 +9,7 @@ dofile(path.."/battery_box.lua")
|
||||||
-- Generators
|
-- Generators
|
||||||
dofile(path.."/solar_array.lua")
|
dofile(path.."/solar_array.lua")
|
||||||
dofile(path.."/generator.lua")
|
dofile(path.."/generator.lua")
|
||||||
|
dofile(path.."/geothermal.lua")
|
||||||
|
|
||||||
-- API for machines
|
-- API for machines
|
||||||
dofile(path.."/recipes.lua")
|
dofile(path.."/recipes.lua")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user