Adapt chemistry, electrolyser and fuel cell to networks
This commit is contained in:
parent
1d7db7943b
commit
104b1f179d
@ -3,7 +3,7 @@
|
|||||||
TechAge
|
TechAge
|
||||||
=======
|
=======
|
||||||
|
|
||||||
Copyright (C) 2019-2020 Joachim Stolberg
|
Copyright (C) 2019-2021 Joachim Stolberg
|
||||||
|
|
||||||
AGPL v3
|
AGPL v3
|
||||||
See LICENSE.txt for more information
|
See LICENSE.txt for more information
|
||||||
@ -17,8 +17,7 @@ local P2S = minetest.pos_to_string
|
|||||||
local M = minetest.get_meta
|
local M = minetest.get_meta
|
||||||
local S = techage.S
|
local S = techage.S
|
||||||
local Pipe = techage.LiquidPipe
|
local Pipe = techage.LiquidPipe
|
||||||
local networks = techage.networks
|
local liquid = networks.liquid
|
||||||
local liquid = techage.liquid
|
|
||||||
local recipes = techage.recipes
|
local recipes = techage.recipes
|
||||||
|
|
||||||
local Liquids = {} -- {hash(pos) = {name = outdir},...}
|
local Liquids = {} -- {hash(pos) = {name = outdir},...}
|
||||||
@ -27,26 +26,6 @@ local STANDBY_TICKS = 2
|
|||||||
local COUNTDOWN_TICKS = 3
|
local COUNTDOWN_TICKS = 3
|
||||||
local CYCLE_TIME = 10
|
local CYCLE_TIME = 10
|
||||||
|
|
||||||
-- to mark the pump source and destinstion node
|
|
||||||
local DebugCache = {}
|
|
||||||
|
|
||||||
local function set_starter_name(pos, clicker)
|
|
||||||
local key = minetest.hash_node_position(pos)
|
|
||||||
DebugCache[key] = {starter = clicker:get_player_name(), count = 10}
|
|
||||||
end
|
|
||||||
|
|
||||||
local function get_starter_name(pos)
|
|
||||||
local key = minetest.hash_node_position(pos)
|
|
||||||
local def = DebugCache[key]
|
|
||||||
if def then
|
|
||||||
def.count = (def.count or 0) - 1
|
|
||||||
if def.count > 0 then
|
|
||||||
return def.starter
|
|
||||||
end
|
|
||||||
DebugCache[key] = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function formspec(self, pos, nvm)
|
local function formspec(self, pos, nvm)
|
||||||
return "size[6,3.6]"..
|
return "size[6,3.6]"..
|
||||||
default.gui_bg..
|
default.gui_bg..
|
||||||
@ -199,8 +178,10 @@ local function dosing(pos, nvm, elapsed)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- inputs
|
-- inputs
|
||||||
local starter = get_starter_name(pos)
|
|
||||||
local taken = {}
|
local taken = {}
|
||||||
|
local mem = techage.get_mem(pos)
|
||||||
|
mem.dbg_cycles = (mem.dbg_cycles or 0) - 1
|
||||||
|
|
||||||
for _,item in pairs(recipe.input) do
|
for _,item in pairs(recipe.input) do
|
||||||
if item.name ~= "" then
|
if item.name ~= "" then
|
||||||
local outdir = liquids[item.name] or reload_liquids(pos)[item.name]
|
local outdir = liquids[item.name] or reload_liquids(pos)[item.name]
|
||||||
@ -210,7 +191,7 @@ local function dosing(pos, nvm, elapsed)
|
|||||||
untake(pos, taken)
|
untake(pos, taken)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local num = liquid.take(pos, Pipe, outdir, item.name, item.num, starter)
|
local num = liquid.take(pos, Pipe, outdir, item.name, item.num, mem.dbg_cycles > 0)
|
||||||
if num < item.num then
|
if num < item.num then
|
||||||
taken[#taken + 1] = {outdir = outdir, name = item.name, num = num}
|
taken[#taken + 1] = {outdir = outdir, name = item.name, num = num}
|
||||||
State:standby(pos, nvm)
|
State:standby(pos, nvm)
|
||||||
@ -267,19 +248,12 @@ local function on_receive_fields(pos, formname, fields, player)
|
|||||||
if not nvm.running then
|
if not nvm.running then
|
||||||
recipes.on_receive_fields(pos, formname, fields, player)
|
recipes.on_receive_fields(pos, formname, fields, player)
|
||||||
end
|
end
|
||||||
set_starter_name(pos, player)
|
local mem = techage.get_mem(pos)
|
||||||
|
mem.dbg_cycles = 5
|
||||||
State:state_button_event(pos, nvm, fields)
|
State:state_button_event(pos, nvm, fields)
|
||||||
M(pos):set_string("formspec", formspec(State, pos, nvm))
|
M(pos):set_string("formspec", formspec(State, pos, nvm))
|
||||||
end
|
end
|
||||||
|
|
||||||
local nworks = {
|
|
||||||
pipe2 = {
|
|
||||||
sides = techage.networks.AllSides, -- Pipe connection sides
|
|
||||||
ntype = "pump",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_node("techage:ta4_doser", {
|
minetest.register_node("techage:ta4_doser", {
|
||||||
description = S("TA4 Doser"),
|
description = S("TA4 Doser"),
|
||||||
tiles = {
|
tiles = {
|
||||||
@ -301,7 +275,7 @@ minetest.register_node("techage:ta4_doser", {
|
|||||||
Pipe:after_place_node(pos)
|
Pipe:after_place_node(pos)
|
||||||
end,
|
end,
|
||||||
tubelib2_on_update2 = function(pos, dir, tlib2, node)
|
tubelib2_on_update2 = function(pos, dir, tlib2, node)
|
||||||
liquid.update_network(pos, dir)
|
liquid.update_network(pos, dir, tlib2, node)
|
||||||
del_liquids(pos)
|
del_liquids(pos)
|
||||||
end,
|
end,
|
||||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
@ -312,7 +286,6 @@ minetest.register_node("techage:ta4_doser", {
|
|||||||
on_receive_fields = on_receive_fields,
|
on_receive_fields = on_receive_fields,
|
||||||
on_rightclick = on_rightclick,
|
on_rightclick = on_rightclick,
|
||||||
on_timer = node_timer,
|
on_timer = node_timer,
|
||||||
networks = nworks,
|
|
||||||
|
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
@ -340,13 +313,12 @@ minetest.register_node("techage:ta4_doser_on", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
tubelib2_on_update2 = function(pos, dir, tlib2, node)
|
tubelib2_on_update2 = function(pos, dir, tlib2, node)
|
||||||
liquid.update_network(pos, dir)
|
liquid.update_network(pos, dir, tlib2, node)
|
||||||
del_liquids(pos)
|
del_liquids(pos)
|
||||||
end,
|
end,
|
||||||
on_receive_fields = on_receive_fields,
|
on_receive_fields = on_receive_fields,
|
||||||
on_rightclick = on_rightclick,
|
on_rightclick = on_rightclick,
|
||||||
on_timer = node_timer,
|
on_timer = node_timer,
|
||||||
networks = nworks,
|
|
||||||
|
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
@ -356,15 +328,14 @@ minetest.register_node("techage:ta4_doser_on", {
|
|||||||
sounds = default.node_sound_metal_defaults(),
|
sounds = default.node_sound_metal_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
liquid.register_nodes({"techage:ta4_doser", "techage:ta4_doser_on"}, Pipe, "pump", nil, {})
|
||||||
|
|
||||||
techage.register_node({"techage:ta4_doser", "techage:ta4_doser_on"}, {
|
techage.register_node({"techage:ta4_doser", "techage:ta4_doser_on"}, {
|
||||||
on_recv_message = function(pos, src, topic, payload)
|
on_recv_message = function(pos, src, topic, payload)
|
||||||
return State:on_receive_message(pos, topic, payload)
|
return State:on_receive_message(pos, topic, payload)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
Pipe:add_secondary_node_names({"techage:ta4_doser", "techage:ta4_doser_on"})
|
|
||||||
|
|
||||||
|
|
||||||
if minetest.global_exists("unified_inventory") then
|
if minetest.global_exists("unified_inventory") then
|
||||||
unified_inventory.register_craft_type("ta4_doser", {
|
unified_inventory.register_craft_type("ta4_doser", {
|
||||||
description = S("TA4 Reactor"),
|
description = S("TA4 Reactor"),
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
local S = techage.S
|
local S = techage.S
|
||||||
local M = minetest.get_meta
|
local M = minetest.get_meta
|
||||||
local Pipe = techage.LiquidPipe
|
local Pipe = techage.LiquidPipe
|
||||||
local networks = techage.networks
|
local Cable = techage.ElectricCable
|
||||||
local liquid = techage.liquid
|
local liquid = networks.liquid
|
||||||
|
|
||||||
minetest.register_node("techage:ta4_reactor_fillerpipe", {
|
minetest.register_node("techage:ta4_reactor_fillerpipe", {
|
||||||
description = S("TA4 Reactor Filler Pipe"),
|
description = S("TA4 Reactor Filler Pipe"),
|
||||||
@ -48,9 +48,9 @@ minetest.register_node("techage:ta4_reactor_fillerpipe", {
|
|||||||
Pipe:after_place_node(pos1)
|
Pipe:after_place_node(pos1)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
tubelib2_on_update2 = function(pos, dir, tlib2, node)
|
-- tubelib2_on_update2 = function(pos, dir, tlib2, node)
|
||||||
liquid.update_network(pos)
|
-- liquid.update_network(pos, dir, tlib2, node)
|
||||||
end,
|
-- end,
|
||||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
Pipe:after_dig_node(pos)
|
Pipe:after_dig_node(pos)
|
||||||
end,
|
end,
|
||||||
@ -63,13 +63,6 @@ minetest.register_node("techage:ta4_reactor_fillerpipe", {
|
|||||||
groups = {cracky=2},
|
groups = {cracky=2},
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
sounds = default.node_sound_metal_defaults(),
|
sounds = default.node_sound_metal_defaults(),
|
||||||
|
|
||||||
networks = {
|
|
||||||
pipe2 = {
|
|
||||||
sides = {U = 1}, -- Pipe connection sides
|
|
||||||
ntype = "tank",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
local function stand_cmnd(pos, cmnd, payload)
|
local function stand_cmnd(pos, cmnd, payload)
|
||||||
@ -117,6 +110,8 @@ techage.register_node({"techage:ta4_reactor_fillerpipe"}, {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
liquid.register_nodes({"techage:ta4_reactor_fillerpipe"}, Pipe, "tank", {"U"}, {})
|
||||||
|
|
||||||
local function formspec()
|
local function formspec()
|
||||||
local title = S("TA4 Reactor")
|
local title = S("TA4 Reactor")
|
||||||
return "size[8,6]"..
|
return "size[8,6]"..
|
||||||
@ -176,8 +171,6 @@ minetest.register_node("techage:ta4_reactor", {
|
|||||||
sounds = default.node_sound_metal_defaults(),
|
sounds = default.node_sound_metal_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
Pipe:add_secondary_node_names({"techage:ta4_reactor_fillerpipe"})
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'techage:ta4_reactor',
|
output = 'techage:ta4_reactor',
|
||||||
recipe = {
|
recipe = {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
TechAge
|
TechAge
|
||||||
=======
|
=======
|
||||||
|
|
||||||
Copyright (C) 2019-2020 Joachim Stolberg
|
Copyright (C) 2019-2021 Joachim Stolberg
|
||||||
|
|
||||||
AGPL v3
|
AGPL v3
|
||||||
See LICENSE.txt for more information
|
See LICENSE.txt for more information
|
||||||
@ -15,13 +15,12 @@
|
|||||||
local S = techage.S
|
local S = techage.S
|
||||||
local M = minetest.get_meta
|
local M = minetest.get_meta
|
||||||
local Cable = techage.ElectricCable
|
local Cable = techage.ElectricCable
|
||||||
local power = techage.power
|
|
||||||
local Pipe = techage.LiquidPipe
|
local Pipe = techage.LiquidPipe
|
||||||
local networks = techage.networks
|
local power = networks.power
|
||||||
local liquid = techage.liquid
|
local liquid = networks.liquid
|
||||||
|
|
||||||
local PWR_NEEDED = 8
|
local PWR_NEEDED = 8
|
||||||
local CYCLE_TIME = 4
|
local CYCLE_TIME = 2
|
||||||
|
|
||||||
local function play_sound(pos)
|
local function play_sound(pos)
|
||||||
local mem = techage.get_mem(pos)
|
local mem = techage.get_mem(pos)
|
||||||
@ -49,18 +48,18 @@ local function on_power(pos)
|
|||||||
M(pos):set_string("infotext", S("on"))
|
M(pos):set_string("infotext", S("on"))
|
||||||
play_sound(pos)
|
play_sound(pos)
|
||||||
local nvm = techage.get_nvm(pos)
|
local nvm = techage.get_nvm(pos)
|
||||||
nvm.has_power = true
|
nvm.running = true
|
||||||
end
|
end
|
||||||
|
|
||||||
local function on_nopower(pos)
|
local function on_nopower(pos)
|
||||||
M(pos):set_string("infotext", S("no power"))
|
M(pos):set_string("infotext", S("no power"))
|
||||||
stop_sound(pos)
|
stop_sound(pos)
|
||||||
local nvm = techage.get_nvm(pos)
|
local nvm = techage.get_nvm(pos)
|
||||||
nvm.has_power = false
|
nvm.running = false
|
||||||
end
|
end
|
||||||
|
|
||||||
local function is_running(pos, nvm)
|
local function is_running(pos, nvm)
|
||||||
return nvm.has_power
|
return nvm.running
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("techage:ta4_reactor_stand", {
|
minetest.register_node("techage:ta4_reactor_stand", {
|
||||||
@ -103,15 +102,21 @@ minetest.register_node("techage:ta4_reactor_stand", {
|
|||||||
Pipe:after_place_node(pos)
|
Pipe:after_place_node(pos)
|
||||||
Cable:after_place_node(pos)
|
Cable:after_place_node(pos)
|
||||||
end,
|
end,
|
||||||
tubelib2_on_update2 = function(pos, dir, tlib2, node)
|
-- tubelib2_on_update2 = function(pos, dir, tlib2, node)
|
||||||
if tlib2.tube_type == "ele1" then
|
-- if tlib2.tube_type == "ele1" then
|
||||||
power.update_network(pos, dir, tlib2)
|
-- power.update_network(pos, dir, tlib2, node)
|
||||||
else
|
-- else
|
||||||
liquid.update_network(pos, dir, tlib2)
|
-- liquid.update_network(pos, dir, tlib2, node)
|
||||||
end
|
-- end
|
||||||
end,
|
-- end,
|
||||||
on_timer = function(pos, elapsed)
|
on_timer = function(pos, elapsed)
|
||||||
power.consumer_alive(pos, Cable, CYCLE_TIME)
|
local nvm = techage.get_nvm(pos)
|
||||||
|
local consumed = power.consume_power(pos, Cable, nil, PWR_NEEDED)
|
||||||
|
if not nvm.running and consumed == PWR_NEEDED then
|
||||||
|
on_power(pos)
|
||||||
|
elseif nvm.running and consumed < PWR_NEEDED then
|
||||||
|
on_nopower(pos)
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
after_dig_node = function(pos, oldnode)
|
after_dig_node = function(pos, oldnode)
|
||||||
@ -127,21 +132,6 @@ minetest.register_node("techage:ta4_reactor_stand", {
|
|||||||
groups = {cracky=2},
|
groups = {cracky=2},
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
sounds = default.node_sound_metal_defaults(),
|
sounds = default.node_sound_metal_defaults(),
|
||||||
|
|
||||||
networks = {
|
|
||||||
pipe2 = {
|
|
||||||
sides = {R=1},
|
|
||||||
ntype = "pump",
|
|
||||||
},
|
|
||||||
ele1 = {
|
|
||||||
sides = {L=1},
|
|
||||||
ntype = "con1",
|
|
||||||
on_power = on_power,
|
|
||||||
on_nopower = on_nopower,
|
|
||||||
nominal = PWR_NEEDED,
|
|
||||||
is_running = is_running,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
-- controlled by the fillerpipe
|
-- controlled by the fillerpipe
|
||||||
@ -149,21 +139,19 @@ techage.register_node({"techage:ta4_reactor_stand"}, {
|
|||||||
on_transfer = function(pos, in_dir, topic, payload)
|
on_transfer = function(pos, in_dir, topic, payload)
|
||||||
local nvm = techage.get_nvm(pos)
|
local nvm = techage.get_nvm(pos)
|
||||||
if topic == "power" then
|
if topic == "power" then
|
||||||
return nvm.has_power or power.power_available(pos, Cable)
|
return nvm.running or power.power_available(pos, Cable)
|
||||||
elseif topic == "output" then
|
elseif topic == "output" then
|
||||||
local outdir = M(pos):get_int("outdir")
|
local outdir = M(pos):get_int("outdir")
|
||||||
return liquid.put(pos, Pipe, outdir, payload.name, payload.amount, payload.player_name)
|
return liquid.put(pos, Pipe, outdir, payload.name, payload.amount, payload.player_name)
|
||||||
elseif topic == "can_start" then
|
elseif topic == "can_start" then
|
||||||
return power.power_available(pos, Cable)
|
return power.power_available(pos, Cable)
|
||||||
elseif topic == "start" then
|
elseif topic == "start" then
|
||||||
nvm.has_power = false
|
nvm.running = false
|
||||||
power.consumer_start(pos, Cable, CYCLE_TIME)
|
|
||||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||||
M(pos):set_string("infotext", "...")
|
M(pos):set_string("infotext", "...")
|
||||||
return true
|
return true
|
||||||
elseif topic == "stop" then
|
elseif topic == "stop" then
|
||||||
nvm.has_power = false
|
nvm.has_power = false
|
||||||
power.consumer_stop(pos, Cable)
|
|
||||||
stop_sound(pos)
|
stop_sound(pos)
|
||||||
minetest.get_node_timer(pos):stop()
|
minetest.get_node_timer(pos):stop()
|
||||||
M(pos):set_string("infotext", S("off"))
|
M(pos):set_string("infotext", S("off"))
|
||||||
@ -194,9 +182,9 @@ minetest.register_node("techage:ta4_reactor_base", {
|
|||||||
M(pos):set_int("outdir", networks.side_to_outdir(pos, "R"))
|
M(pos):set_int("outdir", networks.side_to_outdir(pos, "R"))
|
||||||
Pipe:after_place_node(pos)
|
Pipe:after_place_node(pos)
|
||||||
end,
|
end,
|
||||||
tubelib2_on_update2 = function(pos, dir, tlib2, node)
|
-- tubelib2_on_update2 = function(pos, dir, tlib2, node)
|
||||||
liquid.update_network(pos, dir, tlib2)
|
-- liquid.update_network(pos, dir, tlib2, node)
|
||||||
end,
|
-- end,
|
||||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
Pipe:after_dig_node(pos)
|
Pipe:after_dig_node(pos)
|
||||||
end,
|
end,
|
||||||
@ -206,21 +194,11 @@ minetest.register_node("techage:ta4_reactor_base", {
|
|||||||
groups = {cracky=2},
|
groups = {cracky=2},
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
|
||||||
networks = {
|
|
||||||
pipe2 = {
|
|
||||||
sides = {R=1}, -- Pipe connection sides
|
|
||||||
ntype = "pump",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
Pipe:add_secondary_node_names({
|
liquid.register_nodes({"techage:ta4_reactor_base"}, Pipe, "pump", {"R"}, {})
|
||||||
"techage:ta4_reactor_base",
|
liquid.register_nodes({"techage:ta4_reactor_stand"}, Pipe, "pump", {"R"}, {})
|
||||||
"techage:ta4_reactor_stand",
|
power.register_nodes({"techage:ta4_reactor_stand"}, Cable, "con", {"L"})
|
||||||
})
|
|
||||||
|
|
||||||
Cable:add_secondary_node_names({"techage:ta4_reactor_stand"})
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'techage:ta4_reactor_stand',
|
output = 'techage:ta4_reactor_stand',
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
TechAge
|
TechAge
|
||||||
=======
|
=======
|
||||||
|
|
||||||
Copyright (C) 2019-2020 Joachim Stolberg
|
Copyright (C) 2019-2021 Joachim Stolberg
|
||||||
|
|
||||||
AGPL v3
|
AGPL v3
|
||||||
See LICENSE.txt for more information
|
See LICENSE.txt for more information
|
||||||
@ -17,10 +17,9 @@ local M = minetest.get_meta
|
|||||||
local S = techage.S
|
local S = techage.S
|
||||||
|
|
||||||
local Cable = techage.ElectricCable
|
local Cable = techage.ElectricCable
|
||||||
local power = techage.power
|
local power = networks.power
|
||||||
local Pipe = techage.LiquidPipe
|
local Pipe = techage.LiquidPipe
|
||||||
local liquid = techage.liquid
|
local liquid = networks.liquid
|
||||||
local networks = techage.networks
|
|
||||||
|
|
||||||
local CYCLE_TIME = 2
|
local CYCLE_TIME = 2
|
||||||
local STANDBY_TICKS = 3
|
local STANDBY_TICKS = 3
|
||||||
@ -28,6 +27,10 @@ local PWR_NEEDED = 35
|
|||||||
local PWR_UNITS_PER_HYDROGEN_ITEM = 80
|
local PWR_UNITS_PER_HYDROGEN_ITEM = 80
|
||||||
local CAPACITY = 200
|
local CAPACITY = 200
|
||||||
|
|
||||||
|
local function evaluate_percent(s)
|
||||||
|
return (tonumber(s:sub(1, -2)) or 0) / 100
|
||||||
|
end
|
||||||
|
|
||||||
local function formspec(self, pos, nvm)
|
local function formspec(self, pos, nvm)
|
||||||
local amount = (nvm.liquid and nvm.liquid.amount) or 0
|
local amount = (nvm.liquid and nvm.liquid.amount) or 0
|
||||||
local lqd_name = (nvm.liquid and nvm.liquid.name) or "techage:liquid"
|
local lqd_name = (nvm.liquid and nvm.liquid.name) or "techage:liquid"
|
||||||
@ -36,31 +39,41 @@ local function formspec(self, pos, nvm)
|
|||||||
arrow = "image[3,1.5;1,1;techage_form_arrow_fg.png^[transformR270]"
|
arrow = "image[3,1.5;1,1;techage_form_arrow_fg.png^[transformR270]"
|
||||||
end
|
end
|
||||||
if amount > 0 then
|
if amount > 0 then
|
||||||
lqd_name = lqd_name.." "..amount
|
lqd_name = lqd_name .. " " .. amount
|
||||||
end
|
end
|
||||||
return "size[6,4]"..
|
return "size[6,4]" ..
|
||||||
default.gui_bg..
|
default.gui_bg ..
|
||||||
default.gui_bg_img..
|
default.gui_bg_img ..
|
||||||
default.gui_slots..
|
default.gui_slots ..
|
||||||
"box[0,-0.1;5.8,0.5;#c6e8ff]"..
|
"box[0,-0.1;5.8,0.5;#c6e8ff]" ..
|
||||||
"label[2.5,-0.1;"..minetest.colorize( "#000000", S("Electrolyzer")).."]"..
|
"label[0.2,-0.1;" .. minetest.colorize( "#000000", S("Electrolyzer")) .. "]" ..
|
||||||
techage.power.formspec_label_bar(pos, 0.1, 0.8, S("Electricity"), PWR_NEEDED, nvm.taken)..
|
techage.formspec_power_bar(pos, 0.1, 0.8, S("Electricity"), nvm.taken, PWR_NEEDED) ..
|
||||||
arrow..
|
arrow ..
|
||||||
"image_button[3,2.5;1,1;".. self:get_state_button_image(nvm) ..";state_button;]"..
|
"image_button[3,2.5;1,1;" .. self:get_state_button_image(nvm) .. ";state_button;]" ..
|
||||||
"tooltip[3,2.5;1,1;"..self:get_state_tooltip(nvm).."]"..
|
"tooltip[3,2.5;1,1;" .. self:get_state_tooltip(nvm) .. "]" ..
|
||||||
techage.item_image(4.5,2, lqd_name)
|
techage.item_image(4.5,2, lqd_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function can_start(pos, nvm, state)
|
||||||
|
nvm.liquid = nvm.liquid or {}
|
||||||
|
nvm.liquid.amount = nvm.liquid.amount or 0
|
||||||
|
|
||||||
|
if nvm.liquid.amount < CAPACITY then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return S("Storage full")
|
||||||
|
end
|
||||||
|
|
||||||
local function start_node(pos, nvm, state)
|
local function start_node(pos, nvm, state)
|
||||||
nvm.running = true
|
nvm.running = true
|
||||||
nvm.taken = 0
|
nvm.taken = 0
|
||||||
power.consumer_start(pos, Cable, CYCLE_TIME)
|
nvm.reduction = evaluate_percent(M(pos):get_string("reduction"))
|
||||||
|
nvm.turnoff = evaluate_percent(M(pos):get_string("turnoff"))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function stop_node(pos, nvm, state)
|
local function stop_node(pos, nvm, state)
|
||||||
nvm.running = false
|
nvm.running = false
|
||||||
nvm.taken = 0
|
nvm.taken = 0
|
||||||
power.consumer_stop(pos, Cable)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local State = techage.NodeStates:new({
|
local State = techage.NodeStates:new({
|
||||||
@ -70,26 +83,11 @@ local State = techage.NodeStates:new({
|
|||||||
standby_ticks = STANDBY_TICKS,
|
standby_ticks = STANDBY_TICKS,
|
||||||
formspec_func = formspec,
|
formspec_func = formspec,
|
||||||
infotext_name = S("TA4 Electrolyzer"),
|
infotext_name = S("TA4 Electrolyzer"),
|
||||||
|
can_start = can_start,
|
||||||
start_node = start_node,
|
start_node = start_node,
|
||||||
stop_node = stop_node,
|
stop_node = stop_node,
|
||||||
})
|
})
|
||||||
|
|
||||||
local function on_power(pos)
|
|
||||||
local nvm = techage.get_nvm(pos)
|
|
||||||
State:start(pos, nvm)
|
|
||||||
nvm.running = true
|
|
||||||
end
|
|
||||||
|
|
||||||
local function on_nopower(pos)
|
|
||||||
local nvm = techage.get_nvm(pos)
|
|
||||||
State:stop(pos, nvm)
|
|
||||||
nvm.running = false
|
|
||||||
end
|
|
||||||
|
|
||||||
local function is_running(pos, nvm)
|
|
||||||
return nvm.running
|
|
||||||
end
|
|
||||||
|
|
||||||
local function generating(pos, nvm)
|
local function generating(pos, nvm)
|
||||||
nvm.num_pwr_units = nvm.num_pwr_units or 0
|
nvm.num_pwr_units = nvm.num_pwr_units or 0
|
||||||
nvm.countdown = nvm.countdown or 0
|
nvm.countdown = nvm.countdown or 0
|
||||||
@ -106,16 +104,32 @@ end
|
|||||||
|
|
||||||
-- converts power into hydrogen
|
-- converts power into hydrogen
|
||||||
local function node_timer(pos, elapsed)
|
local function node_timer(pos, elapsed)
|
||||||
|
local meta = M(pos)
|
||||||
local nvm = techage.get_nvm(pos)
|
local nvm = techage.get_nvm(pos)
|
||||||
nvm.liquid = nvm.liquid or {}
|
nvm.liquid = nvm.liquid or {}
|
||||||
nvm.liquid.amount = nvm.liquid.amount or 0
|
nvm.liquid.amount = nvm.liquid.amount or 0
|
||||||
|
|
||||||
if nvm.liquid.amount < CAPACITY then
|
if nvm.liquid.amount < CAPACITY then
|
||||||
nvm.taken = power.consumer_alive(pos, Cable, CYCLE_TIME)
|
local in_dir = meta:get_int("in_dir")
|
||||||
generating(pos, nvm)
|
local curr_load = power.get_storage_load(pos, Cable, in_dir, 1)
|
||||||
State:keep_running(pos, nvm, 1) -- TODO warum hier 1 und nicht COUNTDOWN_TICKS?
|
if curr_load > (nvm.turnoff or 0) then
|
||||||
|
local to_be_taken = PWR_NEEDED * (nvm.reduction or 1)
|
||||||
|
nvm.taken = power.consume_power(pos, Cable, in_dir, to_be_taken) or 0
|
||||||
|
generating(pos, nvm)
|
||||||
|
if not nvm.running and nvm.taken == to_be_taken then
|
||||||
|
State:start(pos, nvm)
|
||||||
|
elseif nvm.running and nvm.taken < to_be_taken then
|
||||||
|
State:nopower(pos, nvm)
|
||||||
|
else
|
||||||
|
State:keep_running(pos, nvm, 1)
|
||||||
|
end
|
||||||
|
elseif curr_load == 0 then
|
||||||
|
State:nopower(pos, nvm)
|
||||||
|
else
|
||||||
|
State:standby(pos, nvm, S("Turnoff point reached"))
|
||||||
|
end
|
||||||
else
|
else
|
||||||
State:blocked(pos, nvm, S("full"))
|
State:blocked(pos, nvm, S("Storage full"))
|
||||||
power.consumer_stop(pos, Cable)
|
power.consumer_stop(pos, Cable)
|
||||||
end
|
end
|
||||||
if techage.is_activeformspec(pos) then
|
if techage.is_activeformspec(pos) then
|
||||||
@ -129,6 +143,7 @@ local function on_receive_fields(pos, formname, fields, player)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
local nvm = techage.get_nvm(pos)
|
local nvm = techage.get_nvm(pos)
|
||||||
|
techage.set_activeformspec(pos, player)
|
||||||
State:state_button_event(pos, nvm, fields)
|
State:state_button_event(pos, nvm, fields)
|
||||||
M(pos):set_string("formspec", formspec(State, pos, nvm))
|
M(pos):set_string("formspec", formspec(State, pos, nvm))
|
||||||
end
|
end
|
||||||
@ -165,44 +180,30 @@ local function put(pos, indir, name, amount)
|
|||||||
return leftover
|
return leftover
|
||||||
end
|
end
|
||||||
|
|
||||||
local function tubelib2_on_update2(pos, outdir, tlib2, node)
|
local tool_config = {
|
||||||
if tlib2.tube_type == "pipe2" then
|
{
|
||||||
liquid.update_network(pos, outdir, tlib2)
|
type = "const",
|
||||||
else
|
name = "needed",
|
||||||
power.update_network(pos, outdir, tlib2)
|
label = S("Needed power [ku]"),
|
||||||
end
|
tooltip = S("The maximum amount of power\nthe consumer can consume"),
|
||||||
end
|
value = PWR_NEEDED,
|
||||||
|
|
||||||
local netw_def = {
|
|
||||||
pipe2 = {
|
|
||||||
sides = {R = 1}, -- Pipe connection sides
|
|
||||||
ntype = "tank",
|
|
||||||
},
|
},
|
||||||
ele1 = {
|
{
|
||||||
sides = {L = 1}, -- Cable connection sides
|
type = "dropdown",
|
||||||
ntype = "con2",
|
choices = "20%,40%,60%,80%,100%",
|
||||||
on_power = on_power,
|
name = "reduction",
|
||||||
on_nopower = on_nopower,
|
label = S("Power reduction"),
|
||||||
nominal = PWR_NEEDED,
|
tooltip = S("The reduced amount of power\nthe consumer should consume"),
|
||||||
is_running = is_running,
|
},
|
||||||
|
{
|
||||||
|
type = "dropdown",
|
||||||
|
choices = "0%,20%,40%,60%,80%",
|
||||||
|
name = "turnoff",
|
||||||
|
label = S("Turnoff point"),
|
||||||
|
tooltip = S("If the load of the storage system\nreaches the configured value,\nthe consumer will be switched off"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local liquid_def = {
|
|
||||||
capa = CAPACITY,
|
|
||||||
peek = liquid.srv_peek,
|
|
||||||
put = put,
|
|
||||||
untake = put,
|
|
||||||
take = function(pos, indir, name, amount)
|
|
||||||
amount, name = liquid.srv_take(pos, indir, name, amount)
|
|
||||||
if techage.is_activeformspec(pos) then
|
|
||||||
local nvm = techage.get_nvm(pos)
|
|
||||||
M(pos):set_string("formspec", formspec(State, pos, nvm))
|
|
||||||
end
|
|
||||||
return amount, name
|
|
||||||
end
|
|
||||||
}
|
|
||||||
|
|
||||||
minetest.register_node("techage:ta4_electrolyzer", {
|
minetest.register_node("techage:ta4_electrolyzer", {
|
||||||
description = S("TA4 Electrolyzer"),
|
description = S("TA4 Electrolyzer"),
|
||||||
tiles = {
|
tiles = {
|
||||||
@ -224,10 +225,7 @@ minetest.register_node("techage:ta4_electrolyzer", {
|
|||||||
|
|
||||||
after_place_node = after_place_node,
|
after_place_node = after_place_node,
|
||||||
after_dig_node = after_dig_node,
|
after_dig_node = after_dig_node,
|
||||||
tubelib2_on_update2 = tubelib2_on_update2,
|
|
||||||
on_punch = liquid.on_punch,
|
on_punch = liquid.on_punch,
|
||||||
networks = netw_def,
|
|
||||||
liquid = liquid_def,
|
|
||||||
on_receive_fields = on_receive_fields,
|
on_receive_fields = on_receive_fields,
|
||||||
on_timer = node_timer,
|
on_timer = node_timer,
|
||||||
on_rightclick = on_rightclick,
|
on_rightclick = on_rightclick,
|
||||||
@ -236,6 +234,7 @@ minetest.register_node("techage:ta4_electrolyzer", {
|
|||||||
groups = {cracky=2, crumbly=2, choppy=2},
|
groups = {cracky=2, crumbly=2, choppy=2},
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
|
ta3_formspec = tool_config,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("techage:ta4_electrolyzer_on", {
|
minetest.register_node("techage:ta4_electrolyzer_on", {
|
||||||
@ -268,9 +267,6 @@ minetest.register_node("techage:ta4_electrolyzer_on", {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
tubelib2_on_update2 = tubelib2_on_update2,
|
|
||||||
networks = netw_def,
|
|
||||||
liquid = liquid_def,
|
|
||||||
on_receive_fields = on_receive_fields,
|
on_receive_fields = on_receive_fields,
|
||||||
on_punch = liquid.on_punch,
|
on_punch = liquid.on_punch,
|
||||||
on_timer = node_timer,
|
on_timer = node_timer,
|
||||||
@ -283,10 +279,47 @@ minetest.register_node("techage:ta4_electrolyzer_on", {
|
|||||||
diggable = false,
|
diggable = false,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
light_source = 6,
|
light_source = 6,
|
||||||
|
ta3_formspec = tool_config,
|
||||||
})
|
})
|
||||||
|
|
||||||
Cable:add_secondary_node_names({"techage:ta4_electrolyzer", "techage:ta4_electrolyzer_on"})
|
local liquid_def = {
|
||||||
Pipe:add_secondary_node_names({"techage:ta4_electrolyzer", "techage:ta4_electrolyzer_on"})
|
capa = CAPACITY,
|
||||||
|
peek = function(pos)
|
||||||
|
local nvm = techage.get_nvm(pos)
|
||||||
|
return liquid.srv_peek(nvm)
|
||||||
|
end,
|
||||||
|
put = function(pos, indir, name, amount)
|
||||||
|
local nvm = techage.get_nvm(pos)
|
||||||
|
local leftover = liquid.srv_put(nvm, name, amount, CAPACITY)
|
||||||
|
if techage.is_activeformspec(pos) then
|
||||||
|
local nvm = techage.get_nvm(pos)
|
||||||
|
M(pos):set_string("formspec", formspec(State, pos, nvm))
|
||||||
|
end
|
||||||
|
return leftover
|
||||||
|
end,
|
||||||
|
take = function(pos, indir, name, amount)
|
||||||
|
local nvm = techage.get_nvm(pos)
|
||||||
|
amount, name = liquid.srv_take(nvm, name, amount)
|
||||||
|
if techage.is_activeformspec(pos) then
|
||||||
|
local nvm = techage.get_nvm(pos)
|
||||||
|
M(pos):set_string("formspec", formspec(State, pos, nvm))
|
||||||
|
end
|
||||||
|
return amount, name
|
||||||
|
end,
|
||||||
|
untake = function(pos, indir, name, amount)
|
||||||
|
local nvm = techage.get_nvm(pos)
|
||||||
|
local leftover = liquid.srv_put(nvm, name, amount, CAPACITY)
|
||||||
|
if techage.is_activeformspec(pos) then
|
||||||
|
local nvm = techage.get_nvm(pos)
|
||||||
|
M(pos):set_string("formspec", formspec(State, pos, nvm))
|
||||||
|
end
|
||||||
|
return leftover
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
liquid.register_nodes({"techage:ta4_electrolyzer", "techage:ta4_electrolyzer_on"}, Pipe, "tank", {"R"}, liquid_def)
|
||||||
|
power.register_nodes({"techage:ta4_electrolyzer", "techage:ta4_electrolyzer_on"}, Cable, "con", {"L"})
|
||||||
|
|
||||||
techage.register_node({"techage:ta4_electrolyzer", "techage:ta4_electrolyzer_on"}, {
|
techage.register_node({"techage:ta4_electrolyzer", "techage:ta4_electrolyzer_on"}, {
|
||||||
on_recv_message = function(pos, src, topic, payload)
|
on_recv_message = function(pos, src, topic, payload)
|
||||||
local nvm = techage.get_nvm(pos)
|
local nvm = techage.get_nvm(pos)
|
||||||
@ -298,6 +331,13 @@ techage.register_node({"techage:ta4_electrolyzer", "techage:ta4_electrolyzer_on"
|
|||||||
return State:on_receive_message(pos, topic, payload)
|
return State:on_receive_message(pos, topic, payload)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
on_node_load = function(pos, node)
|
||||||
|
local meta = M(pos)
|
||||||
|
if not meta:contains("reduction") then
|
||||||
|
meta:set_string("reduction", "100%")
|
||||||
|
meta:set_string("turnoff", "0%")
|
||||||
|
end
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
TechAge
|
TechAge
|
||||||
=======
|
=======
|
||||||
|
|
||||||
Copyright (C) 2019-2020 Joachim Stolberg
|
Copyright (C) 2019-2021 Joachim Stolberg
|
||||||
|
|
||||||
AGPL v3
|
AGPL v3
|
||||||
See LICENSE.txt for more information
|
See LICENSE.txt for more information
|
||||||
@ -17,33 +17,17 @@ local M = minetest.get_meta
|
|||||||
local S = techage.S
|
local S = techage.S
|
||||||
|
|
||||||
local Cable = techage.ElectricCable
|
local Cable = techage.ElectricCable
|
||||||
local power = techage.power
|
local power = networks.power
|
||||||
local Pipe = techage.LiquidPipe
|
local Pipe = techage.LiquidPipe
|
||||||
local liquid = techage.liquid
|
local liquid = networks.liquid
|
||||||
local networks = techage.networks
|
local control = networks.control
|
||||||
|
|
||||||
local CYCLE_TIME = 2
|
local CYCLE_TIME = 2
|
||||||
local STANDBY_TICKS = 4
|
local STANDBY_TICKS = 4
|
||||||
local PWR_CAPA = 34
|
local PWR_PERF = 34
|
||||||
local PWR_UNITS_PER_HYDROGEN_ITEM = 75
|
local PWR_UNITS_PER_HYDROGEN_ITEM = 75
|
||||||
local CAPACITY = 100
|
local CAPACITY = 100
|
||||||
|
|
||||||
local States = {}
|
|
||||||
local STATE = function(pos) return States[techage.get_node_lvm(pos).name] end
|
|
||||||
|
|
||||||
local function is_gen1(nvm)
|
|
||||||
if not nvm.running then
|
|
||||||
local is_gen1 = dump(nvm.is_gen1 or false)
|
|
||||||
return "checkbox[0.3,0.5;is_gen1;"..S("Cat. 1 generator")..";"..is_gen1.."]"..
|
|
||||||
"tooltip[0.3,0.5;1,1;"..S("If set, fuelcell will work\nas cat. 1 generator")..";#0C3D32;#FFFFFF]"
|
|
||||||
end
|
|
||||||
if nvm.is_gen1 then
|
|
||||||
return "label[0.5,0.7;"..S("Cat. 1 generator").."]"
|
|
||||||
else
|
|
||||||
return "label[0.5,0.7;"..S("Cat. 2 generator").."]"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function formspec(self, pos, nvm)
|
local function formspec(self, pos, nvm)
|
||||||
local amount = (nvm.liquid and nvm.liquid.amount) or 0
|
local amount = (nvm.liquid and nvm.liquid.amount) or 0
|
||||||
local lqd_name = (nvm.liquid and nvm.liquid.name) or "techage:liquid"
|
local lqd_name = (nvm.liquid and nvm.liquid.name) or "techage:liquid"
|
||||||
@ -59,40 +43,28 @@ local function formspec(self, pos, nvm)
|
|||||||
default.gui_bg_img..
|
default.gui_bg_img..
|
||||||
default.gui_slots..
|
default.gui_slots..
|
||||||
"box[0,-0.1;5.8,0.5;#c6e8ff]"..
|
"box[0,-0.1;5.8,0.5;#c6e8ff]"..
|
||||||
"label[2.5,-0.1;"..minetest.colorize( "#000000", S("Fuel Cell")).."]"..
|
"label[0.2,-0.1;"..minetest.colorize( "#000000", S("Fuel Cell")).."]"..
|
||||||
techage.item_image(0.5,2, lqd_name)..
|
techage.item_image(0.5,2, lqd_name)..
|
||||||
arrow..
|
arrow..
|
||||||
is_gen1(nvm)..
|
|
||||||
"image_button[2,2.5;1,1;".. self:get_state_button_image(nvm) ..";state_button;]"..
|
"image_button[2,2.5;1,1;".. self:get_state_button_image(nvm) ..";state_button;]"..
|
||||||
"tooltip[2,2.5;1,1;"..self:get_state_tooltip(nvm).."]"..
|
"tooltip[2,2.5;1,1;"..self:get_state_tooltip(nvm).."]"..
|
||||||
techage.power.formspec_label_bar(pos, 3.5, 0.8, S("Electricity"), PWR_CAPA, nvm.given)
|
techage.formspec_power_bar(pos, 3.5, 0.8, S("Electricity"), nvm.provided, PWR_PERF)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function start_node(pos, nvm, state)
|
local function start_node(pos, nvm, state)
|
||||||
nvm.running = true
|
nvm.running = true
|
||||||
nvm.given = 0
|
nvm.provided = 0
|
||||||
local outdir = M(pos):get_int("outdir")
|
local outdir = M(pos):get_int("outdir")
|
||||||
power.generator_start(pos, Cable, CYCLE_TIME, outdir)
|
power.start_storage_calc(pos, Cable, outdir)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function stop_node(pos, nvm, state)
|
local function stop_node(pos, nvm, state)
|
||||||
nvm.running = false
|
nvm.running = false
|
||||||
nvm.given = 0
|
nvm.provided = 0
|
||||||
local outdir = M(pos):get_int("outdir")
|
local outdir = M(pos):get_int("outdir")
|
||||||
power.generator_stop(pos, Cable, outdir)
|
power.start_storage_calc(pos, Cable, outdir)
|
||||||
end
|
end
|
||||||
|
|
||||||
local State = techage.NodeStates:new({
|
|
||||||
node_name_passive = "techage:ta4_fuelcell",
|
|
||||||
node_name_active = "techage:ta4_fuelcell_on",
|
|
||||||
cycle_time = CYCLE_TIME,
|
|
||||||
standby_ticks = STANDBY_TICKS,
|
|
||||||
formspec_func = formspec,
|
|
||||||
infotext_name = S("TA4 Fuel Cell Gen2"),
|
|
||||||
start_node = start_node,
|
|
||||||
stop_node = stop_node,
|
|
||||||
})
|
|
||||||
|
|
||||||
local function has_hydrogen(nvm)
|
local function has_hydrogen(nvm)
|
||||||
nvm.liquid = nvm.liquid or {}
|
nvm.liquid = nvm.liquid or {}
|
||||||
nvm.liquid.amount = nvm.liquid.amount or 0
|
nvm.liquid.amount = nvm.liquid.amount or 0
|
||||||
@ -100,30 +72,53 @@ local function has_hydrogen(nvm)
|
|||||||
return nvm.num_pwr_units > 0 or (nvm.liquid.amount > 0 and nvm.liquid.name == "techage:hydrogen")
|
return nvm.num_pwr_units > 0 or (nvm.liquid.amount > 0 and nvm.liquid.name == "techage:hydrogen")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function can_start(pos, nvm, state)
|
||||||
|
if has_hydrogen(nvm) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return S("no hydrogen")
|
||||||
|
end
|
||||||
|
|
||||||
|
local State = techage.NodeStates:new({
|
||||||
|
node_name_passive = "techage:ta4_fuelcell",
|
||||||
|
node_name_active = "techage:ta4_fuelcell_on",
|
||||||
|
cycle_time = CYCLE_TIME,
|
||||||
|
standby_ticks = STANDBY_TICKS,
|
||||||
|
formspec_func = formspec,
|
||||||
|
infotext_name = S("TA4 Fuel Cell"),
|
||||||
|
can_start = can_start,
|
||||||
|
start_node = start_node,
|
||||||
|
stop_node = stop_node,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
local function consuming(pos, nvm)
|
local function consuming(pos, nvm)
|
||||||
if nvm.num_pwr_units <= 0 then
|
if nvm.num_pwr_units <= 0 then
|
||||||
nvm.num_pwr_units = nvm.num_pwr_units + PWR_UNITS_PER_HYDROGEN_ITEM
|
nvm.num_pwr_units = nvm.num_pwr_units + PWR_UNITS_PER_HYDROGEN_ITEM
|
||||||
nvm.liquid.amount = nvm.liquid.amount - 1
|
nvm.liquid.amount = nvm.liquid.amount - 1
|
||||||
end
|
end
|
||||||
nvm.num_pwr_units = nvm.num_pwr_units - nvm.given
|
nvm.num_pwr_units = nvm.num_pwr_units - nvm.provided
|
||||||
end
|
end
|
||||||
|
|
||||||
-- converts hydrogen into power
|
-- converts hydrogen into power
|
||||||
local function node_timer(pos, elapsed)
|
local function node_timer(pos, elapsed)
|
||||||
|
local meta = M(pos)
|
||||||
local nvm = techage.get_nvm(pos)
|
local nvm = techage.get_nvm(pos)
|
||||||
local state = STATE(pos)
|
--print("fuelcell", nvm.running, nvm.provided, nvm.num_pwr_units)
|
||||||
--print("fuelcell", nvm.running, nvm.given, nvm.num_pwr_units)
|
|
||||||
if has_hydrogen(nvm) then
|
if has_hydrogen(nvm) then
|
||||||
local outdir = M(pos):get_int("outdir")
|
local outdir = M(pos):get_int("outdir")
|
||||||
nvm.given = power.generator_alive(pos, Cable, CYCLE_TIME, outdir)
|
local tp1 = tonumber(meta:get_string("termpoint1"))
|
||||||
|
local tp2 = tonumber(meta:get_string("termpoint2"))
|
||||||
|
nvm.provided = power.provide_power(pos, Cable, outdir, PWR_PERF, tp1, tp2)
|
||||||
|
nvm.load = power.get_storage_load(pos, Cable, outdir, PWR_PERF)
|
||||||
consuming(pos, nvm)
|
consuming(pos, nvm)
|
||||||
state:keep_running(pos, nvm, 1) -- TODO warum hier 1 und nicht COUNTDOWN_TICKS?
|
State:keep_running(pos, nvm, 1) -- TODO warum hier 1 und nicht COUNTDOWN_TICKS?
|
||||||
else
|
else
|
||||||
state:standby(pos, nvm)
|
State:standby(pos, nvm)
|
||||||
nvm.given = 0
|
nvm.provided = 0
|
||||||
end
|
end
|
||||||
if techage.is_activeformspec(pos) then
|
if techage.is_activeformspec(pos) then
|
||||||
M(pos):set_string("formspec", formspec(state, pos, nvm))
|
M(pos):set_string("formspec", formspec(State, pos, nvm))
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -133,26 +128,14 @@ local function on_receive_fields(pos, formname, fields, player)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
local nvm = techage.get_nvm(pos)
|
local nvm = techage.get_nvm(pos)
|
||||||
if fields.is_gen1 then
|
State:state_button_event(pos, nvm, fields)
|
||||||
nvm.is_gen1 = fields.is_gen1 == "true"
|
M(pos):set_string("formspec", formspec(State, pos, nvm))
|
||||||
local node = minetest.get_node(pos)
|
|
||||||
if nvm.is_gen1 then
|
|
||||||
node.name = "techage:ta4_fuelcell2"
|
|
||||||
else
|
|
||||||
node.name = "techage:ta4_fuelcell"
|
|
||||||
end
|
|
||||||
minetest.swap_node(pos, node)
|
|
||||||
local outdir = M(pos):get_int("outdir")
|
|
||||||
techage.power.update_network(pos, outdir, Cable)
|
|
||||||
end
|
|
||||||
STATE(pos):state_button_event(pos, nvm, fields)
|
|
||||||
M(pos):set_string("formspec", formspec(STATE(pos), pos, nvm))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function on_rightclick(pos, node, clicker)
|
local function on_rightclick(pos, node, clicker)
|
||||||
local nvm = techage.get_nvm(pos)
|
local nvm = techage.get_nvm(pos)
|
||||||
techage.set_activeformspec(pos, clicker)
|
techage.set_activeformspec(pos, clicker)
|
||||||
M(pos):set_string("formspec", formspec(STATE(pos), pos, nvm))
|
M(pos):set_string("formspec", formspec(State, pos, nvm))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function after_place_node(pos)
|
local function after_place_node(pos)
|
||||||
@ -160,7 +143,7 @@ local function after_place_node(pos)
|
|||||||
nvm.running = false
|
nvm.running = false
|
||||||
nvm.num_pwr_units = 0
|
nvm.num_pwr_units = 0
|
||||||
local number = techage.add_node(pos, "techage:ta4_fuelcell")
|
local number = techage.add_node(pos, "techage:ta4_fuelcell")
|
||||||
STATE(pos):node_init(pos, nvm, number)
|
State:node_init(pos, nvm, number)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
M(pos):set_int("outdir", networks.side_to_outdir(pos, "R"))
|
M(pos):set_int("outdir", networks.side_to_outdir(pos, "R"))
|
||||||
Pipe:after_place_node(pos)
|
Pipe:after_place_node(pos)
|
||||||
@ -176,47 +159,13 @@ local function after_dig_node(pos, oldnode, oldmetadata, digger)
|
|||||||
Cable:after_dig_node(pos)
|
Cable:after_dig_node(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function tubelib2_on_update2(pos, outdir, tlib2, node)
|
local function get_generator_data(pos, tlib2)
|
||||||
if tlib2.tube_type == "pipe2" then
|
local nvm = techage.get_nvm(pos)
|
||||||
liquid.update_network(pos, outdir, tlib2)
|
if nvm.running then
|
||||||
else
|
return {level = (nvm.load or 0) / PWR_PERF, perf = PWR_PERF, capa = PWR_PERF * 2}
|
||||||
power.update_network(pos, outdir, tlib2)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local netw_def = {
|
|
||||||
pipe2 = {
|
|
||||||
sides = {L = 1}, -- Pipe connection sides
|
|
||||||
ntype = "tank",
|
|
||||||
},
|
|
||||||
ele1 = {
|
|
||||||
sides = {R = 1}, -- Cable connection sides
|
|
||||||
ntype = "gen2",
|
|
||||||
nominal = PWR_CAPA,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
local liquid_def = {
|
|
||||||
capa = CAPACITY,
|
|
||||||
peek = liquid.srv_peek,
|
|
||||||
put = function(pos, indir, name, amount)
|
|
||||||
local leftover = liquid.srv_put(pos, indir, name, amount)
|
|
||||||
if techage.is_activeformspec(pos) then
|
|
||||||
local nvm = techage.get_nvm(pos)
|
|
||||||
M(pos):set_string("formspec", formspec(STATE(pos), pos, nvm))
|
|
||||||
end
|
|
||||||
return leftover
|
|
||||||
end,
|
|
||||||
take = function(pos, indir, name, amount)
|
|
||||||
amount, name = liquid.srv_take(pos, indir, name, amount)
|
|
||||||
if techage.is_activeformspec(pos) then
|
|
||||||
local nvm = techage.get_nvm(pos)
|
|
||||||
M(pos):set_string("formspec", formspec(STATE(pos), pos, nvm))
|
|
||||||
end
|
|
||||||
return amount, name
|
|
||||||
end
|
|
||||||
}
|
|
||||||
|
|
||||||
minetest.register_node("techage:ta4_fuelcell", {
|
minetest.register_node("techage:ta4_fuelcell", {
|
||||||
description = S("TA4 Fuel Cell"),
|
description = S("TA4 Fuel Cell"),
|
||||||
tiles = {
|
tiles = {
|
||||||
@ -238,13 +187,12 @@ minetest.register_node("techage:ta4_fuelcell", {
|
|||||||
|
|
||||||
after_place_node = after_place_node,
|
after_place_node = after_place_node,
|
||||||
after_dig_node = after_dig_node,
|
after_dig_node = after_dig_node,
|
||||||
tubelib2_on_update2 = tubelib2_on_update2,
|
get_generator_data = get_generator_data,
|
||||||
on_punch = liquid.on_punch,
|
on_punch = liquid.on_punch,
|
||||||
networks = netw_def,
|
|
||||||
liquid = liquid_def,
|
|
||||||
on_receive_fields = on_receive_fields,
|
on_receive_fields = on_receive_fields,
|
||||||
on_timer = node_timer,
|
on_timer = node_timer,
|
||||||
on_rightclick = on_rightclick,
|
on_rightclick = on_rightclick,
|
||||||
|
ta4_formspec = techage.generator_settings("ta4", PWR_PERF),
|
||||||
|
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
groups = {cracky=2, crumbly=2, choppy=2},
|
groups = {cracky=2, crumbly=2, choppy=2},
|
||||||
@ -282,13 +230,12 @@ minetest.register_node("techage:ta4_fuelcell_on", {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
tubelib2_on_update2 = tubelib2_on_update2,
|
get_generator_data = get_generator_data,
|
||||||
networks = netw_def,
|
|
||||||
liquid = liquid_def,
|
|
||||||
on_receive_fields = on_receive_fields,
|
on_receive_fields = on_receive_fields,
|
||||||
on_punch = liquid.on_punch,
|
on_punch = liquid.on_punch,
|
||||||
on_timer = node_timer,
|
on_timer = node_timer,
|
||||||
on_rightclick = on_rightclick,
|
on_rightclick = on_rightclick,
|
||||||
|
ta4_formspec = techage.generator_settings("ta4", PWR_PERF),
|
||||||
|
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
groups = {not_in_creative_inventory=1},
|
groups = {not_in_creative_inventory=1},
|
||||||
@ -299,138 +246,81 @@ minetest.register_node("techage:ta4_fuelcell_on", {
|
|||||||
light_source = 6,
|
light_source = 6,
|
||||||
})
|
})
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
local liquid_def = {
|
||||||
-- Gen1 fuellcell
|
capa = CAPACITY,
|
||||||
-------------------------------------------------------------------------------
|
peek = function(pos)
|
||||||
local State2 = techage.NodeStates:new({
|
local nvm = techage.get_nvm(pos)
|
||||||
node_name_passive = "techage:ta4_fuelcell2",
|
return liquid.srv_peek(nvm)
|
||||||
node_name_active = "techage:ta4_fuelcell2_on",
|
end,
|
||||||
cycle_time = CYCLE_TIME,
|
put = function(pos, indir, name, amount)
|
||||||
standby_ticks = STANDBY_TICKS,
|
local nvm = techage.get_nvm(pos)
|
||||||
formspec_func = formspec,
|
local leftover = liquid.srv_put(nvm, name, amount, CAPACITY)
|
||||||
infotext_name = S("TA4 Fuel Cell Gen1"),
|
if techage.is_activeformspec(pos) then
|
||||||
start_node = start_node,
|
local nvm = techage.get_nvm(pos)
|
||||||
stop_node = stop_node,
|
M(pos):set_string("formspec", formspec(State, pos, nvm))
|
||||||
})
|
end
|
||||||
|
return leftover
|
||||||
local netw_def2 = {
|
end,
|
||||||
pipe2 = {
|
take = function(pos, indir, name, amount)
|
||||||
sides = {L = 1}, -- Pipe connection sides
|
local nvm = techage.get_nvm(pos)
|
||||||
ntype = "tank",
|
amount, name = liquid.srv_take(nvm, name, amount)
|
||||||
},
|
if techage.is_activeformspec(pos) then
|
||||||
ele1 = {
|
local nvm = techage.get_nvm(pos)
|
||||||
sides = {R = 1}, -- Cable connection sides
|
M(pos):set_string("formspec", formspec(State, pos, nvm))
|
||||||
ntype = "gen1",
|
end
|
||||||
nominal = PWR_CAPA - 1, -- to be able to distiguish between cat1 and 2
|
return amount, name
|
||||||
},
|
end,
|
||||||
|
untake = function(pos, indir, name, amount)
|
||||||
|
local nvm = techage.get_nvm(pos)
|
||||||
|
local leftover = liquid.srv_put(nvm, name, amount, CAPACITY)
|
||||||
|
if techage.is_activeformspec(pos) then
|
||||||
|
local nvm = techage.get_nvm(pos)
|
||||||
|
M(pos):set_string("formspec", formspec(State, pos, nvm))
|
||||||
|
end
|
||||||
|
return leftover
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
minetest.register_node("techage:ta4_fuelcell2", {
|
liquid.register_nodes({"techage:ta4_fuelcell", "techage:ta4_fuelcell_on"}, Pipe, "tank", {"L"}, liquid_def)
|
||||||
description = S("TA4 Fuel Cell"),
|
power.register_nodes({"techage:ta4_fuelcell", "techage:ta4_fuelcell_on"}, Cable, "gen", {"R"})
|
||||||
tiles = {
|
|
||||||
-- up, down, right, left, back, front
|
|
||||||
"techage_filling_ta4.png^techage_frame_ta4_top.png^techage_appl_arrow.png",
|
|
||||||
"techage_filling_ta4.png^techage_frame_ta4.png",
|
|
||||||
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_hole_electric.png",
|
|
||||||
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_hole_pipe.png",
|
|
||||||
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_fuelcell.png^techage_appl_ctrl_unit.png^[transformFX",
|
|
||||||
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_fuelcell.png^techage_appl_ctrl_unit.png",
|
|
||||||
},
|
|
||||||
|
|
||||||
can_dig = function(pos, player)
|
minetest.register_alias_force("techage:ta4_fuelcell2", "techage:ta4_fuelcell")
|
||||||
if minetest.is_protected(pos, player:get_player_name()) then
|
minetest.register_alias_force("techage:ta4_fuelcell2_on", "techage:ta4_fuelcell_on")
|
||||||
return false
|
|
||||||
end
|
|
||||||
return liquid.is_empty(pos)
|
|
||||||
end,
|
|
||||||
|
|
||||||
after_place_node = after_place_node,
|
|
||||||
after_dig_node = after_dig_node,
|
|
||||||
tubelib2_on_update2 = tubelib2_on_update2,
|
|
||||||
on_punch = liquid.on_punch,
|
|
||||||
networks = netw_def2,
|
|
||||||
liquid = liquid_def,
|
|
||||||
on_receive_fields = on_receive_fields,
|
|
||||||
on_timer = node_timer,
|
|
||||||
on_rightclick = on_rightclick,
|
|
||||||
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
groups = {cracky=2, crumbly=2, choppy=2, not_in_creative_inventory=1},
|
|
||||||
on_rotate = screwdriver.disallow,
|
|
||||||
is_ground_content = false,
|
|
||||||
drop = "techage:ta4_fuelcell",
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("techage:ta4_fuelcell2_on", {
|
techage.register_node({"techage:ta4_fuelcell", "techage:ta4_fuelcell_on"}, {
|
||||||
description = S("TA4 Fuel Cell"),
|
|
||||||
tiles = {
|
|
||||||
-- up, down, right, left, back, front
|
|
||||||
"techage_filling_ta4.png^techage_frame_ta4_top.png^techage_appl_arrow.png",
|
|
||||||
"techage_filling_ta4.png^techage_frame_ta4.png",
|
|
||||||
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_hole_electric.png",
|
|
||||||
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_hole_pipe.png",
|
|
||||||
{
|
|
||||||
image = "techage_filling4_ta4.png^techage_frame4_ta4.png^techage_appl_fuelcell4.png^techage_appl_ctrl_unit4.png^[transformFX",
|
|
||||||
backface_culling = false,
|
|
||||||
animation = {
|
|
||||||
type = "vertical_frames",
|
|
||||||
aspect_w = 32,
|
|
||||||
aspect_h = 32,
|
|
||||||
length = 0.8,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
image = "techage_filling4_ta4.png^techage_frame4_ta4.png^techage_appl_fuelcell4.png^techage_appl_ctrl_unit4.png",
|
|
||||||
backface_culling = false,
|
|
||||||
animation = {
|
|
||||||
type = "vertical_frames",
|
|
||||||
aspect_w = 32,
|
|
||||||
aspect_h = 32,
|
|
||||||
length = 0.8,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
tubelib2_on_update2 = tubelib2_on_update2,
|
|
||||||
networks = netw_def2,
|
|
||||||
liquid = liquid_def,
|
|
||||||
on_receive_fields = on_receive_fields,
|
|
||||||
on_punch = liquid.on_punch,
|
|
||||||
on_timer = node_timer,
|
|
||||||
on_rightclick = on_rightclick,
|
|
||||||
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
groups = {not_in_creative_inventory=1},
|
|
||||||
on_rotate = screwdriver.disallow,
|
|
||||||
is_ground_content = false,
|
|
||||||
diggable = false,
|
|
||||||
paramtype = "light",
|
|
||||||
light_source = 6,
|
|
||||||
})
|
|
||||||
|
|
||||||
States["techage:ta4_fuelcell"] = State
|
|
||||||
States["techage:ta4_fuelcell_on"] = State
|
|
||||||
States["techage:ta4_fuelcell2"] = State2
|
|
||||||
States["techage:ta4_fuelcell2_on"] = State2
|
|
||||||
|
|
||||||
Cable:add_secondary_node_names({"techage:ta4_fuelcell", "techage:ta4_fuelcell_on",
|
|
||||||
"techage:ta4_fuelcell2", "techage:ta4_fuelcell2_on"})
|
|
||||||
Pipe:add_secondary_node_names({"techage:ta4_fuelcell", "techage:ta4_fuelcell_on",
|
|
||||||
"techage:ta4_fuelcell2", "techage:ta4_fuelcell2_on"})
|
|
||||||
techage.register_node({"techage:ta4_fuelcell", "techage:ta4_fuelcell_on",
|
|
||||||
"techage:ta4_fuelcell2", "techage:ta4_fuelcell2_on"}, {
|
|
||||||
on_recv_message = function(pos, src, topic, payload)
|
on_recv_message = function(pos, src, topic, payload)
|
||||||
local nvm = techage.get_nvm(pos)
|
local nvm = techage.get_nvm(pos)
|
||||||
if topic == "load" then
|
if topic == "load" then
|
||||||
return techage.power.percent(CAPACITY, (nvm.liquid and nvm.liquid.amount) or 0)
|
return techage.power.percent(CAPACITY, (nvm.liquid and nvm.liquid.amount) or 0)
|
||||||
elseif topic == "delivered" then
|
elseif topic == "delivered" then
|
||||||
return math.floor((nvm.given or 0) + 0.5)
|
return math.floor((nvm.provided or 0) + 0.5)
|
||||||
else
|
else
|
||||||
return STATE(pos):on_receive_message(pos, topic, payload)
|
return State:on_receive_message(pos, topic, payload)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
control.register_nodes({"techage:ta4_fuelcell", "techage:ta4_fuelcell_on"}, {
|
||||||
|
on_receive = function(pos, tlib2, topic, payload)
|
||||||
|
end,
|
||||||
|
on_request = function(pos, tlib2, topic)
|
||||||
|
if topic == "info" then
|
||||||
|
local nvm = techage.get_nvm(pos)
|
||||||
|
local meta = M(pos)
|
||||||
|
return {
|
||||||
|
type = S("TA4 Fuel Cell"),
|
||||||
|
number = meta:get_string("node_number") or "",
|
||||||
|
running = nvm.running or false,
|
||||||
|
available = PWR_PERF,
|
||||||
|
provided = nvm.provided or 0,
|
||||||
|
termpoint = meta:get_string("termpoint"),
|
||||||
|
}
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "techage:ta4_fuelcell",
|
output = "techage:ta4_fuelcell",
|
||||||
recipe = {
|
recipe = {
|
||||||
|
42
init.lua
42
init.lua
@ -286,15 +286,15 @@ dofile(MP.."/energy_storage/inlet.lua")
|
|||||||
dofile(MP.."/energy_storage/nodes.lua")
|
dofile(MP.."/energy_storage/nodes.lua")
|
||||||
|
|
||||||
-- Chemistry
|
-- Chemistry
|
||||||
--dofile(MP.."/chemistry/ta4_reactor.lua")
|
dofile(MP.."/chemistry/ta4_reactor.lua")
|
||||||
--dofile(MP.."/chemistry/ta4_stand.lua")
|
dofile(MP.."/chemistry/ta4_stand.lua")
|
||||||
--dofile(MP.."/chemistry/ta4_doser.lua")
|
dofile(MP.."/chemistry/ta4_doser.lua")
|
||||||
--dofile(MP.."/chemistry/ta4_liquid_filter.lua")
|
dofile(MP.."/chemistry/ta4_liquid_filter.lua")
|
||||||
|
|
||||||
-- Hydrogen
|
-- Hydrogen
|
||||||
--dofile(MP.."/hydrogen/fuelcellstack.lua")
|
dofile(MP.."/hydrogen/fuelcellstack.lua")
|
||||||
--dofile(MP.."/hydrogen/electrolyzer.lua")
|
dofile(MP.."/hydrogen/electrolyzer.lua")
|
||||||
--dofile(MP.."/hydrogen/fuelcell.lua")
|
dofile(MP.."/hydrogen/fuelcell.lua")
|
||||||
|
|
||||||
-- ICTA Controller
|
-- ICTA Controller
|
||||||
--dofile(MP.."/icta_controller/submenu.lua")
|
--dofile(MP.."/icta_controller/submenu.lua")
|
||||||
@ -324,20 +324,20 @@ dofile(MP.."/items/lye.lua")
|
|||||||
dofile(MP.."/items/oil.lua")
|
dofile(MP.."/items/oil.lua")
|
||||||
dofile(MP.."/items/petroleum.lua")
|
dofile(MP.."/items/petroleum.lua")
|
||||||
dofile(MP.."/items/bauxit.lua")
|
dofile(MP.."/items/bauxit.lua")
|
||||||
--dofile(MP.."/items/silicon.lua")
|
dofile(MP.."/items/silicon.lua")
|
||||||
--dofile(MP.."/items/steelmat.lua")
|
dofile(MP.."/items/steelmat.lua")
|
||||||
--dofile(MP.."/items/powder.lua")
|
dofile(MP.."/items/powder.lua")
|
||||||
--dofile(MP.."/items/epoxy.lua")
|
dofile(MP.."/items/epoxy.lua")
|
||||||
--dofile(MP.."/items/aluminium.lua")
|
dofile(MP.."/items/aluminium.lua")
|
||||||
--dofile(MP.."/items/plastic.lua")
|
dofile(MP.."/items/plastic.lua")
|
||||||
--dofile(MP.."/items/hydrogen.lua")
|
dofile(MP.."/items/hydrogen.lua")
|
||||||
--dofile(MP.."/items/electronic.lua")
|
dofile(MP.."/items/electronic.lua")
|
||||||
--dofile(MP.."/items/redstone.lua")
|
dofile(MP.."/items/redstone.lua")
|
||||||
--dofile(MP.."/items/cement.lua")
|
dofile(MP.."/items/cement.lua")
|
||||||
--dofile(MP.."/items/cracking.lua")
|
dofile(MP.."/items/cracking.lua")
|
||||||
--dofile(MP.."/items/ceramic.lua")
|
dofile(MP.."/items/ceramic.lua")
|
||||||
--dofile(MP.."/items/basalt.lua")
|
dofile(MP.."/items/basalt.lua")
|
||||||
--dofile(MP.."/items/moreblocks.lua")
|
dofile(MP.."/items/moreblocks.lua")
|
||||||
|
|
||||||
-- Carts
|
-- Carts
|
||||||
--dofile(MP.."/carts/tank_cart.lua")
|
--dofile(MP.."/carts/tank_cart.lua")
|
||||||
|
@ -129,13 +129,13 @@ local function after_dig_node(pos, oldnode, oldmetadata, digger)
|
|||||||
techage.del_mem(pos)
|
techage.del_mem(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function tubelib2_on_update2(pos, outdir, tlib2, node)
|
--local function tubelib2_on_update2(pos, outdir, tlib2, node)
|
||||||
if tlib2.tube_type == "pipe2" then
|
-- if tlib2.tube_type == "pipe2" then
|
||||||
liquid.update_network(pos, outdir, tlib2)
|
-- liquid.update_network(pos, outdir, tlib2)
|
||||||
else
|
-- else
|
||||||
power.update_network(pos, outdir, tlib2)
|
-- power.update_network(pos, outdir, tlib2)
|
||||||
end
|
-- end
|
||||||
end
|
--end
|
||||||
|
|
||||||
local netw_def = {
|
local netw_def = {
|
||||||
pipe2 = {
|
pipe2 = {
|
||||||
@ -165,7 +165,7 @@ minetest.register_node("techage:t4_waterpump", {
|
|||||||
|
|
||||||
after_place_node = after_place_node,
|
after_place_node = after_place_node,
|
||||||
after_dig_node = after_dig_node,
|
after_dig_node = after_dig_node,
|
||||||
tubelib2_on_update2 = tubelib2_on_update2,
|
--tubelib2_on_update2 = tubelib2_on_update2,
|
||||||
networks = netw_def,
|
networks = netw_def,
|
||||||
on_receive_fields = on_receive_fields,
|
on_receive_fields = on_receive_fields,
|
||||||
on_timer = node_timer,
|
on_timer = node_timer,
|
||||||
|
@ -233,6 +233,29 @@ function techage.generator_settings(tier, available)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function techage.evaluate_charge_termination(nvm, meta)
|
||||||
|
local termpoint = meta:get_string("termpoint")
|
||||||
|
if termpoint == "40% - 60%" then
|
||||||
|
meta:set_string("termpoint1", 0.4)
|
||||||
|
meta:set_string("termpoint2", 0.6)
|
||||||
|
elseif termpoint == "60% - 80%" then
|
||||||
|
meta:set_string("termpoint1", 0.6)
|
||||||
|
meta:set_string("termpoint2", 0.8)
|
||||||
|
elseif termpoint == "80% - 100%" then
|
||||||
|
meta:set_string("termpoint1", 0.8)
|
||||||
|
meta:set_string("termpoint2", 1.0)
|
||||||
|
else
|
||||||
|
meta:set_string("termpoint", "80% - 100%")
|
||||||
|
meta:set_string("termpoint1", 0.8)
|
||||||
|
meta:set_string("termpoint2", 1.0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
techage.power.percent = calc_percent
|
||||||
|
techage.CYCLES_PER_DAY = CYCLES_PER_DAY
|
||||||
|
techage.round = round
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
-- Still used legacy functions
|
-- Still used legacy functions
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
@ -268,24 +291,3 @@ function techage.formspec_label_bar(pos, x, y, label, max_power, current_power,
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function techage.evaluate_charge_termination(nvm, meta)
|
|
||||||
local termpoint = meta:get_string("termpoint")
|
|
||||||
if termpoint == "40% - 60%" then
|
|
||||||
meta:set_string("termpoint1", 0.4)
|
|
||||||
meta:set_string("termpoint2", 0.6)
|
|
||||||
elseif termpoint == "60% - 80%" then
|
|
||||||
meta:set_string("termpoint1", 0.6)
|
|
||||||
meta:set_string("termpoint2", 0.8)
|
|
||||||
elseif termpoint == "80% - 100%" then
|
|
||||||
meta:set_string("termpoint1", 0.8)
|
|
||||||
meta:set_string("termpoint2", 1.0)
|
|
||||||
else
|
|
||||||
meta:set_string("termpoint", "80% - 100%")
|
|
||||||
meta:set_string("termpoint1", 0.8)
|
|
||||||
meta:set_string("termpoint2", 1.0)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
techage.power.percent = calc_percent
|
|
||||||
techage.CYCLES_PER_DAY = CYCLES_PER_DAY
|
|
||||||
techage.round = round
|
|
Loading…
Reference in New Issue
Block a user