fuell cell and electrolyzer added
power improvements
@ -10,7 +10,7 @@ local Cable = techage.ElectricCable
|
|||||||
local power = techage.power
|
local power = techage.power
|
||||||
|
|
||||||
local function swap_node(pos, name)
|
local function swap_node(pos, name)
|
||||||
local node = minetest.get_node(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
if node.name == name then
|
if node.name == name then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -20,7 +20,7 @@ local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
|||||||
local S2P = minetest.string_to_pos
|
local S2P = minetest.string_to_pos
|
||||||
local M = minetest.get_meta
|
local M = minetest.get_meta
|
||||||
-- Consumer Related Data
|
-- Consumer Related Data
|
||||||
local CRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).consumer end
|
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
|
||||||
|
|
||||||
local S = techage.S
|
local S = techage.S
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
local M = minetest.get_meta
|
local M = minetest.get_meta
|
||||||
local N = minetest.get_node
|
local N = minetest.get_node
|
||||||
-- Consumer Related Data
|
-- Consumer Related Data
|
||||||
local CRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).consumer end
|
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
|
||||||
|
|
||||||
local S = techage.S
|
local S = techage.S
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ local FilterCache = {} -- local cache for filter settings
|
|||||||
|
|
||||||
local function filter_settings(pos)
|
local function filter_settings(pos)
|
||||||
local meta = M(pos)
|
local meta = M(pos)
|
||||||
local param2 = minetest.get_node(pos).param2
|
local param2 = techage.get_node_lvm(pos).param2
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
local filter = minetest.deserialize(meta:get_string("filter")) or {false,false,false,false}
|
local filter = minetest.deserialize(meta:get_string("filter")) or {false,false,false,false}
|
||||||
local ItemFilter = {} -- {<item:name> = {dir,...}]
|
local ItemFilter = {} -- {<item:name> = {dir,...}]
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
-- for lazy programmers
|
-- for lazy programmers
|
||||||
local M = minetest.get_meta
|
local M = minetest.get_meta
|
||||||
-- Consumer Related Data
|
-- Consumer Related Data
|
||||||
local CRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).consumer end
|
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
|
||||||
|
|
||||||
local S = techage.S
|
local S = techage.S
|
||||||
local STANDBY_TICKS = 10
|
local STANDBY_TICKS = 10
|
||||||
|
@ -17,7 +17,7 @@ local M = minetest.get_meta
|
|||||||
local S = techage.S
|
local S = techage.S
|
||||||
|
|
||||||
-- Consumer Related Data
|
-- Consumer Related Data
|
||||||
local CRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).consumer end
|
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
|
||||||
|
|
||||||
local STANDBY_TICKS = 10
|
local STANDBY_TICKS = 10
|
||||||
local COUNTDOWN_TICKS = 10
|
local COUNTDOWN_TICKS = 10
|
||||||
@ -73,7 +73,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
local function get_water_level(pos)
|
local function get_water_level(pos)
|
||||||
local node = minetest.get_node(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
if minetest.get_item_group(node.name, "water") > 0 then
|
if minetest.get_item_group(node.name, "water") > 0 then
|
||||||
local ndef = minetest.registered_nodes[node.name]
|
local ndef = minetest.registered_nodes[node.name]
|
||||||
if ndef and ndef.liquidtype == "flowing" then
|
if ndef and ndef.liquidtype == "flowing" then
|
||||||
|
@ -17,7 +17,7 @@ local M = minetest.get_meta
|
|||||||
local S = techage.S
|
local S = techage.S
|
||||||
|
|
||||||
-- Consumer Related Data
|
-- Consumer Related Data
|
||||||
local CRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).consumer end
|
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
|
||||||
|
|
||||||
local STANDBY_TICKS = 10
|
local STANDBY_TICKS = 10
|
||||||
local COUNTDOWN_TICKS = 10
|
local COUNTDOWN_TICKS = 10
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
-- for lazy programmers
|
-- for lazy programmers
|
||||||
local M = minetest.get_meta
|
local M = minetest.get_meta
|
||||||
-- Consumer Related Data
|
-- Consumer Related Data
|
||||||
local CRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).consumer end
|
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
|
||||||
|
|
||||||
local S = techage.S
|
local S = techage.S
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
-- for lazy programmers
|
-- for lazy programmers
|
||||||
local M = minetest.get_meta
|
local M = minetest.get_meta
|
||||||
-- Consumer Related Data
|
-- Consumer Related Data
|
||||||
local CRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).consumer end
|
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
|
||||||
|
|
||||||
local S = techage.S
|
local S = techage.S
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ end
|
|||||||
local function sample_liquid(pos, crd, mem, inv)
|
local function sample_liquid(pos, crd, mem, inv)
|
||||||
local meta = M(pos)
|
local meta = M(pos)
|
||||||
local water_pos = minetest.string_to_pos(meta:get_string("water_pos"))
|
local water_pos = minetest.string_to_pos(meta:get_string("water_pos"))
|
||||||
local giving_back = test_liquid(minetest.get_node(water_pos))
|
local giving_back = test_liquid(techage.get_node_lvm(water_pos))
|
||||||
if giving_back then
|
if giving_back then
|
||||||
if inv:room_for_item("dst", ItemStack(giving_back)) and
|
if inv:room_for_item("dst", ItemStack(giving_back)) and
|
||||||
inv:contains_item("src", ItemStack("bucket:bucket_empty")) then
|
inv:contains_item("src", ItemStack("bucket:bucket_empty")) then
|
||||||
|
@ -27,7 +27,7 @@ local M = minetest.get_meta
|
|||||||
local S = techage.S
|
local S = techage.S
|
||||||
|
|
||||||
-- Consumer Related Data
|
-- Consumer Related Data
|
||||||
local CRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).consumer end
|
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
|
||||||
|
|
||||||
local STANDBY_TICKS = 10
|
local STANDBY_TICKS = 10
|
||||||
local COUNTDOWN_TICKS = 10
|
local COUNTDOWN_TICKS = 10
|
||||||
|
@ -79,7 +79,7 @@ local function check_space(pos, param2, AssemblyPlan, player_name)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local node = minetest.get_node(pos1)
|
local node = techage.get_node_lvm(pos1)
|
||||||
local ndef = minetest.registered_nodes[node.name]
|
local ndef = minetest.registered_nodes[node.name]
|
||||||
if not ndef or ndef.walkable and node.name ~= node_name then
|
if not ndef or ndef.walkable and node.name ~= node_name then
|
||||||
minetest.chat_send_player(player_name, S("[TA] Not enough space!"))
|
minetest.chat_send_player(player_name, S("[TA] Not enough space!"))
|
||||||
|
@ -25,7 +25,7 @@ local M = minetest.get_meta
|
|||||||
local D = techage.Debug
|
local D = techage.Debug
|
||||||
|
|
||||||
-- Consumer Related Data
|
-- Consumer Related Data
|
||||||
local CRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).consumer end
|
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
|
||||||
local CRDN = function(node) return (minetest.registered_nodes[node.name] or {}).consumer end
|
local CRDN = function(node) return (minetest.registered_nodes[node.name] or {}).consumer end
|
||||||
|
|
||||||
local power = techage.power
|
local power = techage.power
|
||||||
@ -242,7 +242,7 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode, validState
|
|||||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||||
local meta = M(pos)
|
local meta = M(pos)
|
||||||
local mem = tubelib2.init_mem(pos)
|
local mem = tubelib2.init_mem(pos)
|
||||||
local node = minetest.get_node(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
meta:set_int("push_dir", techage.side_to_indir("L", node.param2))
|
meta:set_int("push_dir", techage.side_to_indir("L", node.param2))
|
||||||
meta:set_int("pull_dir", techage.side_to_indir("R", node.param2))
|
meta:set_int("pull_dir", techage.side_to_indir("R", node.param2))
|
||||||
local number = "-"
|
local number = "-"
|
||||||
|
@ -119,7 +119,7 @@ function techage.firebox.on_rightclick(pos, node, clicker)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function techage.firebox.swap_node(pos, name)
|
function techage.firebox.swap_node(pos, name)
|
||||||
local node = minetest.get_node(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
if node.name == name then
|
if node.name == name then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -45,7 +45,7 @@ Node states:
|
|||||||
| cycle time operational needs power
|
| cycle time operational needs power
|
||||||
+---------+------------+-------------+-------------
|
+---------+------------+-------------+-------------
|
||||||
| RUNNING normal yes yes
|
| RUNNING normal yes yes
|
||||||
| BLOCKED long yes yes
|
| BLOCKED long yes no
|
||||||
| STANDBY long yes no
|
| STANDBY long yes no
|
||||||
| NOPOWER long no no
|
| NOPOWER long no no
|
||||||
| FAULT none no no
|
| FAULT none no no
|
||||||
@ -91,7 +91,7 @@ function techage.state_button(state)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function techage.get_power_image(pos, mem)
|
function techage.get_power_image(pos, mem)
|
||||||
local node = minetest.get_node(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
local s = "3" -- electrical power
|
local s = "3" -- electrical power
|
||||||
if string.find(node.name, "techage:ta2") then
|
if string.find(node.name, "techage:ta2") then
|
||||||
s = "2" -- axles power
|
s = "2" -- axles power
|
||||||
@ -130,7 +130,7 @@ local function has_power(pos, mem)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function swap_node(pos, name)
|
local function swap_node(pos, name)
|
||||||
local node = minetest.get_node(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
if node.name == name then
|
if node.name == name then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -191,6 +191,15 @@ function NodeStates:node_init(pos, mem, number)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- to be used to re-start the timer outside of node_timer()
|
||||||
|
local function start_timer_delayed(pos, cycle_time)
|
||||||
|
local t = minetest.get_node_timer(pos)
|
||||||
|
t:stop()
|
||||||
|
if cycle_time > 0.9 then
|
||||||
|
minetest.after(0.1, t.start, t, cycle_time)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function NodeStates:stop(pos, mem)
|
function NodeStates:stop(pos, mem)
|
||||||
local state = mem.techage_state or STOPPED
|
local state = mem.techage_state or STOPPED
|
||||||
mem.techage_state = STOPPED
|
mem.techage_state = STOPPED
|
||||||
@ -249,20 +258,12 @@ function NodeStates:start(pos, mem)
|
|||||||
if self.on_state_change then
|
if self.on_state_change then
|
||||||
self.on_state_change(pos, state, RUNNING)
|
self.on_state_change(pos, state, RUNNING)
|
||||||
end
|
end
|
||||||
minetest.get_node_timer(pos):start(self.cycle_time)
|
start_timer_delayed(pos, self.cycle_time)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- to be used from node timer functions
|
|
||||||
function NodeStates:start_from_timer(pos, mem)
|
|
||||||
local state = mem.techage_state or STOPPED
|
|
||||||
if state ~= RUNNING and state ~= FAULT then
|
|
||||||
minetest.after(0.1, self.start, self, pos, mem)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function NodeStates:standby(pos, mem)
|
function NodeStates:standby(pos, mem)
|
||||||
local state = mem.techage_state or STOPPED
|
local state = mem.techage_state or STOPPED
|
||||||
if state == RUNNING then
|
if state == RUNNING then
|
||||||
@ -277,13 +278,10 @@ function NodeStates:standby(pos, mem)
|
|||||||
if self.formspec_func then
|
if self.formspec_func then
|
||||||
M(pos):set_string("formspec", self.formspec_func(self, pos, mem))
|
M(pos):set_string("formspec", self.formspec_func(self, pos, mem))
|
||||||
end
|
end
|
||||||
if minetest.get_node_timer(pos):is_started() then
|
|
||||||
minetest.get_node_timer(pos):stop()
|
|
||||||
end
|
|
||||||
if self.on_state_change then
|
if self.on_state_change then
|
||||||
self.on_state_change(pos, state, STANDBY)
|
self.on_state_change(pos, state, STANDBY)
|
||||||
end
|
end
|
||||||
minetest.get_node_timer(pos):start(self.cycle_time * self.standby_ticks)
|
start_timer_delayed(pos, self.cycle_time * self.standby_ticks)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
@ -304,13 +302,10 @@ function NodeStates:blocked(pos, mem)
|
|||||||
if self.formspec_func then
|
if self.formspec_func then
|
||||||
M(pos):set_string("formspec", self.formspec_func(self, pos, mem))
|
M(pos):set_string("formspec", self.formspec_func(self, pos, mem))
|
||||||
end
|
end
|
||||||
if minetest.get_node_timer(pos):is_started() then
|
|
||||||
minetest.get_node_timer(pos):stop()
|
|
||||||
end
|
|
||||||
if self.on_state_change then
|
if self.on_state_change then
|
||||||
self.on_state_change(pos, state, BLOCKED)
|
self.on_state_change(pos, state, BLOCKED)
|
||||||
end
|
end
|
||||||
minetest.get_node_timer(pos):start(self.cycle_time * self.standby_ticks)
|
start_timer_delayed(pos, self.cycle_time * self.standby_ticks)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
@ -333,7 +328,7 @@ function NodeStates:nopower(pos, mem)
|
|||||||
if self.on_state_change then
|
if self.on_state_change then
|
||||||
self.on_state_change(pos, state, NOPOWER)
|
self.on_state_change(pos, state, NOPOWER)
|
||||||
end
|
end
|
||||||
minetest.get_node_timer(pos):start(self.cycle_time * self.standby_ticks)
|
start_timer_delayed(pos, self.cycle_time * self.standby_ticks)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
@ -394,7 +389,9 @@ end
|
|||||||
-- and keep the node in state RUNNING
|
-- and keep the node in state RUNNING
|
||||||
function NodeStates:keep_running(pos, mem, val, num_items)
|
function NodeStates:keep_running(pos, mem, val, num_items)
|
||||||
-- set to RUNNING if not already done
|
-- set to RUNNING if not already done
|
||||||
self:start_from_timer(pos, mem)
|
if mem.techage_state ~= RUNNING then
|
||||||
|
self:start(pos, mem)
|
||||||
|
end
|
||||||
mem.techage_countdown = val or 4
|
mem.techage_countdown = val or 4
|
||||||
mem.techage_item_meter = (mem.techage_item_meter or 0) + (num_items or 1)
|
mem.techage_item_meter = (mem.techage_item_meter or 0) + (num_items or 1)
|
||||||
end
|
end
|
||||||
@ -431,7 +428,7 @@ function NodeStates:on_receive_message(pos, topic, payload)
|
|||||||
self:stop(pos, tubelib2.get_mem(pos))
|
self:stop(pos, tubelib2.get_mem(pos))
|
||||||
return true
|
return true
|
||||||
elseif topic == "state" then
|
elseif topic == "state" then
|
||||||
local node = minetest.get_node(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
if node.name == "ignore" then -- unloaded node?
|
if node.name == "ignore" then -- unloaded node?
|
||||||
return "unloaded"
|
return "unloaded"
|
||||||
end
|
end
|
||||||
@ -461,7 +458,7 @@ function NodeStates:on_node_load(pos, not_start_timer)
|
|||||||
local number = M(pos):get_string("node_number")
|
local number = M(pos):get_string("node_number")
|
||||||
if number == "" then
|
if number == "" then
|
||||||
minetest.log("warning", "[TA] Node at "..S(pos).." has no node_number")
|
minetest.log("warning", "[TA] Node at "..S(pos).." has no node_number")
|
||||||
local name = minetest.get_node(pos).name
|
local name = techage.get_node_lvm(pos).name
|
||||||
local number = techage.add_node(pos, name)
|
local number = techage.add_node(pos, name)
|
||||||
self:node_init(pos, mem, number)
|
self:node_init(pos, mem, number)
|
||||||
return
|
return
|
||||||
|
@ -66,6 +66,7 @@ local State = techage.NodeStates:new({
|
|||||||
|
|
||||||
local function node_timer(pos, elapsed)
|
local function node_timer(pos, elapsed)
|
||||||
local mem = tubelib2.get_mem(pos)
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
print("akku", mem.running, mem.delivered, mem.capa)
|
||||||
if mem.running then
|
if mem.running then
|
||||||
mem.delivered = power.secondary_alive(pos, mem, mem.capa, PWR_CAPA)
|
mem.delivered = power.secondary_alive(pos, mem, mem.capa, PWR_CAPA)
|
||||||
mem.capa = mem.capa - mem.delivered
|
mem.capa = mem.capa - mem.delivered
|
||||||
|
@ -24,7 +24,7 @@ local function transfer(pos, in_dir, topic, payload)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function swap_node(pos, name)
|
local function swap_node(pos, name)
|
||||||
local node = minetest.get_node(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
if node.name == name then
|
if node.name == name then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -23,7 +23,7 @@ local CYCLE_TIME = 2
|
|||||||
local BURN_CYCLE_FACTOR = 0.5
|
local BURN_CYCLE_FACTOR = 0.5
|
||||||
|
|
||||||
local function firehole(pos, on)
|
local function firehole(pos, on)
|
||||||
local param2 = minetest.get_node(pos).param2
|
local param2 = techage.get_node_lvm(pos).param2
|
||||||
local pos2 = techage.get_pos(pos, 'F')
|
local pos2 = techage.get_pos(pos, 'F')
|
||||||
if on == true then
|
if on == true then
|
||||||
minetest.swap_node(pos2, {name="techage:coalfirehole_on", param2 = param2})
|
minetest.swap_node(pos2, {name="techage:coalfirehole_on", param2 = param2})
|
||||||
|
@ -35,6 +35,8 @@ local function collect_network_data(pos, mem)
|
|||||||
solar = {},
|
solar = {},
|
||||||
akku = {},
|
akku = {},
|
||||||
stor = {},
|
stor = {},
|
||||||
|
elec = {},
|
||||||
|
fcel = {},
|
||||||
}
|
}
|
||||||
local add = function(kind, attr, val)
|
local add = function(kind, attr, val)
|
||||||
data[kind][attr] = (data[kind][attr] or 0) + (val or 0)
|
data[kind][attr] = (data[kind][attr] or 0) + (val or 0)
|
||||||
@ -51,11 +53,11 @@ local function collect_network_data(pos, mem)
|
|||||||
add("fuel", "curr", mem.provided)
|
add("fuel", "curr", mem.provided)
|
||||||
elseif node.name == "techage:ta3_akku" then
|
elseif node.name == "techage:ta3_akku" then
|
||||||
add("akku", "num", 1)
|
add("akku", "num", 1)
|
||||||
add("akku", "nomi", mem.pwr_available2)
|
add("akku", "nomi", mem.pwr_could_provide)
|
||||||
add("akku", "curr", mem.delivered)
|
add("akku", "curr", mem.delivered)
|
||||||
elseif node.name == "techage:heatexchanger1" then
|
elseif node.name == "techage:heatexchanger1" then
|
||||||
add("stor", "num", 1)
|
add("stor", "num", 1)
|
||||||
add("stor", "nomi", mem.pwr_available2)
|
add("stor", "nomi", mem.pwr_could_provide)
|
||||||
add("stor", "curr", mem.delivered)
|
add("stor", "curr", mem.delivered)
|
||||||
elseif node.name == "techage:tiny_generator" or node.name == "techage:tiny_generator_on" then
|
elseif node.name == "techage:tiny_generator" or node.name == "techage:tiny_generator_on" then
|
||||||
add("fuel", "num", 1)
|
add("fuel", "num", 1)
|
||||||
@ -69,6 +71,14 @@ local function collect_network_data(pos, mem)
|
|||||||
add("wind", "num", 1)
|
add("wind", "num", 1)
|
||||||
add("wind", "nomi", mem.pwr_available)
|
add("wind", "nomi", mem.pwr_available)
|
||||||
add("wind", "curr", mem.delivered)
|
add("wind", "curr", mem.delivered)
|
||||||
|
elseif node.name == "techage:ta4_fuelcell" or node.name == "techage:ta4_fuelcell_on" then
|
||||||
|
add("fcel", "num", 1)
|
||||||
|
add("fcel", "nomi", mem.pwr_available)
|
||||||
|
add("fcel", "curr", mem.provided)
|
||||||
|
elseif node.name == "techage:ta4_electrolyzer" or node.name == "techage:ta4_electrolyzer_on" then
|
||||||
|
add("elec", "num", 1)
|
||||||
|
add("elec", "nomi", -mem.pwr_could_need)
|
||||||
|
add("elec", "curr", -mem.consumed)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
@ -89,19 +99,21 @@ local function formspec(pos)
|
|||||||
if nnodes > (techage.MAX_NUM_NODES - 50) then
|
if nnodes > (techage.MAX_NUM_NODES - 50) then
|
||||||
alarm = " (max. "..(techage.MAX_NUM_NODES).." !!!)"
|
alarm = " (max. "..(techage.MAX_NUM_NODES).." !!!)"
|
||||||
end
|
end
|
||||||
return "size[10,6.5]"..
|
return "size[10,7.5]"..
|
||||||
default.gui_bg..
|
default.gui_bg..
|
||||||
default.gui_bg_img..
|
default.gui_bg_img..
|
||||||
default.gui_slots..
|
default.gui_slots..
|
||||||
"label[2,0.0;"..S("Network Data").."]"..
|
"label[2,0.0;"..S("Network Data").."]"..
|
||||||
"label[3,0.7;"..S("(number / current / max.)").."]"..
|
"label[3,0.7;"..S("(number / current / max.)").."]"..
|
||||||
"label[0,1.4;"..S("Power Fuel")..":]".. "label[4,1.4;"..get("fuel").."]"..
|
"label[0,1.4;"..S("TA3 Coal/oil")..":]".. "label[5,1.4;"..get("fuel").."]"..
|
||||||
"label[0,2.1;"..S("Power Solar")..":]".. "label[4,2.1;"..get("solar").."]"..
|
"label[0,2.1;"..S("TA3 Akku")..":]".. "label[5,2.1;"..get("akku").."]"..
|
||||||
"label[0,2.8;"..S("Power Wind")..":]".. "label[4,2.8;"..get("wind").."]"..
|
"label[0,2.8;"..S("TA4 Solar Inverter")..":]".. "label[5,2.8;"..get("solar").."]"..
|
||||||
"label[0,3.5;"..S("Power Storage")..":]".."label[4,3.5;"..get("stor").."]"..
|
"label[0,3.5;"..S("TA4 Wind Turbine")..":]".. "label[5,3.5;"..get("wind").."]"..
|
||||||
"label[0,4.2;"..S("Power Akkus")..":]".. "label[4,4.2;"..get("akku").."]"..
|
"label[0,4.2;"..S("TA4 Energy Storage")..":]".. "label[5,4.2;"..get("stor").."]"..
|
||||||
"label[0,4.9;"..S("Number nodes").." : "..nnodes..alarm.."]"..
|
"label[0,4.9;"..S("TA4 Electrolyzer")..":]".. "label[5,4.9;"..get("elec").."]"..
|
||||||
"button[2.5,5.8;2,1;update;"..S("Update").."]"
|
"label[0,5.6;"..S("TA4 Fuel Cell")..":]".. "label[5,5.6;"..get("fcel").."]"..
|
||||||
|
"label[0,6.3;"..S("Number of nodes").." : "..nnodes..alarm.."]"..
|
||||||
|
"button[2.5,6.8;2,1;update;"..S("Update").."]"
|
||||||
end
|
end
|
||||||
|
|
||||||
local function update_formspec(pos)
|
local function update_formspec(pos)
|
||||||
|
@ -29,7 +29,7 @@ local function transfer_generator(pos, topic, payload)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function swap_node(pos, name)
|
local function swap_node(pos, name)
|
||||||
local node = minetest.get_node(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
if node.name == name then
|
if node.name == name then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -111,5 +111,8 @@ techage.Items = {
|
|||||||
ta4_solarcarrier = "techage:ta4_solar_carrier",
|
ta4_solarcarrier = "techage:ta4_solar_carrier",
|
||||||
ta4_solar_inverter = "techage:ta4_solar_inverter",
|
ta4_solar_inverter = "techage:ta4_solar_inverter",
|
||||||
techage_ta4_solar = "techage_ta4_solar.png",
|
techage_ta4_solar = "techage_ta4_solar.png",
|
||||||
|
ta4_hydrogen = "techage_hydrogen_inv.png",
|
||||||
|
ta4_electrolyzer = "techage:ta4_electrolyzer",
|
||||||
|
ta4_fuelcell = "techage:ta4_fuelcell",
|
||||||
--ta4_ "",
|
--ta4_ "",
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ techage.manual_DE = {}
|
|||||||
techage.manual_DE.aTitel = {
|
techage.manual_DE.aTitel = {
|
||||||
"1,Tech Age Mod",
|
"1,Tech Age Mod",
|
||||||
"2,Hinweise",
|
"2,Hinweise",
|
||||||
|
"2,History",
|
||||||
"1,TA1: Eisenzeitalter",
|
"1,TA1: Eisenzeitalter",
|
||||||
"2,Köhler / Coal Pile",
|
"2,Köhler / Coal Pile",
|
||||||
"2,Kohlebrenner / Coal Burner",
|
"2,Kohlebrenner / Coal Burner",
|
||||||
@ -110,6 +111,9 @@ techage.manual_DE.aTitel = {
|
|||||||
"3,TA4 Turbine",
|
"3,TA4 Turbine",
|
||||||
"3,TA4 Generator",
|
"3,TA4 Generator",
|
||||||
"3,TA4 Röhre / Pipe",
|
"3,TA4 Röhre / Pipe",
|
||||||
|
"2,Wasserstoff",
|
||||||
|
"3,Elektrolyseur",
|
||||||
|
"3,Brennstoffzelle",
|
||||||
}
|
}
|
||||||
|
|
||||||
techage.manual_DE.aText = {
|
techage.manual_DE.aText = {
|
||||||
@ -144,6 +148,9 @@ techage.manual_DE.aText = {
|
|||||||
"\n"..
|
"\n"..
|
||||||
"Mit TA4 kommen weitere Stromquellen dazu\\, aber auch höhere logistische Herausforderungen (Stromtrassen\\, Item Transport).\n"..
|
"Mit TA4 kommen weitere Stromquellen dazu\\, aber auch höhere logistische Herausforderungen (Stromtrassen\\, Item Transport).\n"..
|
||||||
"\n",
|
"\n",
|
||||||
|
" - 28.09.2019: Um Solaranlage erweitert\n"..
|
||||||
|
" - 05.10.2019: Daten zur Solaranlage und Beschreibung zum Wechselrichter und zum Power-Terminal geändert\n"..
|
||||||
|
"\n",
|
||||||
"In TA1 geht es darum\\, mit einfachen Werkzeugen und Gerätschaften ausreichend Erze zu schürfen und Holzkohle herzustellen\\, so dass damit TA2 Maschinen hergestellt und betrieben werden können.\n"..
|
"In TA1 geht es darum\\, mit einfachen Werkzeugen und Gerätschaften ausreichend Erze zu schürfen und Holzkohle herzustellen\\, so dass damit TA2 Maschinen hergestellt und betrieben werden können.\n"..
|
||||||
"\n"..
|
"\n"..
|
||||||
"Natürlich muss es für ein Eisenzeitalter auch Eisen geben und nicht nur Stahl (steel)\\, wie in \"Minetest Game\". Daher wurden einige Rezepte geändert\\, so dass zuerst Eisen hergestellt werden muss und erst später dann Stahl.\n"..
|
"Natürlich muss es für ein Eisenzeitalter auch Eisen geben und nicht nur Stahl (steel)\\, wie in \"Minetest Game\". Daher wurden einige Rezepte geändert\\, so dass zuerst Eisen hergestellt werden muss und erst später dann Stahl.\n"..
|
||||||
@ -801,6 +808,8 @@ techage.manual_DE.aText = {
|
|||||||
"\n"..
|
"\n"..
|
||||||
"Die kleinste Einheit bei einer Solaranlage sind zwei Solarmodule und ein Trägermodul. Das Trägermodul muss zuerst gesetzt werden\\, die zwei Solarmodule dann links und rechts daneben (nicht darüber!).\n"..
|
"Die kleinste Einheit bei einer Solaranlage sind zwei Solarmodule und ein Trägermodul. Das Trägermodul muss zuerst gesetzt werden\\, die zwei Solarmodule dann links und rechts daneben (nicht darüber!).\n"..
|
||||||
"\n"..
|
"\n"..
|
||||||
|
"Der Plan rechts zeigt 3 Einheiten mit je zwei Solarmodulen und einem Trägermodul\\, über rote Kabel mit dem Wechselrichter verbunden.\n"..
|
||||||
|
"\n"..
|
||||||
"Solarmodule liefern Gleichspannung\\, welcher nicht direkt in das Stromnetz eingespeist werden kann. Daher müssen zuerst die Solareinheiten über das rote Kabel mit dem Wechselrichter verbunden werden. Dieser besteht aus zwei Blöcken\\, einen für das rote Kabel zu den Solarmodulen (DC) und einen für das graue Stromkabel ins Stromnetz (AC).\n"..
|
"Solarmodule liefern Gleichspannung\\, welcher nicht direkt in das Stromnetz eingespeist werden kann. Daher müssen zuerst die Solareinheiten über das rote Kabel mit dem Wechselrichter verbunden werden. Dieser besteht aus zwei Blöcken\\, einen für das rote Kabel zu den Solarmodulen (DC) und einen für das graue Stromkabel ins Stromnetz (AC).\n"..
|
||||||
"\n"..
|
"\n"..
|
||||||
"Der Kartenbereich\\, wo die Solaranlage steht\\, muss komplett geladen sein. Es empfiehlt sich daher\\, zuerst einen Forceload Block zu setzen\\, und dann innerhalb dieses Bereiches die Module zu platzieren.\n"..
|
"Der Kartenbereich\\, wo die Solaranlage steht\\, muss komplett geladen sein. Es empfiehlt sich daher\\, zuerst einen Forceload Block zu setzen\\, und dann innerhalb dieses Bereiches die Module zu platzieren.\n"..
|
||||||
@ -820,6 +829,7 @@ techage.manual_DE.aText = {
|
|||||||
"\n",
|
"\n",
|
||||||
"Der Wechselrichter wandelt den Solarstrom (DC) in Wechselstrom (AC) um\\, so dass dieser in das Stromnetz eingespeist werden kann.\n"..
|
"Der Wechselrichter wandelt den Solarstrom (DC) in Wechselstrom (AC) um\\, so dass dieser in das Stromnetz eingespeist werden kann.\n"..
|
||||||
"Ein Wechselrichter\\, bestehend aus zwei Blöcken kann maximal 100 ku an Strom einspeisen\\, was 33 Solarmodulen oder auch mehr entspricht.\n"..
|
"Ein Wechselrichter\\, bestehend aus zwei Blöcken kann maximal 100 ku an Strom einspeisen\\, was 33 Solarmodulen oder auch mehr entspricht.\n"..
|
||||||
|
"Der DC Block muss links neben den AC-Block gesetzt werden.\n"..
|
||||||
"\n"..
|
"\n"..
|
||||||
"\n"..
|
"\n"..
|
||||||
"\n",
|
"\n",
|
||||||
@ -877,11 +887,36 @@ techage.manual_DE.aText = {
|
|||||||
"\n"..
|
"\n"..
|
||||||
"\n"..
|
"\n"..
|
||||||
"\n",
|
"\n",
|
||||||
|
"Strom kann mittels Elektrolyse in Wasserstoff und Sauerstoff aufgespalten werden. Auf der anderen Seite kann über eine Brennstoffzelle Wasserstoff mit Sauerstoff aus der Luft wieder in Strom umgewandelt werden.\n"..
|
||||||
|
"Damit können Stromspitzen oder ein Überangebot an Strom in Wasserstoff umgewandelt und so gespeichert werden.\n"..
|
||||||
|
"\n"..
|
||||||
|
"Im Spiel kann Strom mit Hilfe des Elektrolyseurs in Wasserstoff-Items und Wasserstoff-Items über die Brennstoffzelle wieder in Strom umgewandelt werden.\n"..
|
||||||
|
"Damit kann Strom (in Form von Wasserstoff-Items) nicht nur in Kisten gelagert\\, sonder auch über Wagen (carts) oder Röhren transportiert werden.\n"..
|
||||||
|
"\n"..
|
||||||
|
"Die Umwandlung von Strom in Wasserstoff und zurück ist aber verlustbehaftet. Von 100 Einheiten Strom kommen nach der Umwandlung in Wasserstoff und zurück nur 75 Einheiten Strom wieder raus.\n"..
|
||||||
|
"\n"..
|
||||||
|
"\n"..
|
||||||
|
"\n",
|
||||||
|
"Der Elektrolyseur wandelt Strom in Wasserstoff um.\n"..
|
||||||
|
"Es muss von links mit Strom versorgt werden. Rechts können die Wasserstoff-Items per Schieber entnommen werden.\n"..
|
||||||
|
"\n"..
|
||||||
|
"Der Elektrolyseur kann bis zu 40 ku an Strom aufnehmen und generiert alle 8 s ein Wasserstoff Item.\n"..
|
||||||
|
"\n"..
|
||||||
|
"\n"..
|
||||||
|
"\n",
|
||||||
|
"Die Brennstoffzelle wandelt Wasserstoff in Strom um.\n"..
|
||||||
|
"Sie muss von links per Schieber mit Wasserstoff-Items versorgt werden. Rechts ist der Stromanschluss.\n"..
|
||||||
|
"\n"..
|
||||||
|
"Die Brennstoffzelle kann bis zu 40 ku an Strom abgeben und benötigt dazu alle 6 s ein Wasserstoff Item.\n"..
|
||||||
|
"\n"..
|
||||||
|
"\n"..
|
||||||
|
"\n",
|
||||||
}
|
}
|
||||||
|
|
||||||
techage.manual_DE.aItemName = {
|
techage.manual_DE.aItemName = {
|
||||||
"wlanchip",
|
"wlanchip",
|
||||||
"",
|
"",
|
||||||
|
"",
|
||||||
"techage_ta1",
|
"techage_ta1",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
@ -989,12 +1024,16 @@ techage.manual_DE.aItemName = {
|
|||||||
"ta4_turbine",
|
"ta4_turbine",
|
||||||
"ta4_generator",
|
"ta4_generator",
|
||||||
"ta4_pipe",
|
"ta4_pipe",
|
||||||
|
"ta4_hydrogen",
|
||||||
|
"ta4_electrolyzer",
|
||||||
|
"ta4_fuelcell",
|
||||||
}
|
}
|
||||||
|
|
||||||
techage.manual_DE.aPlanTable = {
|
techage.manual_DE.aPlanTable = {
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
"",
|
||||||
"coalpile",
|
"coalpile",
|
||||||
"coalburner",
|
"coalburner",
|
||||||
"",
|
"",
|
||||||
@ -1101,5 +1140,8 @@ techage.manual_DE.aPlanTable = {
|
|||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ local Cable = techage.ElectricCable
|
|||||||
local power = techage.power
|
local power = techage.power
|
||||||
|
|
||||||
local function swap_node(pos, name)
|
local function swap_node(pos, name)
|
||||||
local node = minetest.get_node(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
if node.name == name then
|
if node.name == name then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -87,7 +87,7 @@ local function stop_sound(pos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function swap_node(pos, name)
|
local function swap_node(pos, name)
|
||||||
local node = minetest.get_node(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
if node.name == name then
|
if node.name == name then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -113,6 +113,21 @@ local function charging(pos, mem, is_charging)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function delivering(pos, mem, delivered)
|
||||||
|
print("delivering", delivered, mem.had_delivered)
|
||||||
|
if mem.capa <= 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if delivered ~= mem.had_delivered then
|
||||||
|
mem.had_delivered = delivered
|
||||||
|
if delivered > 0 then
|
||||||
|
turbine_cmnd(pos, "start")
|
||||||
|
elseif delivered == 0 then
|
||||||
|
turbine_cmnd(pos, "stop")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function glowing(pos, mem, should_glow)
|
local function glowing(pos, mem, should_glow)
|
||||||
if mem.win_pos then
|
if mem.win_pos then
|
||||||
if should_glow then
|
if should_glow then
|
||||||
@ -171,9 +186,9 @@ local function start_node(pos, mem, state)
|
|||||||
mem.running = true
|
mem.running = true
|
||||||
mem.delivered = 0
|
mem.delivered = 0
|
||||||
mem.was_charging = true
|
mem.was_charging = true
|
||||||
|
mem.had_delivered = nil
|
||||||
play_sound(pos)
|
play_sound(pos)
|
||||||
mem.win_pos = inlet_cmnd(pos, "window")
|
mem.win_pos = inlet_cmnd(pos, "window")
|
||||||
turbine_cmnd(pos, "start")
|
|
||||||
power.secondary_start(pos, mem, PWR_PERF, PWR_PERF)
|
power.secondary_start(pos, mem, PWR_PERF, PWR_PERF)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -204,6 +219,7 @@ local function node_timer(pos, elapsed)
|
|||||||
mem.capa = in_range(mem.capa, 0, mem.capa_max)
|
mem.capa = in_range(mem.capa, 0, mem.capa_max)
|
||||||
glowing(pos, mem, mem.capa > mem.capa_max * 0.8)
|
glowing(pos, mem, mem.capa > mem.capa_max * 0.8)
|
||||||
charging(pos, mem, mem.delivered < 0)
|
charging(pos, mem, mem.delivered < 0)
|
||||||
|
delivering(pos, mem, mem.delivered)
|
||||||
end
|
end
|
||||||
return mem.running
|
return mem.running
|
||||||
end
|
end
|
||||||
|
@ -21,7 +21,7 @@ local CYCLE_TIME = 2
|
|||||||
local Pipe = techage.BiogasPipe
|
local Pipe = techage.BiogasPipe
|
||||||
|
|
||||||
local function swap_node(pos, name)
|
local function swap_node(pos, name)
|
||||||
local node = minetest.get_node(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
if node.name == name then
|
if node.name == name then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -28,7 +28,7 @@ local function infotext(pos, state)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function swap_node(pos, name)
|
local function swap_node(pos, name)
|
||||||
local node = minetest.get_node(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
if node.name == name then
|
if node.name == name then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -18,7 +18,7 @@ local S = techage.S
|
|||||||
local D = techage.Debug
|
local D = techage.Debug
|
||||||
|
|
||||||
-- Consumer Related Data
|
-- Consumer Related Data
|
||||||
local CRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).consumer end
|
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
|
||||||
|
|
||||||
local STANDBY_TICKS = 6
|
local STANDBY_TICKS = 6
|
||||||
local COUNTDOWN_TICKS = 6
|
local COUNTDOWN_TICKS = 6
|
||||||
|
270
hydrogen/electrolyzer.lua
Normal file
@ -0,0 +1,270 @@
|
|||||||
|
--[[
|
||||||
|
|
||||||
|
TechAge
|
||||||
|
=======
|
||||||
|
|
||||||
|
Copyright (C) 2019 Joachim Stolberg
|
||||||
|
|
||||||
|
GPL v3
|
||||||
|
See LICENSE.txt for more information
|
||||||
|
|
||||||
|
TA4 Electrolyzer
|
||||||
|
|
||||||
|
]]--
|
||||||
|
|
||||||
|
-- for lazy programmers
|
||||||
|
local M = minetest.get_meta
|
||||||
|
local S = techage.S
|
||||||
|
|
||||||
|
local Power = techage.ElectricCable
|
||||||
|
local power = techage.power
|
||||||
|
|
||||||
|
local CYCLE_TIME = 2
|
||||||
|
local STANDBY_TICKS = 5
|
||||||
|
local PWR_NEEDED = 40
|
||||||
|
local PWR_UNITS_PER_HYDROGEN_ITEM = 320
|
||||||
|
|
||||||
|
local function formspec(self, pos, mem)
|
||||||
|
return "size[8,6.6]"..
|
||||||
|
default.gui_bg..
|
||||||
|
default.gui_bg_img..
|
||||||
|
default.gui_slots..
|
||||||
|
"image[0.5,0;1,2;"..power.formspec_power_bar(PWR_NEEDED, mem.consumed).."]"..
|
||||||
|
"label[0.7,1.9;"..S("\\[ku\\]").."]"..
|
||||||
|
"image[3,0;1,1;techage_form_arrow_fg.png^[transformR270]"..
|
||||||
|
"image_button[4,1;1,1;".. self:get_state_button_image(mem) ..";state_button;]"..
|
||||||
|
"button[2.1,1;1.8,1;update;"..S("Update").."]"..
|
||||||
|
"list[context;dst;5.5,0;2,2;]"..
|
||||||
|
"list[current_player;main;0,2.8;8,4;]" ..
|
||||||
|
"listring[current_player;main]"..
|
||||||
|
"listring[context;dst]" ..
|
||||||
|
"listring[current_player;main]"..
|
||||||
|
default.get_hotbar_bg(0, 2.8)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function start_node(pos, mem, state)
|
||||||
|
mem.running = true
|
||||||
|
mem.consumed = 0
|
||||||
|
power.secondary_start(pos, mem, PWR_NEEDED, PWR_NEEDED)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function stop_node(pos, mem, state)
|
||||||
|
mem.running = false
|
||||||
|
mem.consumed = 0
|
||||||
|
power.secondary_stop(pos, mem)
|
||||||
|
end
|
||||||
|
|
||||||
|
local State = techage.NodeStates:new({
|
||||||
|
node_name_passive = "techage:ta4_electrolyzer",
|
||||||
|
node_name_active = "techage:ta4_electrolyzer_on",
|
||||||
|
cycle_time = CYCLE_TIME,
|
||||||
|
standby_ticks = STANDBY_TICKS,
|
||||||
|
formspec_func = formspec,
|
||||||
|
infotext_name = "TA4 Electrolyzer",
|
||||||
|
start_node = start_node,
|
||||||
|
stop_node = stop_node,
|
||||||
|
})
|
||||||
|
|
||||||
|
local function add_hydrogen(pos)
|
||||||
|
local inv = M(pos):get_inventory()
|
||||||
|
local leftover = inv:add_item("dst", ItemStack("techage:hydrogen"))
|
||||||
|
return leftover:get_count() == 0
|
||||||
|
end
|
||||||
|
|
||||||
|
local function room_for_hydrogen(pos)
|
||||||
|
local inv = M(pos):get_inventory()
|
||||||
|
return inv:room_for_item("dst", ItemStack("techage:hydrogen"))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- converts power into hydrogen
|
||||||
|
local function node_timer(pos, elapsed)
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
mem.num_pwr_units = mem.num_pwr_units or 0
|
||||||
|
--print("electrolyzer", mem.running, mem.consumed, mem.num_pwr_units, techage.get_state_string(mem))
|
||||||
|
if mem.running then
|
||||||
|
if techage.needs_power(mem) then
|
||||||
|
mem.consumed = -power.secondary_alive(pos, mem, 0, 1)
|
||||||
|
--print("mem.consumed", mem.consumed)
|
||||||
|
if mem.consumed > 0 then
|
||||||
|
mem.num_pwr_units = mem.num_pwr_units + mem.consumed
|
||||||
|
if mem.num_pwr_units >= PWR_UNITS_PER_HYDROGEN_ITEM then
|
||||||
|
if add_hydrogen(pos) then
|
||||||
|
mem.num_pwr_units = mem.num_pwr_units - PWR_UNITS_PER_HYDROGEN_ITEM
|
||||||
|
State:keep_running(pos, mem, 1, 0) -- count items
|
||||||
|
else
|
||||||
|
State:blocked(pos, mem)
|
||||||
|
power.secondary_stop(pos, mem)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
mem.consumed = -power.secondary_alive(pos, mem, 1, 1)
|
||||||
|
if room_for_hydrogen(pos) then
|
||||||
|
State:start(pos, mem)
|
||||||
|
power.secondary_start(pos, mem, PWR_NEEDED, PWR_NEEDED)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return mem.running
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_receive_fields(pos, formname, fields, player)
|
||||||
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
State:state_button_event(pos, mem, fields)
|
||||||
|
|
||||||
|
if fields.update then
|
||||||
|
M(pos):set_string("formspec", formspec(State, pos, mem))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function allow_metadata_inventory(pos, listname, index, stack, player)
|
||||||
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
if stack:get_name() == "techage:hydrogen" then
|
||||||
|
return stack:get_count()
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_rightclick(pos)
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
M(pos):set_string("formspec", formspec(State, pos, mem))
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node("techage:ta4_electrolyzer", {
|
||||||
|
description = S("TA4 Electrolyzer"),
|
||||||
|
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_outp.png",
|
||||||
|
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_hole_electric.png",
|
||||||
|
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_electrolyzer.png^techage_appl_ctrl_unit.png^[transformFX",
|
||||||
|
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_electrolyzer.png^techage_appl_ctrl_unit.png",
|
||||||
|
},
|
||||||
|
|
||||||
|
on_construct = function(pos)
|
||||||
|
local mem = tubelib2.init_mem(pos)
|
||||||
|
local number = techage.add_node(pos, "techage:ta4_electrolyzer")
|
||||||
|
mem.running = false
|
||||||
|
mem.num_pwr_units = 0
|
||||||
|
State:node_init(pos, mem, number)
|
||||||
|
local meta = M(pos)
|
||||||
|
meta:set_string("formspec", formspec(State, pos, mem))
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
inv:set_size('dst', 4)
|
||||||
|
end,
|
||||||
|
|
||||||
|
can_dig = function(pos, player)
|
||||||
|
local inv = M(pos):get_inventory()
|
||||||
|
return inv:is_empty("dst")
|
||||||
|
end,
|
||||||
|
|
||||||
|
allow_metadata_inventory_put = allow_metadata_inventory,
|
||||||
|
allow_metadata_inventory_take = allow_metadata_inventory,
|
||||||
|
on_receive_fields = on_receive_fields,
|
||||||
|
on_timer = node_timer,
|
||||||
|
on_rightclick = on_rightclick,
|
||||||
|
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {cracky=2, crumbly=2, choppy=2},
|
||||||
|
on_rotate = screwdriver.disallow,
|
||||||
|
is_ground_content = false,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("techage:ta4_electrolyzer_on", {
|
||||||
|
description = S("TA4 Electrolyzer"),
|
||||||
|
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_outp.png",
|
||||||
|
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_hole_electric.png",
|
||||||
|
{
|
||||||
|
image = "techage_filling4_ta4.png^techage_frame4_ta4.png^techage_appl_electrolyzer4.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_electrolyzer4.png^techage_appl_ctrl_unit4.png",
|
||||||
|
backface_culling = false,
|
||||||
|
animation = {
|
||||||
|
type = "vertical_frames",
|
||||||
|
aspect_w = 32,
|
||||||
|
aspect_h = 32,
|
||||||
|
length = 0.8,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
allow_metadata_inventory_put = allow_metadata_inventory,
|
||||||
|
allow_metadata_inventory_take = allow_metadata_inventory,
|
||||||
|
on_receive_fields = on_receive_fields,
|
||||||
|
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,
|
||||||
|
})
|
||||||
|
|
||||||
|
techage.power.register_node({"techage:ta4_electrolyzer", "techage:ta4_electrolyzer_on"}, {
|
||||||
|
conn_sides = {"L"},
|
||||||
|
power_network = Power,
|
||||||
|
after_place_node = function(pos)
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
local indir = techage.side_to_indir("R", node.param2)
|
||||||
|
M(pos):set_int("in_dir", indir)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
techage.register_node({"techage:ta4_electrolyzer", "techage:ta4_electrolyzer_on"}, {
|
||||||
|
on_pull_item = function(pos, in_dir, num)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if meta:get_int("in_dir") == in_dir then
|
||||||
|
local inv = M(pos):get_inventory()
|
||||||
|
return techage.get_items(inv, "dst", num)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
on_push_item = function(pos, in_dir, stack)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if meta:get_int("in_dir") == in_dir then
|
||||||
|
local inv = M(pos):get_inventory()
|
||||||
|
State:start_if_standby(pos)
|
||||||
|
return techage.put_items(inv, "dst", stack)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
on_unpull_item = function(pos, in_dir, stack)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if meta:get_int("in_dir") == in_dir then
|
||||||
|
local inv = M(pos):get_inventory()
|
||||||
|
return techage.put_items(inv, "dst", stack)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
on_recv_message = function(pos, src, topic, payload)
|
||||||
|
return State:on_receive_message(pos, topic, payload)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "techage:ta4_electrolyzer",
|
||||||
|
recipe = {
|
||||||
|
{'default:steel_ingot', 'dye:blue', 'default:steel_ingot'},
|
||||||
|
{'techage:electric_cableS', 'default:glass', 'techage:tubeS'},
|
||||||
|
{'default:steel_ingot', "techage:ta4_wlanchip", 'default:steel_ingot'},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
271
hydrogen/fuelcell.lua
Normal file
@ -0,0 +1,271 @@
|
|||||||
|
--[[
|
||||||
|
|
||||||
|
TechAge
|
||||||
|
=======
|
||||||
|
|
||||||
|
Copyright (C) 2019 Joachim Stolberg
|
||||||
|
|
||||||
|
GPL v3
|
||||||
|
See LICENSE.txt for more information
|
||||||
|
|
||||||
|
TA4 Fuel Cell
|
||||||
|
|
||||||
|
]]--
|
||||||
|
|
||||||
|
-- for lazy programmers
|
||||||
|
local M = minetest.get_meta
|
||||||
|
local S = techage.S
|
||||||
|
|
||||||
|
local Power = techage.ElectricCable
|
||||||
|
local power = techage.power
|
||||||
|
|
||||||
|
local CYCLE_TIME = 2
|
||||||
|
local STANDBY_TICKS = 5
|
||||||
|
local PWR_CAPA = 40
|
||||||
|
local PWR_UNITS_PER_HYDROGEN_ITEM = 240
|
||||||
|
|
||||||
|
local function formspec(self, pos, mem)
|
||||||
|
return "size[8,6.6]"..
|
||||||
|
default.gui_bg..
|
||||||
|
default.gui_bg_img..
|
||||||
|
default.gui_slots..
|
||||||
|
"list[context;src;0.5,0;2,2;]"..
|
||||||
|
"image[4,0;1,1;techage_form_arrow_fg.png^[transformR270]"..
|
||||||
|
"image_button[5,1;1,1;".. self:get_state_button_image(mem) ..";state_button;]"..
|
||||||
|
"button[3.1,1;1.8,1;update;"..S("Update").."]"..
|
||||||
|
"image[6.5,0;1,2;"..power.formspec_power_bar(PWR_CAPA, mem.provided).."]"..
|
||||||
|
"label[6.7,1.9;"..S("\\[ku\\]").."]"..
|
||||||
|
"list[current_player;main;0,2.8;8,4;]" ..
|
||||||
|
"listring[current_player;main]"..
|
||||||
|
"listring[context;src]" ..
|
||||||
|
"listring[current_player;main]"..
|
||||||
|
default.get_hotbar_bg(0, 2.8)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function start_node(pos, mem, state)
|
||||||
|
mem.running = true
|
||||||
|
mem.provided = 0
|
||||||
|
power.generator_start(pos, mem, PWR_CAPA)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function stop_node(pos, mem, state)
|
||||||
|
mem.running = false
|
||||||
|
mem.provided = 0
|
||||||
|
power.generator_stop(pos, mem)
|
||||||
|
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 = "TA4 Fuel Cell",
|
||||||
|
start_node = start_node,
|
||||||
|
stop_node = stop_node,
|
||||||
|
})
|
||||||
|
|
||||||
|
local function get_hydrogen(pos)
|
||||||
|
local inv = M(pos):get_inventory()
|
||||||
|
local taken = inv:remove_item("src", ItemStack("techage:hydrogen"))
|
||||||
|
return taken:get_count() > 0
|
||||||
|
end
|
||||||
|
|
||||||
|
local function contains_hydrogen(pos)
|
||||||
|
local inv = M(pos):get_inventory()
|
||||||
|
return inv:contains_item("src", ItemStack("techage:hydrogen"))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- converts hydrogen into power
|
||||||
|
local function node_timer(pos, elapsed)
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
mem.num_pwr_units = mem.num_pwr_units or 0
|
||||||
|
--print("fuelcell", mem.running, mem.provided, mem.num_pwr_units, techage.get_state_string(mem))
|
||||||
|
if mem.running then
|
||||||
|
if techage.needs_power(mem) then
|
||||||
|
if mem.num_pwr_units <= 0 then
|
||||||
|
if get_hydrogen(pos) then
|
||||||
|
State:keep_running(pos, mem, 1, 0) -- count items
|
||||||
|
mem.num_pwr_units = mem.num_pwr_units + PWR_UNITS_PER_HYDROGEN_ITEM
|
||||||
|
else
|
||||||
|
State:standby(pos, mem)
|
||||||
|
mem.provided = 0
|
||||||
|
power.generator_stop(pos, mem)
|
||||||
|
M(pos):set_string("formspec", formspec(State, pos, mem))
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
mem.provided = power.generator_alive(pos, mem)
|
||||||
|
mem.num_pwr_units = mem.num_pwr_units - mem.provided
|
||||||
|
else
|
||||||
|
if contains_hydrogen(pos) then
|
||||||
|
State:start(pos, mem)
|
||||||
|
mem.provided = 0
|
||||||
|
power.generator_start(pos, mem, PWR_CAPA)
|
||||||
|
M(pos):set_string("formspec", formspec(State, pos, mem))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return mem.running
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_receive_fields(pos, formname, fields, player)
|
||||||
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
State:state_button_event(pos, mem, fields)
|
||||||
|
|
||||||
|
if fields.update then
|
||||||
|
M(pos):set_string("formspec", formspec(State, pos, mem))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function allow_metadata_inventory(pos, listname, index, stack, player)
|
||||||
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
if stack:get_name() == "techage:hydrogen" then
|
||||||
|
return stack:get_count()
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_rightclick(pos)
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
M(pos):set_string("formspec", formspec(State, pos, mem))
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node("techage:ta4_fuelcell", {
|
||||||
|
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_inp.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",
|
||||||
|
},
|
||||||
|
|
||||||
|
on_construct = function(pos)
|
||||||
|
local mem = tubelib2.init_mem(pos)
|
||||||
|
local number = techage.add_node(pos, "techage:ta4_fuelcell")
|
||||||
|
mem.running = false
|
||||||
|
mem.num_pwr_units = 0
|
||||||
|
State:node_init(pos, mem, number)
|
||||||
|
local meta = M(pos)
|
||||||
|
meta:set_string("formspec", formspec(State, pos, mem))
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
inv:set_size('src', 4)
|
||||||
|
end,
|
||||||
|
|
||||||
|
can_dig = function(pos, player)
|
||||||
|
local inv = M(pos):get_inventory()
|
||||||
|
return inv:is_empty("src")
|
||||||
|
end,
|
||||||
|
|
||||||
|
allow_metadata_inventory_put = allow_metadata_inventory,
|
||||||
|
allow_metadata_inventory_take = allow_metadata_inventory,
|
||||||
|
on_receive_fields = on_receive_fields,
|
||||||
|
on_timer = node_timer,
|
||||||
|
on_rightclick = on_rightclick,
|
||||||
|
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {cracky=2, crumbly=2, choppy=2},
|
||||||
|
on_rotate = screwdriver.disallow,
|
||||||
|
is_ground_content = false,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("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_inp.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,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
allow_metadata_inventory_put = allow_metadata_inventory,
|
||||||
|
allow_metadata_inventory_take = allow_metadata_inventory,
|
||||||
|
on_receive_fields = on_receive_fields,
|
||||||
|
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,
|
||||||
|
})
|
||||||
|
|
||||||
|
techage.power.register_node({"techage:ta4_fuelcell", "techage:ta4_fuelcell_on"}, {
|
||||||
|
conn_sides = {"R"},
|
||||||
|
power_network = Power,
|
||||||
|
after_place_node = function(pos)
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
local indir = techage.side_to_indir("L", node.param2)
|
||||||
|
M(pos):set_int("in_dir", indir)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
techage.register_node({"techage:ta4_fuelcell", "techage:ta4_fuelcell_on"}, {
|
||||||
|
on_pull_item = function(pos, in_dir, num)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if meta:get_int("in_dir") == in_dir then
|
||||||
|
local inv = M(pos):get_inventory()
|
||||||
|
return techage.get_items(inv, "src", num)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
on_push_item = function(pos, in_dir, stack)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if meta:get_int("in_dir") == in_dir then
|
||||||
|
local inv = M(pos):get_inventory()
|
||||||
|
State:start_if_standby(pos)
|
||||||
|
return techage.put_items(inv, "src", stack)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
on_unpull_item = function(pos, in_dir, stack)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
if meta:get_int("in_dir") == in_dir then
|
||||||
|
local inv = M(pos):get_inventory()
|
||||||
|
return techage.put_items(inv, "src", stack)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
on_recv_message = function(pos, src, topic, payload)
|
||||||
|
return State:on_receive_message(pos, topic, payload)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "techage:ta4_fuelcell",
|
||||||
|
recipe = {
|
||||||
|
{'default:steel_ingot', 'dye:blue', 'default:steel_ingot'},
|
||||||
|
{'techage:tubeS', 'techage:ta4_fuelcellstack', 'techage:electric_cableS'},
|
||||||
|
{'default:steel_ingot', "techage:ta4_wlanchip", 'default:steel_ingot'},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
34
hydrogen/hydrogen.lua
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
--[[
|
||||||
|
|
||||||
|
TechAge
|
||||||
|
=======
|
||||||
|
|
||||||
|
Copyright (C) 2019 Joachim Stolberg
|
||||||
|
|
||||||
|
GPL v3
|
||||||
|
See LICENSE.txt for more information
|
||||||
|
|
||||||
|
TA4 Hydrogen
|
||||||
|
|
||||||
|
]]--
|
||||||
|
|
||||||
|
local S = techage.S
|
||||||
|
|
||||||
|
minetest.register_craftitem("techage:hydrogen", {
|
||||||
|
description = S("TA4 Hydrogen"),
|
||||||
|
inventory_image = "techage_hydrogen_inv.png",
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craftitem("techage:ta4_fuelcellstack", {
|
||||||
|
description = S("TA4 Fuell Cell Stack"),
|
||||||
|
inventory_image = "techage_fc_stack_inv.png",
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "techage:ta4_fuelcellstack",
|
||||||
|
recipe = {
|
||||||
|
{'techage:baborium_ingot', 'techage:ta4_carbon_fiber', 'default:copper_ingot'},
|
||||||
|
{'default:gold_ingot', 'techage:ta4_carbon_fiber', 'default:tin_ingot'},
|
||||||
|
{"techage:baborium_ingot", 'techage:ta4_carbon_fiber', 'default:copper_ingot'},
|
||||||
|
},
|
||||||
|
})
|
4
init.lua
@ -201,4 +201,8 @@ else
|
|||||||
dofile(MP.."/energy_storage/inlet.lua")
|
dofile(MP.."/energy_storage/inlet.lua")
|
||||||
dofile(MP.."/energy_storage/nodes.lua")
|
dofile(MP.."/energy_storage/nodes.lua")
|
||||||
|
|
||||||
|
-- Hydrogen
|
||||||
|
dofile(MP.."/hydrogen/hydrogen.lua")
|
||||||
|
dofile(MP.."/hydrogen/electrolyzer.lua")
|
||||||
|
dofile(MP.."/hydrogen/fuelcell.lua")
|
||||||
end
|
end
|
@ -22,7 +22,7 @@ local get_random_basalt_ore = techage.gravelsieve_get_random_basalt_ore
|
|||||||
|
|
||||||
-- handle the sieve animation
|
-- handle the sieve animation
|
||||||
local function swap_node(pos)
|
local function swap_node(pos)
|
||||||
local node = minetest.get_node(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
local idx = string.byte(node.name, -1) - 48
|
local idx = string.byte(node.name, -1) - 48
|
||||||
idx = (idx + 1) % 4
|
idx = (idx + 1) % 4
|
||||||
minetest.swap_node(pos, {name = "techage:sieve"..idx, param2 = node.param2})
|
minetest.swap_node(pos, {name = "techage:sieve"..idx, param2 = node.param2})
|
||||||
@ -31,7 +31,7 @@ end
|
|||||||
|
|
||||||
local function push_items(pos, items)
|
local function push_items(pos, items)
|
||||||
local pos1 = {x=pos.x, y=pos.y-1, z=pos.z}
|
local pos1 = {x=pos.x, y=pos.y-1, z=pos.z}
|
||||||
local node = minetest.get_node(pos1)
|
local node = techage.get_node_lvm(pos1)
|
||||||
minetest.add_item({x=pos.x, y=pos.y-0.4, z=pos.z}, items)
|
minetest.add_item({x=pos.x, y=pos.y-0.4, z=pos.z}, items)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ end
|
|||||||
local function get_heat(pos)
|
local function get_heat(pos)
|
||||||
local heat = 0
|
local heat = 0
|
||||||
pos.y = pos.y - 1
|
pos.y = pos.y - 1
|
||||||
local node = minetest.get_node(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if minetest.get_item_group(node.name, "techage_flame") == 0 then
|
if minetest.get_item_group(node.name, "techage_flame") == 0 then
|
||||||
pos.y = pos.y + 1
|
pos.y = pos.y + 1
|
||||||
@ -212,7 +212,7 @@ local function get_heat(pos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
pos.y = pos.y - 1
|
pos.y = pos.y - 1
|
||||||
node = minetest.get_node(pos)
|
node = techage.get_node_lvm(pos)
|
||||||
pos.y = pos.y + 2
|
pos.y = pos.y + 2
|
||||||
if minetest.get_item_group(node.name, "techage_flame") == 0 and
|
if minetest.get_item_group(node.name, "techage_flame") == 0 and
|
||||||
node.name ~= "techage:charcoal_burn" then
|
node.name ~= "techage:charcoal_burn" then
|
||||||
|
@ -57,7 +57,7 @@ Network Data=Netzwerkdaten
|
|||||||
No plan available=Kein Plan verfügar
|
No plan available=Kein Plan verfügar
|
||||||
No wind at this altitude!=Kein Wind auf dieser Höhe
|
No wind at this altitude!=Kein Wind auf dieser Höhe
|
||||||
Node owner=Blockbesitzer
|
Node owner=Blockbesitzer
|
||||||
Number nodes=Blocknummern
|
Number of nodes=Anzahl Blöcke
|
||||||
Oil Drill Box=Ölbohrkiste
|
Oil Drill Box=Ölbohrkiste
|
||||||
Oil Pumpjack=Ölpumpe
|
Oil Pumpjack=Ölpumpe
|
||||||
Oil Source=Erdöl
|
Oil Source=Erdöl
|
||||||
@ -67,15 +67,14 @@ Plan=Plan
|
|||||||
Position=Position
|
Position=Position
|
||||||
Position temperature=Positionstemperatur
|
Position temperature=Positionstemperatur
|
||||||
Power=Energie
|
Power=Energie
|
||||||
Power Akkus=Strom Akkus
|
Primary available=Primär verfügbar
|
||||||
Power Fuel=Strom Kohle/Öl
|
Primary needed=Primär benötigt
|
||||||
Power Solar=Strom Solar
|
|
||||||
Power Storage=Strom Speicher
|
|
||||||
Power Wind=Strom Wind
|
|
||||||
Pusher=Schieber
|
Pusher=Schieber
|
||||||
Remove derrick=Entferne Ölturm
|
Remove derrick=Entferne Ölturm
|
||||||
Rinsing=Waschen
|
Rinsing=Waschen
|
||||||
Save=Speichern
|
Save=Speichern
|
||||||
|
Secondary available=Sekundär verfügbar
|
||||||
|
Secondary needed=Sekundär benötigt
|
||||||
Send signal if nodes have been:=Sende ein Signal falls Blöcke:
|
Send signal if nodes have been:=Sende ein Signal falls Blöcke:
|
||||||
Sieved Basalt Gravel=Basaltkies gesiebt
|
Sieved Basalt Gravel=Basaltkies gesiebt
|
||||||
Sieved Gravel=Gesiebtes Kies
|
Sieved Gravel=Gesiebtes Kies
|
||||||
@ -124,6 +123,7 @@ TA2 Gearbox=TA2 Getriebeblock
|
|||||||
TA2 Gravel Sieve=TA2 Kiessieb
|
TA2 Gravel Sieve=TA2 Kiessieb
|
||||||
TA2 Protected Chest=TA2 Gesicherte Kiste
|
TA2 Protected Chest=TA2 Gesicherte Kiste
|
||||||
TA2 Steam Pipe=TA2 Dampfleitung
|
TA2 Steam Pipe=TA2 Dampfleitung
|
||||||
|
TA3 Akku=TA3 Akku
|
||||||
TA3 Akku Box=TA3 Akku Block
|
TA3 Akku Box=TA3 Akku Block
|
||||||
TA3 Boiler Base=TA3 Boiler unten
|
TA3 Boiler Base=TA3 Boiler unten
|
||||||
TA3 Boiler Top=TA3 Boiler oben
|
TA3 Boiler Top=TA3 Boiler oben
|
||||||
@ -131,6 +131,7 @@ TA3 Booster=TA3 Gebläse
|
|||||||
TA3 Button/Switch=TA3 Taster/Schalter
|
TA3 Button/Switch=TA3 Taster/Schalter
|
||||||
TA3 Cart Detector=TA3 Wagen Detektor
|
TA3 Cart Detector=TA3 Wagen Detektor
|
||||||
TA3 Coal Power Station Firebox=TA3 Kohlekraftwerks-Feuerbox
|
TA3 Coal Power Station Firebox=TA3 Kohlekraftwerks-Feuerbox
|
||||||
|
TA3 Coal/oil=TA3 Kohle/Öl
|
||||||
TA3 Cooler=TA3 Kühler
|
TA3 Cooler=TA3 Kühler
|
||||||
TA3 Derrick=TA3 Bohrturm
|
TA3 Derrick=TA3 Bohrturm
|
||||||
TA3 Detector=TA3 Detektor
|
TA3 Detector=TA3 Detektor
|
||||||
@ -158,12 +159,16 @@ TA3 Turbine=TA3 Turbine
|
|||||||
TA3 Vacuum Tube=TA3 Vakuumröhre
|
TA3 Vacuum Tube=TA3 Vakuumröhre
|
||||||
TA4 Carbon Fiber=TA4 Kohlefaser
|
TA4 Carbon Fiber=TA4 Kohlefaser
|
||||||
TA4 Derrick=TA4 Bohrturm
|
TA4 Derrick=TA4 Bohrturm
|
||||||
|
TA4 Electrolyzer=TA4 Elektrolyseur
|
||||||
|
TA4 Energy Storage=TA4 Energiespeicher
|
||||||
TA4 Epoxide Resin=TA4 Epoxidharz
|
TA4 Epoxide Resin=TA4 Epoxidharz
|
||||||
|
TA4 Fuel Cell=TA4 Brennstoffzelle
|
||||||
TA4 Generator=TA4 Generator
|
TA4 Generator=TA4 Generator
|
||||||
TA4 Heat Exchanger=TA4 Wärmetauscher
|
TA4 Heat Exchanger=TA4 Wärmetauscher
|
||||||
TA4 Heat Exchanger 1=TA4 Wärmetauscher 1
|
TA4 Heat Exchanger 1=TA4 Wärmetauscher 1
|
||||||
TA4 Heat Exchanger 2=TA4 Wärmetauscher 2
|
TA4 Heat Exchanger 2=TA4 Wärmetauscher 2
|
||||||
TA4 Heat Exchanger 3=TA4 Wärmetauscher 3
|
TA4 Heat Exchanger 3=TA4 Wärmetauscher 3
|
||||||
|
TA4 Hydrogen=TA4 Wasserstoff
|
||||||
TA4 Junction Pipe=TA4 Verbindungsrohr
|
TA4 Junction Pipe=TA4 Verbindungsrohr
|
||||||
TA4 Low Power Box==TA4 Niederspannungsverteilerbox
|
TA4 Low Power Box==TA4 Niederspannungsverteilerbox
|
||||||
TA4 Low Power Cable=TA4 Niederspannungskabel
|
TA4 Low Power Cable=TA4 Niederspannungskabel
|
||||||
@ -216,6 +221,7 @@ Wrong place for wind turbines!=Falscher Ort für Windkraftanlagen
|
|||||||
[TechAge Programmer] node programmed!=[TechAge Programmer] Nicht programmiert!
|
[TechAge Programmer] node programmed!=[TechAge Programmer] Nicht programmiert!
|
||||||
[TechAge Programmer] number=[TechAge Programmer] Nummer=
|
[TechAge Programmer] number=[TechAge Programmer] Nummer=
|
||||||
[TechAge Programmer] programmer reset=[TechAge Programmer] Programmer zurück gesetzt
|
[TechAge Programmer] programmer reset=[TechAge Programmer] Programmer zurück gesetzt
|
||||||
|
\\[ku\\]=\\[ku\\]
|
||||||
accept=akzeptieren
|
accept=akzeptieren
|
||||||
added=hinzugefügt wird
|
added=hinzugefügt wird
|
||||||
added or removed=hinzugefügt oder entfernt wird
|
added or removed=hinzugefügt oder entfernt wird
|
||||||
|
@ -55,7 +55,7 @@ Network Data=
|
|||||||
No plan available=
|
No plan available=
|
||||||
No wind at this altitude!=
|
No wind at this altitude!=
|
||||||
Node owner=
|
Node owner=
|
||||||
Number nodes=
|
Number of nodes=
|
||||||
Oil Drill Box=
|
Oil Drill Box=
|
||||||
Oil Pumpjack=
|
Oil Pumpjack=
|
||||||
Oil Source=
|
Oil Source=
|
||||||
@ -65,15 +65,14 @@ Plan=
|
|||||||
Position=
|
Position=
|
||||||
Position temperature=
|
Position temperature=
|
||||||
Power=
|
Power=
|
||||||
Power Akkus=
|
Primary available=
|
||||||
Power Fuel=
|
Primary needed=
|
||||||
Power Solar=
|
|
||||||
Power Storage=
|
|
||||||
Power Wind=
|
|
||||||
Pusher=
|
Pusher=
|
||||||
Remove derrick=
|
Remove derrick=
|
||||||
Rinsing=
|
Rinsing=
|
||||||
Save=
|
Save=
|
||||||
|
Secondary available=
|
||||||
|
Secondary needed=
|
||||||
Send signal if nodes have been:=
|
Send signal if nodes have been:=
|
||||||
Sieved Basalt Gravel=
|
Sieved Basalt Gravel=
|
||||||
Sieved Gravel=
|
Sieved Gravel=
|
||||||
@ -122,6 +121,7 @@ TA2 Gearbox=
|
|||||||
TA2 Gravel Sieve=
|
TA2 Gravel Sieve=
|
||||||
TA2 Protected Chest=
|
TA2 Protected Chest=
|
||||||
TA2 Steam Pipe=
|
TA2 Steam Pipe=
|
||||||
|
TA3 Akku=
|
||||||
TA3 Akku Box=
|
TA3 Akku Box=
|
||||||
TA3 Boiler Base=
|
TA3 Boiler Base=
|
||||||
TA3 Boiler Top=
|
TA3 Boiler Top=
|
||||||
@ -129,6 +129,7 @@ TA3 Booster=
|
|||||||
TA3 Button/Switch=
|
TA3 Button/Switch=
|
||||||
TA3 Cart Detector=
|
TA3 Cart Detector=
|
||||||
TA3 Coal Power Station Firebox=
|
TA3 Coal Power Station Firebox=
|
||||||
|
TA3 Coal/oil=
|
||||||
TA3 Cooler=
|
TA3 Cooler=
|
||||||
TA3 Derrick=
|
TA3 Derrick=
|
||||||
TA3 Detector=
|
TA3 Detector=
|
||||||
@ -156,12 +157,16 @@ TA3 Turbine=
|
|||||||
TA3 Vacuum Tube=
|
TA3 Vacuum Tube=
|
||||||
TA4 Carbon Fiber=
|
TA4 Carbon Fiber=
|
||||||
TA4 Derrick=
|
TA4 Derrick=
|
||||||
|
TA4 Electrolyzer=
|
||||||
|
TA4 Energy Storage=
|
||||||
TA4 Epoxide Resin=
|
TA4 Epoxide Resin=
|
||||||
|
TA4 Fuel Cell=
|
||||||
TA4 Generator=
|
TA4 Generator=
|
||||||
TA4 Heat Exchanger=
|
TA4 Heat Exchanger=
|
||||||
TA4 Heat Exchanger 1=
|
TA4 Heat Exchanger 1=
|
||||||
TA4 Heat Exchanger 2=
|
TA4 Heat Exchanger 2=
|
||||||
TA4 Heat Exchanger 3=
|
TA4 Heat Exchanger 3=
|
||||||
|
TA4 Hydrogen=
|
||||||
TA4 Junction Pipe=
|
TA4 Junction Pipe=
|
||||||
TA4 Low Power Box=
|
TA4 Low Power Box=
|
||||||
TA4 Low Power Cable=
|
TA4 Low Power Cable=
|
||||||
@ -214,6 +219,7 @@ Wrong place for wind turbines!=
|
|||||||
[TechAge Programmer] node programmed!=
|
[TechAge Programmer] node programmed!=
|
||||||
[TechAge Programmer] number=
|
[TechAge Programmer] number=
|
||||||
[TechAge Programmer] programmer reset=
|
[TechAge Programmer] programmer reset=
|
||||||
|
\\[ku\\]=
|
||||||
accept=
|
accept=
|
||||||
added=
|
added=
|
||||||
added or removed=
|
added or removed=
|
||||||
|
@ -40,7 +40,7 @@ function techage.logic.dest_pos(pos, param2, route)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function techage.logic.swap_node(pos, name)
|
function techage.logic.swap_node(pos, name)
|
||||||
local node = minetest.get_node(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
if node.name == name then
|
if node.name == name then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
@ -114,10 +114,10 @@ minetest.register_node("techage:signal_lamp_on", {
|
|||||||
techage.register_node({"techage:signal_lamp_off", "techage:signal_lamp_on"}, {
|
techage.register_node({"techage:signal_lamp_off", "techage:signal_lamp_on"}, {
|
||||||
on_recv_message = function(pos, src, topic, payload)
|
on_recv_message = function(pos, src, topic, payload)
|
||||||
if topic == "on" then
|
if topic == "on" then
|
||||||
local node = minetest.get_node(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
switch_on(pos, node)
|
switch_on(pos, node)
|
||||||
elseif topic == "off" then
|
elseif topic == "off" then
|
||||||
local node = minetest.get_node(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
switch_off(pos, node)
|
switch_off(pos, node)
|
||||||
else
|
else
|
||||||
return "unsupported"
|
return "unsupported"
|
||||||
|
@ -179,3 +179,41 @@ Die Röhren dienen bei TA4 zur Weiterleitung von Gas und Dampf.
|
|||||||
Die maximale Leitungslänge beträgt 100 m.
|
Die maximale Leitungslänge beträgt 100 m.
|
||||||
|
|
||||||
[ta4_pipe|image]
|
[ta4_pipe|image]
|
||||||
|
|
||||||
|
|
||||||
|
## Wasserstoff
|
||||||
|
|
||||||
|
Strom kann mittels Elektrolyse in Wasserstoff und Sauerstoff aufgespalten werden. Auf der anderen Seite kann über eine Brennstoffzelle Wasserstoff mit Sauerstoff aus der Luft wieder in Strom umgewandelt werden.
|
||||||
|
Damit können Stromspitzen oder ein Überangebot an Strom in Wasserstoff umgewandelt und so gespeichert werden.
|
||||||
|
|
||||||
|
Im Spiel kann Strom mit Hilfe des Elektrolyseurs in Wasserstoff-Items und Wasserstoff-Items über die Brennstoffzelle wieder in Strom umgewandelt werden.
|
||||||
|
Damit kann Strom (in Form von Wasserstoff-Items) nicht nur in Kisten gelagert, sonder auch über Wagen (carts) oder Röhren transportiert werden.
|
||||||
|
|
||||||
|
Die Umwandlung von Strom in Wasserstoff und zurück ist aber verlustbehaftet. Von 100 Einheiten Strom kommen nach der Umwandlung in Wasserstoff und zurück nur 75 Einheiten Strom wieder raus.
|
||||||
|
|
||||||
|
[ta4_hydrogen|image]
|
||||||
|
|
||||||
|
|
||||||
|
### Elektrolyseur
|
||||||
|
|
||||||
|
Der Elektrolyseur wandelt Strom in Wasserstoff um.
|
||||||
|
Es muss von links mit Strom versorgt werden. Rechts können die Wasserstoff-Items per Schieber entnommen werden.
|
||||||
|
|
||||||
|
Der Elektrolyseur kann bis zu 40 ku an Strom aufnehmen und generiert alle 8 s ein Wasserstoff Item.
|
||||||
|
|
||||||
|
[ta4_electrolyzer|image]
|
||||||
|
|
||||||
|
|
||||||
|
### Brennstoffzelle
|
||||||
|
|
||||||
|
Die Brennstoffzelle wandelt Wasserstoff in Strom um.
|
||||||
|
Sie muss von links per Schieber mit Wasserstoff-Items versorgt werden. Rechts ist der Stromanschluss.
|
||||||
|
|
||||||
|
Die Brennstoffzelle kann bis zu 40 ku an Strom abgeben und benötigt dazu alle 6 s ein Wasserstoff Item.
|
||||||
|
|
||||||
|
[ta4_fuelcell|image]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
- [Tech Age Mod](./manual_DE.md#tech-age-mod)
|
- [Tech Age Mod](./manual_DE.md#tech-age-mod)
|
||||||
- [Hinweise](./manual_DE.md#hinweise)
|
- [Hinweise](./manual_DE.md#hinweise)
|
||||||
|
- [History](./manual_DE.md#history)
|
||||||
- [TA1: Eisenzeitalter](./manual_ta1_DE.md#ta1:-eisenzeitalter)
|
- [TA1: Eisenzeitalter](./manual_ta1_DE.md#ta1:-eisenzeitalter)
|
||||||
- [Köhler / Coal Pile](./manual_ta1_DE.md#köhler--coal-pile)
|
- [Köhler / Coal Pile](./manual_ta1_DE.md#köhler--coal-pile)
|
||||||
- [Kohlebrenner / Coal Burner](./manual_ta1_DE.md#kohlebrenner--coal-burner)
|
- [Kohlebrenner / Coal Burner](./manual_ta1_DE.md#kohlebrenner--coal-burner)
|
||||||
@ -108,4 +109,7 @@
|
|||||||
- [TA4 Wärmetauscher / Heat Exchanger](./manual_ta4_DE.md#ta4-wärmetauscher--heat-exchanger)
|
- [TA4 Wärmetauscher / Heat Exchanger](./manual_ta4_DE.md#ta4-wärmetauscher--heat-exchanger)
|
||||||
- [TA4 Turbine](./manual_ta4_DE.md#ta4-turbine)
|
- [TA4 Turbine](./manual_ta4_DE.md#ta4-turbine)
|
||||||
- [TA4 Generator](./manual_ta4_DE.md#ta4-generator)
|
- [TA4 Generator](./manual_ta4_DE.md#ta4-generator)
|
||||||
- [TA4 Röhre / Pipe](./manual_ta4_DE.md#ta4-röhre--pipe)
|
- [TA4 Röhre / Pipe](./manual_ta4_DE.md#ta4-röhre--pipe)
|
||||||
|
- [Wasserstoff](./manual_ta4_DE.md#wasserstoff)
|
||||||
|
- [Elektrolyseur](./manual_ta4_DE.md#elektrolyseur)
|
||||||
|
- [Brennstoffzelle](./manual_ta4_DE.md#brennstoffzelle)
|
@ -17,7 +17,7 @@ local M = minetest.get_meta
|
|||||||
local S = techage.S
|
local S = techage.S
|
||||||
|
|
||||||
-- Consumer Related Data
|
-- Consumer Related Data
|
||||||
local CRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).consumer end
|
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
|
||||||
|
|
||||||
local STANDBY_TICKS = 4
|
local STANDBY_TICKS = 4
|
||||||
local COUNTDOWN_TICKS = 6
|
local COUNTDOWN_TICKS = 6
|
||||||
|
@ -19,7 +19,7 @@ local P = minetest.string_to_pos
|
|||||||
local S = techage.S
|
local S = techage.S
|
||||||
|
|
||||||
-- Consumer Related Data
|
-- Consumer Related Data
|
||||||
local CRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).consumer end
|
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
|
||||||
local CRDN = function(node) return (minetest.registered_nodes[node.name] or {}).consumer end
|
local CRDN = function(node) return (minetest.registered_nodes[node.name] or {}).consumer end
|
||||||
|
|
||||||
local STANDBY_TICKS = 10
|
local STANDBY_TICKS = 10
|
||||||
|
@ -21,7 +21,7 @@ local N = function(pos) return minetest.get_node(pos).name end
|
|||||||
local D = techage.Debug
|
local D = techage.Debug
|
||||||
|
|
||||||
-- Techage Related Data
|
-- Techage Related Data
|
||||||
local PWR = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).power end
|
local PWR = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).power end
|
||||||
|
|
||||||
-- Used to determine the already passed nodes while power distribution
|
-- Used to determine the already passed nodes while power distribution
|
||||||
local Route = {}
|
local Route = {}
|
||||||
@ -38,7 +38,7 @@ local NOPOWER = 2
|
|||||||
local RUNNING = 3
|
local RUNNING = 3
|
||||||
|
|
||||||
-------------------------------------------------- Migrate
|
-------------------------------------------------- Migrate
|
||||||
local CRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).consumer end
|
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
|
||||||
local Consumer = {
|
local Consumer = {
|
||||||
["techage:streetlamp_off"] = 0,
|
["techage:streetlamp_off"] = 0,
|
||||||
["techage:streetlamp_on"] = 0.5,
|
["techage:streetlamp_on"] = 0.5,
|
||||||
@ -117,7 +117,7 @@ local function migrate(pos, mem, node)
|
|||||||
mem.pwr_power_provided_cnt = 2
|
mem.pwr_power_provided_cnt = 2
|
||||||
mem.pwr_node_alive_cnt = 4
|
mem.pwr_node_alive_cnt = 4
|
||||||
|
|
||||||
local name = minetest.get_node(pos).name
|
local name = techage.get_node_lvm(pos).name
|
||||||
mem.pwr_needed = Consumer[name]
|
mem.pwr_needed = Consumer[name]
|
||||||
mem.pwr_available = Generator[name]
|
mem.pwr_available = Generator[name]
|
||||||
mem.pwr_could_provide = Akku[name]
|
mem.pwr_could_provide = Akku[name]
|
||||||
@ -578,6 +578,7 @@ function techage.power.secondary_stop(pos, mem)
|
|||||||
mem.pwr_node_alive_cnt = 0
|
mem.pwr_node_alive_cnt = 0
|
||||||
mem.pwr_could_provide = 0
|
mem.pwr_could_provide = 0
|
||||||
mem.pwr_could_need = 0
|
mem.pwr_could_need = 0
|
||||||
|
mem.pwr_needed2 = 0
|
||||||
if determine_new_master(pos, mem) then -- last available master
|
if determine_new_master(pos, mem) then -- last available master
|
||||||
power_distribution(pos, mem)
|
power_distribution(pos, mem)
|
||||||
end
|
end
|
||||||
@ -598,7 +599,10 @@ function techage.power.secondary_alive(pos, mem, capa_curr, capa_max)
|
|||||||
if D.pwr then D.dbg("secondary_alive is master") end
|
if D.pwr then D.dbg("secondary_alive is master") end
|
||||||
power_distribution(pos, mem, 1)
|
power_distribution(pos, mem, 1)
|
||||||
end
|
end
|
||||||
return mem.pwr_provided or 0
|
if mem.pwr_master_pos then
|
||||||
|
return mem.pwr_provided or 0
|
||||||
|
end
|
||||||
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
@ -618,7 +622,7 @@ function techage.power.get_power(start_pos, inverter)
|
|||||||
if pwr and pwr.on_getpower then
|
if pwr and pwr.on_getpower then
|
||||||
sum = sum + pwr.on_getpower(pos, mem)
|
sum = sum + pwr.on_getpower(pos, mem)
|
||||||
else
|
else
|
||||||
local node = minetest.get_node(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
if node.name == inverter then
|
if node.name == inverter then
|
||||||
num_inverter = num_inverter + 1
|
num_inverter = num_inverter + 1
|
||||||
end
|
end
|
||||||
|
@ -17,7 +17,7 @@ local P = minetest.string_to_pos
|
|||||||
local M = minetest.get_meta
|
local M = minetest.get_meta
|
||||||
local N = function(pos) return minetest.get_node(pos).name end
|
local N = function(pos) return minetest.get_node(pos).name end
|
||||||
-- Techage Related Data
|
-- Techage Related Data
|
||||||
local PWR = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).power end
|
local PWR = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).power end
|
||||||
local PWRN = function(node) return (minetest.registered_nodes[node.name] or {}).power end
|
local PWRN = function(node) return (minetest.registered_nodes[node.name] or {}).power end
|
||||||
|
|
||||||
local network_changed = techage.power.network_changed
|
local network_changed = techage.power.network_changed
|
||||||
@ -78,7 +78,7 @@ local function matching_nodes(pos, peer_pos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function techage.get_pos(pos, side)
|
function techage.get_pos(pos, side)
|
||||||
local node = minetest.get_node(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
local dir = nil
|
local dir = nil
|
||||||
if node.name ~= "air" and node.name ~= "ignore" then
|
if node.name ~= "air" and node.name ~= "ignore" then
|
||||||
dir = side_to_dir(node.param2, side)
|
dir = side_to_dir(node.param2, side)
|
||||||
@ -236,7 +236,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function techage.power.side_to_outdir(pos, side)
|
function techage.power.side_to_outdir(pos, side)
|
||||||
local node = minetest.get_node(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
return side_to_dir(node.param2, side)
|
return side_to_dir(node.param2, side)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -244,7 +244,7 @@ end
|
|||||||
function techage.power.power_cut(pos, dir, cable, cut)
|
function techage.power.power_cut(pos, dir, cable, cut)
|
||||||
local npos = vector.add(pos, tubelib2.Dir6dToVector[dir or 0])
|
local npos = vector.add(pos, tubelib2.Dir6dToVector[dir or 0])
|
||||||
|
|
||||||
local node = minetest.get_node(npos)
|
local node = techage.get_node_lvm(npos)
|
||||||
if node.name ~= "techage:powerswitch_box" and
|
if node.name ~= "techage:powerswitch_box" and
|
||||||
M(npos):get_string("techage_hidden_nodename") ~= "techage:powerswitch_box" then
|
M(npos):get_string("techage_hidden_nodename") ~= "techage:powerswitch_box" then
|
||||||
return
|
return
|
||||||
|
@ -264,7 +264,7 @@ techage.power.register_node({"techage:powerswitch_box"}, {
|
|||||||
|
|
||||||
techage.register_node({"techage:powerswitch", "techage:powerswitch_on"}, {
|
techage.register_node({"techage:powerswitch", "techage:powerswitch_on"}, {
|
||||||
on_recv_message = function(pos, src, topic, payload)
|
on_recv_message = function(pos, src, topic, payload)
|
||||||
local node = minetest.get_node(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
if topic == "on" and node.name == "techage:powerswitch" then
|
if topic == "on" and node.name == "techage:powerswitch" then
|
||||||
switch_on(pos, node, nil, "techage:powerswitch_on")
|
switch_on(pos, node, nil, "techage:powerswitch_on")
|
||||||
return true
|
return true
|
||||||
|
@ -52,7 +52,7 @@ end
|
|||||||
local old_is_protected = minetest.is_protected
|
local old_is_protected = minetest.is_protected
|
||||||
|
|
||||||
function minetest.is_protected(pos, name)
|
function minetest.is_protected(pos, name)
|
||||||
local node = minetest.get_node(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
if IsNodeUnderObservation[node.name] and is_protected(pos, name, RANGE) then
|
if IsNodeUnderObservation[node.name] and is_protected(pos, name, RANGE) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -32,7 +32,7 @@ end
|
|||||||
|
|
||||||
-- return the required param2 for solar modules
|
-- return the required param2 for solar modules
|
||||||
local function get_param2(pos, side)
|
local function get_param2(pos, side)
|
||||||
local node = minetest.get_node(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
local dir = power.side_to_dir(node.param2, side)
|
local dir = power.side_to_dir(node.param2, side)
|
||||||
return (dir + 1) % 4
|
return (dir + 1) % 4
|
||||||
end
|
end
|
||||||
@ -49,7 +49,7 @@ end
|
|||||||
local function is_solar_module(base_pos, pos, side)
|
local function is_solar_module(base_pos, pos, side)
|
||||||
local pos1 = techage.get_pos(pos, side)
|
local pos1 = techage.get_pos(pos, side)
|
||||||
if pos1 then
|
if pos1 then
|
||||||
local node = minetest.get_node(pos1)
|
local node = techage.get_node_lvm(pos1)
|
||||||
if node and node.name == "techage:ta4_solar_module" and light(pos1) then
|
if node and node.name == "techage:ta4_solar_module" and light(pos1) then
|
||||||
if side == "L" and node.param2 == M(base_pos):get_int("left_param2") then
|
if side == "L" and node.param2 == M(base_pos):get_int("left_param2") then
|
||||||
return true
|
return true
|
||||||
|
@ -20,7 +20,7 @@ local S = techage.S
|
|||||||
local Pipe = techage.SteamPipe
|
local Pipe = techage.SteamPipe
|
||||||
|
|
||||||
local function swap_node(pos, name)
|
local function swap_node(pos, name)
|
||||||
local node = minetest.get_node(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
if node.name == name then
|
if node.name == name then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -24,7 +24,7 @@ local Axle = techage.Axle
|
|||||||
local power = techage.power
|
local power = techage.power
|
||||||
|
|
||||||
local function swap_node(pos, name)
|
local function swap_node(pos, name)
|
||||||
local node = minetest.get_node(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
if node.name == name then
|
if node.name == name then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
BIN
textures/techage_appl_ctrl_unit.png
Normal file
After Width: | Height: | Size: 233 B |
BIN
textures/techage_appl_ctrl_unit4.png
Normal file
After Width: | Height: | Size: 425 B |
BIN
textures/techage_appl_electrolyzer.png
Normal file
After Width: | Height: | Size: 223 B |
BIN
textures/techage_appl_electrolyzer4.png
Normal file
After Width: | Height: | Size: 245 B |
BIN
textures/techage_appl_fuelcell.png
Normal file
After Width: | Height: | Size: 248 B |
BIN
textures/techage_appl_fuelcell4.png
Normal file
After Width: | Height: | Size: 354 B |
BIN
textures/techage_fc_stack_inv.png
Normal file
After Width: | Height: | Size: 175 B |
BIN
textures/techage_hydrogen_inv.png
Normal file
After Width: | Height: | Size: 338 B |
@ -23,6 +23,17 @@ local Nodes2Convert = {
|
|||||||
["techage:button_on"] = "techage:ta3_button_on",
|
["techage:button_on"] = "techage:ta3_button_on",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local function power_data(power)
|
||||||
|
local tbl = {}
|
||||||
|
tbl[1] = S("Primary available") ..": "..(power.prim_available or 0)
|
||||||
|
tbl[2] = S("Secondary available") ..": "..(power.sec_available or 0)
|
||||||
|
tbl[3] = S("Primary needed") ..": "..(power.prim_needed or 0)
|
||||||
|
tbl[4] = S("Secondary needed") ..": "..(power.sec_needed or 0)
|
||||||
|
tbl[5] = S("Number of nodes") ..": "..(power.num_nodes or 0)
|
||||||
|
tbl[6] = ""
|
||||||
|
return table.concat(tbl, "\n")
|
||||||
|
end
|
||||||
|
|
||||||
local function read_state(itemstack, user, pointed_thing)
|
local function read_state(itemstack, user, pointed_thing)
|
||||||
local pos = pointed_thing.under
|
local pos = pointed_thing.under
|
||||||
if pos and user then
|
if pos and user then
|
||||||
@ -94,9 +105,8 @@ local function read_state(itemstack, user, pointed_thing)
|
|||||||
if ndef.is_power_available then
|
if ndef.is_power_available then
|
||||||
techage.power.mark_nodes(user:get_player_name(), pos)
|
techage.power.mark_nodes(user:get_player_name(), pos)
|
||||||
local power = ndef.is_power_available(pos)
|
local power = ndef.is_power_available(pos)
|
||||||
if power and power.prim_available then
|
if power then
|
||||||
local text = "\nGenerators: "..power.prim_available.." ku\nAkkus: "..power.sec_available.." ku\nMachines: "..power.prim_needed.." ku\nNum Nodes: "..power.num_nodes.."\n"
|
minetest.chat_send_player(user:get_player_name(), ndef.description..":\n"..power_data(power))
|
||||||
minetest.chat_send_player(user:get_player_name(), ndef.description..":"..text)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local owner = M(pos):get_string("owner") or ""
|
local owner = M(pos):get_string("owner") or ""
|
||||||
|