bugfixes for solar inverter and energy storage

power distribution changed
solar inverter in two nodes divided
manuals revised
This commit is contained in:
Joachim Stolberg 2019-10-05 19:19:18 +02:00
parent a3fadf4143
commit 14bc0b19cb
38 changed files with 532 additions and 479 deletions

View File

@ -54,17 +54,6 @@ local function on_receive_fields(pos, formname, fields, player)
end
end
local function after_place_node(pos, placer)
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
local mem = tubelib2.get_mem(pos)
mem.running = true
mem.capa = 0
minetest.get_node_timer(pos):start(CYCLE_TIME)
power.secondary_start(pos, mem, PWR_PERF, PWR_PERF)
M(pos):set_string("formspec", formspec(pos, mem))
end
minetest.register_node("techage:akku", {
description = "Akku",
tiles = {
@ -79,11 +68,18 @@ minetest.register_node("techage:akku", {
paramtype2 = "facedir",
groups = {cracky=2, crumbly=2, choppy=2},
is_ground_content = false,
after_place_node = after_place_node,
on_receive_fields = on_receive_fields,
on_timer = node_timer,
})
techage.power.register_node({"techage:akku"}, {
power_network = Cable,
after_place_node = function(pos, placer)
local mem = tubelib2.init_mem(pos)
mem.running = true
mem.capa = 0
minetest.get_node_timer(pos):start(CYCLE_TIME)
power.secondary_start(pos, mem, PWR_PERF, PWR_PERF)
M(pos):set_string("formspec", formspec(pos, mem))
end,
})

View File

@ -60,12 +60,6 @@ minetest.register_node("techage:sink", {
description = "Sink",
tiles = {'techage_electric_button.png'},
after_place_node = function(pos)
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
local mem = tubelib2.get_mem(pos)
M(pos):set_string("infotext", "off")
end,
on_timer = node_timer,
on_rightclick = on_rightclick,
@ -99,4 +93,9 @@ techage.power.register_node({"techage:sink", "techage:sink_on"}, {
power_network = Cable,
on_power = on_power,
on_nopower = on_nopower,
after_place_node = function(pos)
local mem = tubelib2.init_mem(pos)
M(pos):set_string("infotext", "off")
end,
})

View File

@ -45,11 +45,6 @@ minetest.register_node("techage:source", {
'techage_electric_button.png^techage_appl_electronic_fab.png',
'techage_electric_button.png^techage_appl_electronic_fab.png',
},
after_place_node = function(pos)
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
local mem = tubelib2.get_mem(pos)
M(pos):set_string("infotext", "off")
end,
paramtype2 = "facedir",
groups = {cracky=2, crumbly=2, choppy=2},
@ -60,4 +55,8 @@ minetest.register_node("techage:source", {
techage.power.register_node({"techage:source"}, {
power_network = Cable,
after_place_node = function(pos)
local mem = tubelib2.init_mem(pos)
M(pos):set_string("infotext", "off")
end,
})

View File

@ -123,16 +123,6 @@ minetest.register_node("techage:t2_source", {
groups = {cracky=2, crumbly=2, choppy=2},
on_rotate = screwdriver.disallow,
is_ground_content = false,
on_construct = tubelib2.init_mem,
after_place_node = function(pos, placer)
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
local mem = tubelib2.get_mem(pos)
State2:node_init(pos, mem, "")
mem.state_num = 2
on_rightclick(pos)
end,
on_receive_fields = on_receive_fields,
on_rightclick = on_rightclick,
on_timer = node_timer,
@ -153,16 +143,6 @@ minetest.register_node("techage:t3_source", {
groups = {cracky=2, crumbly=2, choppy=2},
on_rotate = screwdriver.disallow,
is_ground_content = false,
on_construct = tubelib2.init_mem,
after_place_node = function(pos, placer)
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
local mem = tubelib2.get_mem(pos)
State3:node_init(pos, mem, "")
mem.state_num = 3
on_rightclick(pos)
end,
on_receive_fields = on_receive_fields,
on_rightclick = on_rightclick,
on_timer = node_timer,
@ -183,16 +163,6 @@ minetest.register_node("techage:t4_source", {
groups = {cracky=2, crumbly=2, choppy=2},
on_rotate = screwdriver.disallow,
is_ground_content = false,
on_construct = tubelib2.init_mem,
after_place_node = function(pos, placer)
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
local mem = tubelib2.get_mem(pos)
State4:node_init(pos, mem, "")
mem.state_num = 4
on_rightclick(pos)
end,
on_receive_fields = on_receive_fields,
on_rightclick = on_rightclick,
on_timer = node_timer,
@ -201,14 +171,32 @@ minetest.register_node("techage:t4_source", {
techage.power.register_node({"techage:t2_source"}, {
conn_sides = {"R"},
power_network = TA2_Power,
after_place_node = function(pos, placer)
local mem = tubelib2.init_mem(pos)
State2:node_init(pos, mem, "")
mem.state_num = 2
on_rightclick(pos)
end,
})
techage.power.register_node({"techage:t3_source"}, {
conn_sides = {"R"},
power_network = TA3_Power,
after_place_node = function(pos, placer)
local mem = tubelib2.init_mem(pos)
State3:node_init(pos, mem, "")
mem.state_num = 3
on_rightclick(pos)
end,
})
techage.power.register_node({"techage:t4_source"}, {
conn_sides = {"R"},
power_network = TA4_Power,
after_place_node = function(pos, placer)
local mem = tubelib2.init_mem(pos)
State4:node_init(pos, mem, "")
mem.state_num = 4
on_rightclick(pos)
end,
})

View File

@ -161,8 +161,7 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode, validState
node_box = tNode.node_box,
selection_box = tNode.selection_box,
on_construct = tubelib2.init_mem,
-- will be overwritten in case, power is used
after_place_node = function(pos, placer, itemstack, pointed_thing)
local meta = M(pos)
local mem = tubelib2.init_mem(pos)
@ -178,7 +177,7 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode, validState
end
CRD(pos).State:node_init(pos, mem, number)
end,
-- will be overwritten in case, power is used
after_dig_node = function(pos, oldnode, oldmetadata, digger)
if tNode.after_dig_node then
tNode.after_dig_node(pos, oldnode, oldmetadata, digger)
@ -240,6 +239,28 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode, validState
power_network = power_network,
on_power = on_power,
on_nopower = on_nopower,
after_place_node = function(pos, placer, itemstack, pointed_thing)
local meta = M(pos)
local mem = tubelib2.init_mem(pos)
local node = minetest.get_node(pos)
meta:set_int("push_dir", techage.side_to_indir("L", node.param2))
meta:set_int("pull_dir", techage.side_to_indir("R", node.param2))
local number = "-"
if stage > 2 then
number = techage.add_node(pos, name_pas)
end
if tNode.after_place_node then
tNode.after_place_node(pos, placer, itemstack, pointed_thing)
end
CRD(pos).State:node_init(pos, mem, number)
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
if tNode.after_dig_node then
tNode.after_dig_node(pos, oldnode, oldmetadata, digger)
end
techage.remove_node(pos)
tubelib2.del_mem(pos)
end,
})
end
techage.register_node({name_pas, name_act}, tNode.tubing)

View File

@ -126,30 +126,9 @@ minetest.register_node("techage:ta3_akku", {
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_source.png",
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_source.png",
},
on_construct = tubelib2.init_mem,
after_place_node = function(pos, placer, itemstack)
local meta = M(pos)
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
local mem = tubelib2.get_mem(pos)
local own_num = techage.add_node(pos, "techage:ta3_akku")
meta:set_string("owner", placer:get_player_name())
meta:set_string("infotext", S("TA3 Akku Box").." "..own_num)
State:node_init(pos, mem, own_num)
mem.capa = get_capa(itemstack)
on_rightclick(pos)
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
local mem = tubelib2.get_mem(pos)
set_capa(pos, oldnode, digger, mem.capa)
end,
on_receive_fields = on_receive_fields,
on_rightclick = on_rightclick,
on_timer = node_timer,
drop = "", -- don't remove, item will be added via 'set_capa'
paramtype2 = "facedir",
groups = {cracky=2, crumbly=2, choppy=2},
@ -161,6 +140,20 @@ minetest.register_node("techage:ta3_akku", {
techage.power.register_node({"techage:ta3_akku"}, {
conn_sides = {"R"},
power_network = Power,
after_place_node = function(pos, placer, itemstack)
local meta = M(pos)
local mem = tubelib2.init_mem(pos)
local own_num = techage.add_node(pos, "techage:ta3_akku")
meta:set_string("owner", placer:get_player_name())
meta:set_string("infotext", S("TA3 Akku Box").." "..own_num)
State:node_init(pos, mem, own_num)
mem.capa = get_capa(itemstack)
on_rightclick(pos)
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
local mem = tubelib2.get_mem(pos)
set_capa(pos, oldnode, digger, mem.capa)
end,
})
-- for logical communication

View File

@ -238,22 +238,11 @@ minetest.register_node("techage:coalboiler_top", {
on_rightclick = on_rightclick,
on_construct = function(pos)
tubelib2.init_mem(pos)
local inv = M(pos):get_inventory()
inv:set_size('water', 1)
inv:set_size('input', 1)
end,
after_place_node = function(pos, placer)
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
local mem = tubelib2.get_mem(pos)
State:node_init(pos, mem, "")
local node = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z})
if node.name == "techage:coalboiler_base" then
on_rightclick(pos)
end
end,
on_metadata_inventory_put = function(pos)
minetest.after(0.5, move_to_water, pos)
end,
@ -268,6 +257,14 @@ minetest.register_node("techage:coalboiler_top", {
techage.power.register_node({"techage:coalboiler_top"}, {
conn_sides = {"F"},
power_network = Pipe,
after_place_node = function(pos, placer)
local mem = tubelib2.init_mem(pos)
State:node_init(pos, mem, "")
local node = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z})
if node.name == "techage:coalboiler_base" then
on_rightclick(pos)
end
end,
})
techage.register_node({"techage:coalboiler_top"}, {

View File

@ -32,11 +32,6 @@ local function swap_node(pos, name)
minetest.swap_node(pos, node)
end
-- called with any pipe change
local function after_tube_update(node, pos, out_dir, peer_pos, peer_in_dir)
swap_node(pos, "techage:cooler")
end
minetest.register_node("techage:cooler", {
description = S("TA3 Cooler"),
tiles = {
@ -88,7 +83,6 @@ minetest.register_node("techage:cooler_on", {
"techage_filling_ta3.png^techage_frame_ta3.png^techage_cooler.png",
},
after_tube_update = after_tube_update,
paramtype2 = "facedir",
groups = {not_in_creative_inventory=1},
diggable = false,
@ -101,6 +95,9 @@ minetest.register_node("techage:cooler_on", {
techage.power.register_node({"techage:cooler", "techage:cooler_on"}, {
conn_sides = {"L", "R"},
power_network = Pipe,
after_tube_update = function(node, pos, out_dir, peer_pos, peer_in_dir)
swap_node(pos, "techage:cooler")
end,
})
-- for logical communication

View File

@ -111,21 +111,9 @@ minetest.register_node("techage:generator", {
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_generator.png",
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_generator.png^[transformFX]",
},
on_construct = tubelib2.init_mem,
after_place_node = function(pos, placer)
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
local mem = tubelib2.get_mem(pos)
local number = techage.add_node(pos, "techage:generator")
State:node_init(pos, mem, number)
on_rightclick(pos)
end,
on_receive_fields = on_receive_fields,
on_rightclick = on_rightclick,
on_timer = node_timer,
paramtype2 = "facedir",
groups = {cracky=2, crumbly=2, choppy=2},
on_rotate = screwdriver.disallow,
@ -166,7 +154,6 @@ minetest.register_node("techage:generator_on", {
on_receive_fields = on_receive_fields,
on_rightclick = on_rightclick,
on_timer = node_timer,
drop = "",
paramtype2 = "facedir",
groups = {not_in_creative_inventory=1},
@ -188,6 +175,12 @@ minetest.register_craft({
techage.power.register_node({"techage:generator", "techage:generator_on"}, {
conn_sides = {"R"},
power_network = Cable,
after_place_node = function(pos, placer)
local mem = tubelib2.init_mem(pos)
local number = techage.add_node(pos, "techage:generator")
State:node_init(pos, mem, number)
on_rightclick(pos)
end,
})
-- for logical communication

View File

@ -28,35 +28,80 @@ local Param2ToDir = {
[5] = 3,
}
local function collect_network_data(pos, mem)
local data = {
fuel = {},
wind = {},
solar = {},
akku = {},
stor = {},
}
local add = function(kind, attr, val)
data[kind][attr] = (data[kind][attr] or 0) + (val or 0)
end
local max = function(kind, attr, val)
data[kind][attr] = math.max((data[kind][attr] or 0), (val or 0))
end
local nnodes = techage.power.limited_connection_walk(pos,
function(pos, node, mem, num_hops, num_nodes)
if node.name == "techage:generator" or node.name == "techage:generator_on" then
add("fuel", "num", 1)
add("fuel", "nomi", mem.pwr_available)
add("fuel", "curr", mem.provided)
elseif node.name == "techage:ta3_akku" then
add("akku", "num", 1)
add("akku", "nomi", mem.pwr_available2)
add("akku", "curr", mem.delivered)
elseif node.name == "techage:heatexchanger1" then
add("stor", "num", 1)
add("stor", "nomi", mem.pwr_available2)
add("stor", "curr", mem.delivered)
elseif node.name == "techage:tiny_generator" or node.name == "techage:tiny_generator_on" then
add("fuel", "num", 1)
add("fuel", "nomi", mem.pwr_available)
add("fuel", "curr", mem.provided)
elseif node.name == "techage:ta4_solar_inverter" then
add("solar", "num", 1)
add("solar", "nomi", mem.pwr_available)
add("solar", "curr", mem.delivered)
elseif node.name == "techage:ta4_wind_turbine" then
add("wind", "num", 1)
add("wind", "nomi", mem.pwr_available)
add("wind", "curr", mem.delivered)
end
end
)
return data, nnodes
end
local function formspec(pos)
local jpos = minetest.deserialize(M(pos):get_string("junction_pos"))
local power = techage.power.power_accounting(jpos, tubelib2.get_mem(jpos))
if power and power.prim_available then
local alarm = ""
if power.num_nodes > (techage.MAX_NUM_NODES - 50) then
alarm = " (max. "..(techage.MAX_NUM_NODES).." !!!)"
end
return "size[5,4]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"label[1.5,0.0;"..S("Network Data").."]"..
"label[0,0.8;"..S("Generators").." : "..power.prim_available.." ku]"..
"label[0,1.4;"..S("Akkus").." : "..power.sec_available.." ku]"..
"label[0,2.0;"..S("Machines").." : "..power.prim_needed.." ku]"..
"label[0,2.6;"..S("Number nodes").." : "..power.num_nodes..alarm.."]"..
"button[1.5,3.3;2,1;update;"..S("Update").."]"
local data, nnodes = collect_network_data(jpos, tubelib2.get_mem(jpos))
local get = function(kind)
return (data[kind].num or 0).." / "..(data[kind].curr or 0).." ku / "..(data[kind].nomi or 0).. " ku"
end
return "size[5,4]"..
local get = function(kind)
return (data[kind].num or 0).." / "..(data[kind].curr or 0).." ku / "..(data[kind].nomi or 0).. " ku"
end
local alarm = ""
if nnodes > (techage.MAX_NUM_NODES - 50) then
alarm = " (max. "..(techage.MAX_NUM_NODES).." !!!)"
end
return "size[10,6.5]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"label[1.5,0.0;"..S("Network Data").."]"..
"label[0,0.8;"..S("Generators").." : 0 ku]"..
"label[0,1.4;"..S("Akkus").." : 0 ku]"..
"label[0,2.0;"..S("Machines").." : 0 ku]"..
"label[0,2.6;"..S("Number nodes").." : 0]"..
"button[1.5,3.3;2,1;update;"..S("Update").."]"
"label[2,0.0;"..S("Network Data").."]"..
"label[3,0.7;"..S("(number / current / max.)").."]"..
"label[0,1.4;"..S("Power Fuel")..":]".. "label[4,1.4;"..get("fuel").."]"..
"label[0,2.1;"..S("Power Solar")..":]".. "label[4,2.1;"..get("solar").."]"..
"label[0,2.8;"..S("Power Wind")..":]".. "label[4,2.8;"..get("wind").."]"..
"label[0,3.5;"..S("Power Storage")..":]".."label[4,3.5;"..get("stor").."]"..
"label[0,4.2;"..S("Power Akkus")..":]".. "label[4,4.2;"..get("akku").."]"..
"label[0,4.9;"..S("Number nodes").." : "..nnodes..alarm.."]"..
"button[2.5,5.8;2,1;update;"..S("Update").."]"
end
local function update_formspec(pos)

View File

@ -56,15 +56,6 @@ local function stop_sound(pos)
end
end
-- called with any pipe change
local function after_tube_update(node, pos, out_dir, peer_pos, peer_in_dir)
local mem = tubelib2.get_mem(pos)
transfer_cooler(pos, "stop", nil)
swap_node(pos, "techage:turbine")
mem.running = false
stop_sound(pos)
end
minetest.register_node("techage:turbine", {
description = S("TA3 Turbine"),
tiles = {
@ -76,8 +67,6 @@ minetest.register_node("techage:turbine", {
"techage_filling_ta3.png^techage_appl_turbine.png^techage_frame_ta3.png",
"techage_filling_ta3.png^techage_appl_turbine.png^techage_frame_ta3.png",
},
on_construct = tubelib2.init_mem,
paramtype2 = "facedir",
groups = {cracky=2, crumbly=2, choppy=2},
on_rotate = screwdriver.disallow,
@ -113,8 +102,6 @@ minetest.register_node("techage:turbine_on", {
},
},
},
after_tube_update = after_tube_update,
paramtype2 = "facedir",
groups = {not_in_creative_inventory=1},
diggable = false,
@ -127,6 +114,13 @@ minetest.register_node("techage:turbine_on", {
techage.power.register_node({"techage:turbine", "techage:turbine_on"}, {
conn_sides = {"L", "U"},
power_network = Pipe,
after_tube_update = function(node, pos, out_dir, peer_pos, peer_in_dir)
local mem = tubelib2.get_mem(pos)
transfer_cooler(pos, "stop", nil)
swap_node(pos, "techage:turbine")
mem.running = false
stop_sound(pos)
end
})
-- for logical communication

View File

@ -485,9 +485,7 @@ techage.manual_DE.aText = {
"\n",
"Das Strom-Terminal muss von eine Verteilerdose platziert werden. Es zeigt Daten aus dem Stromnetz an wie:\n"..
"\n"..
" - Leistung alle Generatoren\n"..
" - Leistung alles Akkus (Sekundärquellen)\n"..
" - Leistungsaufnahme aller Maschinen\n"..
" - Anzahl und Leistung der verschiedenen Generatoren und Akkus (aktuell/maximal)\n"..
" - Anzahl der Netzwerk-Blöcke (max. 1000)\nDie Daten des Terminals werden beim Öffnen des Menüs und dann nur durch Anklicken des \"Update\" Buttons aktualisiert.\n"..
"\n"..
"\n"..
@ -801,16 +799,16 @@ techage.manual_DE.aText = {
"Für den Stromtransport stehen die Überlandleitungen zur Verfügung.\n"..
"Es kann aber auch Wasserstoff produziert werden\\, welcher sich transportieren und am Ziel wieder zu Strom umwandeln lässt (geplant).\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.\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"..
"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 hat zwei Anschlussseiten\\, eine für das rote Kabel zu den Solarmodulen und eine für das graue Stromkabel ins Stromnetz.\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"..
"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"..
"\n"..
"\n"..
"\n",
"Das Solarmodul muss an das Trägermodul gesetzt werden. Es sind immer zwei Solarmodule notwendig.\n"..
"Im Paar leisten die Solarmodule bis 4 ku\\, je nach Temperatur.\n"..
"Im Paar leisten die Solarmodule bis 3 ku\\, je nach Temperatur.\n"..
"Bei den Solarmodul muss darauf geachtet werden\\, dass diese das volle Tageslicht haben und nicht durch Blöcke oder Bäume beschattet sind.\n"..
"\n"..
"\n"..
@ -821,7 +819,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"..
"Ein Wechselrichter kann maximal 120 ku an Strom einspeisen\\, was 30 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"..
"\n"..
"\n"..
"\n",
@ -978,7 +976,7 @@ techage.manual_DE.aItemName = {
"ta4_nacelle",
"ta4_blinklamp",
"ta4_pillar",
"techage_ta4_solar",
"",
"ta4_solarmodule",
"ta4_solarcarrier",
"ta4_solar_inverter",
@ -1090,7 +1088,7 @@ techage.manual_DE.aPlanTable = {
"",
"",
"",
"",
"ta4_solarplant",
"",
"",
"",

View File

@ -20,7 +20,7 @@ local IMG_2 = {"", "techage_ta2.png"}
local IMG_3 = {"", "techage_ta3.png"}
local IMG_4 = {"", "techage_ta4.png"}
local IMG41 = {"", "techage_ta4_tes.png"}
local IMG42 = {"", "techage_ta4_solar.png"}
--
-- TA1: Coal Pile
@ -213,3 +213,24 @@ techage.ConstructionPlans["ta4_storagesystem"] = {
{false, false, false, PN090, PIPEH, PIPEH, PN180, false, false, false, false},
}
--
-- Solar Plant
--
local SOLAR = {"techage_solar_module_top.png", "techage:ta4_solar_module"}
local RCBLE = {"techage_ta4_cable_inv.png", "techage:ta4_power_cableS"}
local CARRI = {"techage:ta4_solar_carrier", "techage:ta4_solar_carrier"}
local INVDC = {"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_inverterDC.png", "techage:ta4_solar_inverterDC"}
local INVAC = {"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_inverter.png", "techage:ta4_solar_inverter"}
techage.ConstructionPlans["ta4_solarplant"] = {
{false, false, false, false, false, false, false, false, false, IMG42, false},
{false, false, false, false, false, false, false, false, false, false, false},
{false, false, false, false, false, false, false, false, false, false, false},
{false, SOLAR, SOLAR, SOLAR},
{false, CARRI, CARRI, CARRI, RCBLE, RCBLE, INVDC, INVAC, Cable},
{false, SOLAR, SOLAR, SOLAR},
}

View File

@ -52,13 +52,6 @@ minetest.register_node("techage:ta4_generator", {
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_generator.png",
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_generator.png^[transformFX]",
},
after_place_node = function(pos, placer)
local mem = tubelib2.init_mem(pos)
mem.running = false
mem.remote_trigger = 0
end,
on_timer = node_timer,
paramtype2 = "facedir",
groups = {cracky=2, crumbly=2, choppy=2},
@ -124,6 +117,12 @@ minetest.register_craft({
techage.power.register_node({"techage:ta4_generator", "techage:ta4_generator_on"}, {
conn_sides = {"R"},
power_network = Cable,
after_place_node = function(pos, placer)
local mem = tubelib2.init_mem(pos)
mem.running = false
mem.remote_trigger = 0
end,
})
-- controlled by the turbine

View File

@ -136,14 +136,33 @@ local function formspec(self, pos, mem)
"label[4.2,2.5;Flow]"
end
local function error_info(pos, err)
local own_num = M(pos):get_string("node_number")
local pos1 = {x = pos.x, y = pos.y + 1, z = pos.z}
M(pos1):set_string("infotext", S("TA4 Heat Exchanger").." "..own_num.." : "..err)
end
local function can_start(pos, mem, state)
if turbine_cmnd(pos, "power") then
local radius = inlet_cmnd(pos, "radius")
if radius then
mem.capa_max = PWR_CAPA[tonumber(radius)] or 0
local diameter = inlet_cmnd(pos, "diameter")
if diameter then
mem.capa_max = PWR_CAPA[tonumber(diameter)] or 0
print(diameter, mem.capa_max)
local owner = M(pos):get_string("owner") or ""
return inlet_cmnd(pos, "volume", owner)
if inlet_cmnd(pos, "volume", owner) then
error_info(pos, "")
return true
else
error_info(pos, "storage volume error")
return false
end
else
error_info(pos, "inlet/pipe error")
return false
end
else
error_info(pos, "power network error")
return false
end
return false
end
@ -154,6 +173,7 @@ local function start_node(pos, mem, state)
mem.was_charging = true
play_sound(pos)
mem.win_pos = inlet_cmnd(pos, "window")
turbine_cmnd(pos, "start")
power.secondary_start(pos, mem, PWR_PERF, PWR_PERF)
end
@ -294,19 +314,6 @@ minetest.register_node("techage:heatexchanger1", {
"techage_filling_ta4.png^techage_frameB_ta4.png^techage_appl_hole_electric.png",
"techage_filling_ta4.png^techage_frameB_ta4.png^techage_appl_hole_electric.png",
},
on_construct = tubelib2.init_mem,
after_place_node = function(pos, placer)
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
local mem = tubelib2.get_mem(pos)
local meta = M(pos)
local own_num = techage.add_node(pos, "techage:heatexchanger1")
meta:set_string("owner", placer:get_player_name())
State:node_init(pos, mem, own_num)
mem.capa = 0
end,
on_timer = node_timer,
paramtype2 = "facedir",
groups = {crumbly = 2, cracky = 2, snappy = 2},
@ -318,6 +325,14 @@ minetest.register_node("techage:heatexchanger1", {
techage.power.register_node({"techage:heatexchanger1"}, {
conn_sides = {"F", "B"},
power_network = Cable,
after_place_node = function(pos, placer)
local mem = tubelib2.init_mem(pos)
local meta = M(pos)
local own_num = techage.add_node(pos, "techage:heatexchanger1")
meta:set_string("owner", placer:get_player_name())
State:node_init(pos, mem, own_num)
mem.capa = 0
end,
})
Pipe:add_secondary_node_names({"techage:heatexchanger1", "techage:heatexchanger3"})

View File

@ -128,8 +128,8 @@ end
-- for logical communication
techage.register_node({"techage:ta4_pipe_inlet"}, {
on_transfer = function(pos, in_dir, topic, payload)
if topic == "radius" then
return get_radius(pos, in_dir)
if topic == "diameter" then
return get_radius(pos, in_dir) * 2 - 1
elseif topic == "volume" then
return check_volume(pos, in_dir, payload)
elseif topic == "window" then

View File

@ -82,12 +82,6 @@ minetest.register_node("techage:ta4_turbine", {
"techage_filling_ta4.png^techage_appl_turbine.png^techage_frame_ta4.png",
"techage_filling_ta4.png^techage_appl_turbine.png^techage_frame_ta4.png",
},
after_place_node = function(pos, placer)
local mem = tubelib2.init_mem(pos)
mem.running = false
mem.remote_trigger = 0
end,
on_timer = node_timer,
paramtype2 = "facedir",
groups = {cracky=2, crumbly=2, choppy=2},
@ -143,6 +137,11 @@ minetest.register_node("techage:ta4_turbine_on", {
techage.power.register_node({"techage:ta4_turbine", "techage:ta4_turbine_on"}, {
conn_sides = {"L", "U"},
power_network = Pipe,
after_place_node = function(pos, placer)
local mem = tubelib2.init_mem(pos)
mem.running = false
mem.remote_trigger = 0
end,
})
-- for logical communication

View File

@ -77,18 +77,7 @@ minetest.register_node("techage:ta3_booster", {
"techage_filling_ta3.png^techage_appl_compressor.png^techage_frame_ta3.png",
"techage_filling_ta3.png^techage_appl_compressor.png^[transformFX^techage_frame_ta3.png",
},
on_construct = tubelib2.init_mem,
after_place_node = function(pos, placer)
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
local mem = tubelib2.get_mem(pos)
local node = minetest.get_node(pos)
local indir = techage.side_to_indir("R", node.param2)
M(pos):set_int("indir", indir)
infotext(pos, "stopped")
end,
on_timer = node_timer,
paramtype2 = "facedir",
groups = {cracky=2, crumbly=2, choppy=2},
on_rotate = screwdriver.disallow,
@ -140,6 +129,13 @@ techage.power.register_node({"techage:ta3_booster", "techage:ta3_booster_on"}, {
conn_sides = {"F", "B", "U", "D", "L"},
on_power = on_power,
on_nopower = on_nopower,
after_place_node = function(pos, placer)
local mem = tubelib2.init_mem(pos)
local node = minetest.get_node(pos)
local indir = techage.side_to_indir("R", node.param2)
M(pos):set_int("indir", indir)
infotext(pos, "stopped")
end,
})
-- for intra machine communication

View File

@ -57,16 +57,16 @@ local function lamp_on_rightclick(pos, node, clicker)
end
local mem = tubelib2.get_mem(pos)
minetest.get_node_timer(pos):start(CYCLE_TIME)
if not mem.turned_on and power.power_available(pos, mem, PWR_NEEDED) then
mem.turned_on = true
swap_node(pos, "on")
power.consumer_start(pos, mem, CYCLE_TIME, PWR_NEEDED)
minetest.get_node_timer(pos):start(CYCLE_TIME)
swap_node(pos, "on")
else
mem.turned_on = false
swap_node(pos, "off")
power.consumer_stop(pos, mem)
minetest.get_node_timer(pos):stop()
swap_node(pos, "off")
end
end

View File

@ -1,7 +1,7 @@
# textdomain: techage
#### TA3 Terminal ####@n@nSend commands to your machines@nand output text messages from your@nmachines to the Terminal.@n@nCommand syntax:@n cmd <num> <cmnd>@n@nexample: cmd 181 on@n<num> is the number of the node to which the command is sent@n'on' is the command to turn machines/nodes on@nFurther commands can be retrieved by clicking on@nmachines/nodes with the Techage Info Tool.@n@nLocal commands:@n- clear @= clear screen@n- help @= this message@n- pub @= switch to public use@n- priv @= switch to private use@nTo program a user button with a command:@n set <button-num> <button-text> <command>@ne.g. 'set 1 ON cmd 123 on'@n=
Akkus=Akkus
(number / current / max.)=(Anzahl / aktuell / max.)
Allow to dig/place Techage power lines nearby power poles=Erlaubt TODO
Ash=Asche
Autocrafter=Autocrafter
@ -36,7 +36,6 @@ Flint and Iron=Flint and Iron
Flowing Oil=Fließendes Öl
Force order of filter items=Erzwinge Reihenfolge
Furnace Top=Ofenoberteil
Generators=Generatoren
Gravel Rinser=Kiesspüler
Gravel Sieve=Kiessieb
Grinder=Mühle
@ -44,7 +43,6 @@ Grinding=Mahlen
Heat=Hitze
Insert destination node number(s)=Gebe Zielnummer(n) ein
Liquid Sampler=Flüssigkeitensammler
Machines=Maschinen
Melting Guide=Schmelzführer
Melting Pot active (heat@==Schmelztiegel aktiv (Hitze@=
Melting Pot inactive (heat@==Schmelztiegel inaktiv (Hitze@=
@ -69,6 +67,11 @@ Plan=Plan
Position=Position
Position temperature=Positionstemperatur
Power=Energie
Power Akkus=Strom Akkus
Power Fuel=Strom Kohle/Öl
Power Solar=Strom Solar
Power Storage=Strom Speicher
Power Wind=Strom Wind
Pusher=Schieber
Remove derrick=Entferne Ölturm
Rinsing=Waschen
@ -174,6 +177,8 @@ TA4 Solar Carrier Module=TA4 Solar Trägermodul
TA4 Solar Carrier Module B=TA4 Solar Trägermodul U
TA4 Solar Carrier Module T=TA4 Solar Trägermodul O
TA4 Solar Inverter=TA4 Solar Wechselrichter
TA4 Solar Inverter AC=TA4 Solar Wechselrichter AC
TA4 Solar Inverter DC=TA4 Solar Wechselrichter DC
TA4 Solar Module=TA4 Solarmodul
TA4 Streetlamp Solar Cell=TA4 Straßenlampen-Solarzelle
TA4 Turbine=TA4 Turbine

View File

@ -1,5 +1,5 @@
#### TA3 Terminal ####@n@nSend commands to your machines@nand output text messages from your@nmachines to the Terminal.@n@nCommand syntax:@n cmd <num> <cmnd>@n@nexample: cmd 181 on@n<num> is the number of the node to which the command is sent@n'on' is the command to turn machines/nodes on@nFurther commands can be retrieved by clicking on@nmachines/nodes with the Techage Info Tool.@n@nLocal commands:@n- clear @= clear screen@n- help @= this message@n- pub @= switch to public use@n- priv @= switch to private use@nTo program a user button with a command:@n set <button-num> <button-text> <command>@ne.g. 'set 1 ON cmd 123 on'@n=
Akkus=
(number / current / max.)=
Allow to dig/place Techage power lines nearby power poles=
Ash=
Autocrafter=
@ -34,7 +34,6 @@ Flint and Iron=
Flowing Oil=
Force order of filter items=
Furnace Top=
Generators=
Gravel Rinser=
Gravel Sieve=
Grinder=
@ -42,7 +41,6 @@ Grinding=
Heat=
Insert destination node number(s)=
Liquid Sampler=
Machines=
Melting Guide=
Melting Pot active (heat@==
Melting Pot inactive (heat@==
@ -67,6 +65,11 @@ Plan=
Position=
Position temperature=
Power=
Power Akkus=
Power Fuel=
Power Solar=
Power Storage=
Power Wind=
Pusher=
Remove derrick=
Rinsing=
@ -172,6 +175,8 @@ TA4 Solar Carrier Module=
TA4 Solar Carrier Module B=
TA4 Solar Carrier Module T=
TA4 Solar Inverter=
TA4 Solar Inverter AC=
TA4 Solar Inverter DC=
TA4 Solar Module=
TA4 Streetlamp Solar Cell=
TA4 Turbine=

View File

@ -144,41 +144,49 @@ end)
Wird 1) aufgerufen, wird 2) **nicht** mehr gerufen!
### API Funktionen
```lua
tubelib2.get_pos(pos, dir)
```
## Techage `command`
### Dir vs. Side
`tubelib2` arbeitet nur mit dirs (siehe oben). Oft ist aber die Arbeitsweise mit `sides` einfacher.
Techage defiiert `sides` , die wie folgt definiert sind `{B=1, R=2, F=3, L=4, D=5, U=6}`:
Techage definiert `sides` , die wie folgt definiert sind `{B=1, R=2, F=3, L=4, D=5, U=6}`:
sides: dirs:
U
| B
| / 6
+--|-----+ | 1
/ o /| | /
+--------+ | |/
L <----| |o----> R 4 <-------+-------> 2
| o | | /|
| / | + / |
| / |/ 3 |
+-/------+ 5
/ |
F |
D
```
sides: dirs:
U
| B
| / 6
+--|-----+ | 1
/ o /| | /
+--------+ | |/
L <----| |o----> R 4 <-------+-------> 2
| o | | /|
| / | + / |
| / |/ 3 |
+-/------+ 5
/ |
F |
D
```
`techage/command.lua` definiert hier:
```lua
techage.side_to_outdir(side, param2) -- "B/R/F/L/D/U", node.param2
```
Weitere API Funktionen von `command.lua`
## Techage `command`
In Ergänzung zu `tubelib2` sind in `command` Funktionen für den Austausch von Items von Inventar zu Inventar (Tubing) und Kommandos für Datenaustausch definiert.
Zusätzlich etabliert `command` das Knoten-Nummern-System für die Addressierung bei Kommandos.
Zusätzlich etabliert `command` das Knoten-Nummern-System für die Adressierung bei Kommandos.
Dazu muss jeder Knoten bei `command` an- und abgemeldet werden:
@ -200,7 +208,7 @@ techage.register_node(names, {
})
```
#### Client API
### Client API
Bspw. der Pusher als Client nutzt:
@ -210,7 +218,7 @@ techage.push_items(pos, out_dir, stack)
techage.unpull_items(pos, out_dir, stack)
```
#### Server API
### Server API
Für den Server (chest mit Inventar) existieren dazu folgende Funktionen:
@ -220,7 +228,7 @@ techage.put_items(inv, listname, stack)
techage.get_inv_state(inv, listname)
```
#### Hopper API
### Hopper API
Es gibt bspw. mit dem Hopper aber auch einen Block, der nicht über Tubes sondern nur mit direkten Nachbarn Items austauschen soll. Dazu dient dieser Satz an Funktionen:
@ -230,7 +238,7 @@ techage.neighbour_push_items(pos, out_dir, stack)
techage.neighbour_unpull_items(pos, out_dir, stack)
```
#### Nummern bezogene Kommando API
### Nummern bezogene Kommando API
Kommunikation ohne Tubes, Addressierung nur über Knoten-Nummern
@ -241,7 +249,7 @@ techage.send_multi(src, numbers, topic, payload) --> to many nodes
techage.send_single(src, number, topic, payload) --> to one node with response
```
#### Positions bezogene Kommando API
### Positions bezogene Kommando API
Kommunikation mit Tubes oder mit direkten Nachbar-Knoten über pos/dir. Im Falle von Tubes muss bei `network` die Tube Instanz angegeben werden.
@ -257,7 +265,7 @@ techage.transfer(pos, outdir, topic, payload, network, nodenames)
-- opt: nodenames is a table of valid callee node names
```
#### Sonstige API
### Sonstige API
```lua
techage.side_to_indir(side, param2) --> indir
@ -281,16 +289,20 @@ techage.power.register_node(names, {
on_nopower = func(pos, mem), -- für Verbraucher (ausschalten)
on_getpower = func(pos, mem), -- für Solarzellen (Strom einsammeln)
power_network = Tube, -- tubelib2 Instanz
after_place_node = func(pos, placer, itemstack, pointed_thing),
after_dig_node = func(pos, oldnode, oldmetadata, digger)
after_tube_update = func(node, pos, out_dir, peer_pos, peer_in_dir)
})
```
Durch die Registrierung des Nodes werden auch die folgenden Funktionen überschrieben bzw. erhalten einen Wrapper (Code nur symbolhaft):
Durch die Registrierung des Nodes die obigen "after"-Funktionen einen Wrapper (Code nur symbolhaft):
```lua
-- after_place_node decorator
after_place_node = function(pos, placer, itemstack, pointed_thing)
local res = <node>.after_place_node(pos, placer, itemstack, pointed_thing)
<Tube>:after_place_node(pos)
return <node>.after_place_node(pos, placer, itemstack, pointed_thing)
return res
end,
-- after_dig_node decorator
after_dig_node = function(pos, oldnode, oldmetadata, digger)
@ -304,8 +316,6 @@ end,
-- --> after_tube_update (power)
after_tube_update = function(node, pos, out_dir, peer_pos, peer_in_dir)
mem.connections = ... -- aktualisieren/löschen
-- To be called delayed, so that all network connections have been established
minetest.after(0.2, network_changed, pos, mem)
return <node>.after_tube_update(node, pos, out_dir, peer_pos, peer_in_dir)
end,
@ -353,7 +363,6 @@ techage.power.power_accounting(pos, mem) --> {network data...} (used by terminal
techage.power.get_power(start_pos) --> sum (used by solar cells)
techage.power.power_network_available(start_pos) --> bool (used by TES generator)
techage.power.mark_nodes(name, start_pos) -- used by debugging tool
techage.power.add_connection(pos, out_dir, network, add) -- (Inverter feature)
```
## Klasse `NodeStates`
@ -471,23 +480,7 @@ Ein einfaches Beispiele dafür wäre: `pusher.lua`
#### Problem: Verbindungen zu zwei Netzwerken
Es ist nicht möglich, einen Knoten in zwei unterschiedlichen Netzwerken (bspw. Strom, Dampf) über `techage.power.register_node()` anzumelden. `power` würde zweimal übereinander die gleichen Knoten-internen Variablen wie `mem.connections` im Knoten anlegen und nutzen. Das geht und muss schief gehen. Aktuell ist es zusätzlich so, dass sich Lua in einer Endlosschleife aufhängt. Also insgesamt keine gute Idee.
Ein Lösungsansatz wäre, den Datensatz in mem, node und meta eine Indirektion tiefer unter dem Netzwerknamen abzuspeichern. Dies hat aber Auswirkungen auf die Performance.
Der **Inverter** hat mit Power und Solar zwei Netzwerkanschlüsse. Da dies aber aktuell (03.10.2019) nicht geht, ist nur Power normal registiert, Solar wird nur "krückenhaft" angesteuert. Damit taucht der Inverter aber nicht im Solar-Netzwerk auf. Dies ermöglicht es, mehrere Inverter in ein Solar-Netzwerk zu hängen und jeder liefert die volle Leistung.
Weiteres Problem: Die Funktion `matching_nodes()` (power2.lua) prüft, ob beide Knoten beim `after_tube_update` den gleichen Netzwerktyp haben. Der Inverter liefert hier "power", müsste aber "solar" liefern. Dadurch wird der Verbindungsaufbau von der Junctionbox abgelehnt.
#### Lösung
Leider eine Speziallösung für den Inverter:
- power2 hat eine Funktion `techage.power.add_connection()` um vom Inverter aus beim nächsten angeschlossenen Knoten den Inverter in der connection Liste einzutragen.
- Der Inverter gibt jetzt bei `techage.power.get_power()` seinen eigenen Namen an. `techage.power.get_power()` liefert die Anzahl der gefundenen Inverter zurück. Sind es mehr als einer, gibt es eine Fehlermeldung.
- Der Inverter hat auch noch eine `after_tube_update` bekommen, um auch von hier die `techage.power.add_connection()`aufrufen zu können.
So scheint es aber zu gehen.
Es ist nicht möglich, einen Knoten in zwei unterschiedlichen Netzwerken (bspw. Strom, Dampf) über `techage.power.register_node()` anzumelden. `power` würde zweimal übereinander die gleichen Knoten-internen Variablen wie `mem.connections` im Knoten anlegen und nutzen. Das geht und muss schief gehen. Aktuell gibt es dafür keine Lösung.
### ToDo

View File

@ -34,6 +34,9 @@ Ab TA3 laufen die Maschinen mit Strom und besitzen eine Kommunikationsschnittste
Mit TA4 kommen weitere Stromquellen dazu, aber auch höhere logistische Herausforderungen (Stromtrassen, Item Transport).
## History
- 28.09.2019: Um Solaranlage erweitert
- 05.10.2019: Daten zur Solaranlage und Beschreibung zum Wechselrichter und zum Power-Terminal geändert

View File

@ -167,9 +167,7 @@ Bei Volllast kann ein Akku 400 s lang Strom aufnehmen und wenn er voll ist, auch
### TA3 Strom Terminal / Power Terminal
Das Strom-Terminal muss von eine Verteilerdose platziert werden. Es zeigt Daten aus dem Stromnetz an wie:
- Leistung alle Generatoren
- Leistung alles Akkus (Sekundärquellen)
- Leistungsaufnahme aller Maschinen
- Anzahl und Leistung der verschiedenen Generatoren und Akkus (aktuell/maximal)
- Anzahl der Netzwerk-Blöcke (max. 1000)
Die Daten des Terminals werden beim Öffnen des Menüs und dann nur durch Anklicken des "Update" Buttons aktualisiert.

View File

@ -63,19 +63,21 @@ Es empfiehlt sich daher, nach heißen Steppen und Wüsten für die Solaranlage A
Für den Stromtransport stehen die Überlandleitungen zur Verfügung.
Es kann aber auch Wasserstoff produziert werden, welcher sich transportieren und am Ziel wieder zu Strom umwandeln lässt (geplant).
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.
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!).
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 hat zwei Anschlussseiten, eine für das rote Kabel zu den Solarmodulen und eine für das graue Stromkabel ins Stromnetz.
Der Plan rechts zeigt 3 Einheiten mit je zwei Solarmodulen und einem Trägermodul, über rote Kabel mit dem Wechselrichter verbunden.
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).
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.
[techage_ta4_solar|image]
[ta4_solarplant|plan]
### TA4 Solarmodul / Solar Module
Das Solarmodul muss an das Trägermodul gesetzt werden. Es sind immer zwei Solarmodule notwendig.
Im Paar leisten die Solarmodule bis 4 ku, je nach Temperatur.
Im Paar leisten die Solarmodule bis 3 ku, je nach Temperatur.
Bei den Solarmodul muss darauf geachtet werden, dass diese das volle Tageslicht haben und nicht durch Blöcke oder Bäume beschattet sind.
[ta4_solarmodule|image]
@ -92,7 +94,8 @@ Die Trägermodule können direkt aneinander gesetzt und so zu einer Modulreihe v
### TA4 Solar Wechselrichter / Solar Inverter
Der Wechselrichter wandelt den Solarstrom (DC) in Wechselstrom (AC) um, so dass dieser in das Stromnetz eingespeist werden kann.
Ein Wechselrichter kann maximal 120 ku an Strom einspeisen, was 30 Solarmodulen oder auch mehr entspricht.
Ein Wechselrichter, bestehend aus zwei Blöcken kann maximal 100 ku an Strom einspeisen, was 33 Solarmodulen oder auch mehr entspricht.
Der DC Block muss links neben den AC-Block gesetzt werden.
[ta4_solar_inverter|image]

View File

@ -70,7 +70,10 @@ function techage.register_junction(name, size, boxes, network, node, index)
ndef.drop = name..(index or "0")
minetest.register_node(name..idx, ndef)
-- Register in addition for power distribution
techage.power.register_node({name..idx}, {power_network = network})
techage.power.register_node({name..idx}, {
power_network = network,
after_tube_update = ndef.after_tube_update,
})
end
end

View File

@ -17,6 +17,7 @@
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos
local M = minetest.get_meta
local N = function(pos) return minetest.get_node(pos).name end
local D = techage.Debug
-- Techage Related Data
@ -194,7 +195,7 @@ minetest.register_lbm({
-------------------------------------------------- Migrate
local function conection_color(t)
local function connection_color(t)
local count = 0
for _ in pairs(t) do count = count + 1 end
if count == 0 then return count, "#FF0000" end
@ -245,23 +246,25 @@ local function connection_walk(pos, clbk)
end
end
-- walk limited by number of nodes and hops
local function connection_walk2(pos, max_hops, max_nodes, clbk)
-- Comfort walk with abort condition and additional info
-- num_hops is for internal use only
-- clbk(pos, node, mem, num_hops, num_nodes)
local function limited_connection_walk(pos, clbk, num_hops)
num_hops = num_hops or 1
local mem = tubelib2.get_mem(pos)
mem.interrupted_dirs = mem.interrupted_dirs or {}
if clbk then
clbk(pos, mem, max_hops)
local node = techage.get_node_lvm(pos)
if clbk(pos, node, mem, num_hops, NumNodes) then return true end
end
max_hops = max_hops - 1
if max_hops < 0 then return end
num_hops = num_hops + 1
for out_dir,item in pairs(mem.connections or {}) do
if item.pos and not pos_already_reached(item.pos) and
not mem.interrupted_dirs[out_dir] then
max_nodes = max_nodes - 1
if max_nodes < 0 then return end
connection_walk2(item.pos, max_hops, max_nodes, clbk)
limited_connection_walk(item.pos, clbk, num_hops)
end
end
return false
end
-- if no power available
@ -537,7 +540,7 @@ function techage.power.power_available(pos, mem, needed)
return false
end
-- Power terminal function
-- Debug info, used by junction boxes
function techage.power.power_accounting(pos, mem)
if mem.pwr_master_pos and (mem.pwr_power_provided_cnt or 0) > 0 then
mem.pwr_power_provided_cnt = (mem.pwr_power_provided_cnt or 0) - 1
@ -628,11 +631,10 @@ function techage.power.power_network_available(start_pos)
Route = {}
NumNodes = 0
pos_already_reached(start_pos)
local sum = 0
connection_walk2(start_pos, 2, 3, function(pos, mem)
sum = sum + 1
limited_connection_walk(start_pos, function(pos, node, mem, _, num_nodes)
return num_nodes > 2
end)
return sum > 1
return NumNodes > 2
end
function techage.power.mark_nodes(name, start_pos)
@ -640,8 +642,36 @@ function techage.power.mark_nodes(name, start_pos)
NumNodes = 0
pos_already_reached(start_pos)
techage.unmark_position(name)
connection_walk2(start_pos, 3, 100, function(pos, mem, max_hops)
local num, color = conection_color(mem.connections or {})
limited_connection_walk(start_pos, function(pos, node, mem, num_hops, num_nodes)
local num, color = connection_color(mem.connections or {})
techage.mark_position(name, pos, S(pos).." : "..num, color)
return num_hops >= 3 or num_nodes >= 100
end)
end
-- Network walk with callback for each node:
--
-- limited_connection_walk(pos, clbk) --> num_hops, num_nodes
--
-- called function: clbk(pos, node, mem, num_hops, num_nodes)
-- walk will be arborted if function returns true
function techage.power.limited_connection_walk(pos, clbk)
Route = {}
NumNodes = 0
pos_already_reached(pos)
limited_connection_walk(pos, clbk)
return NumNodes
end
--local function test()
-- print("test")
-- local cnt = 0
-- tubelib2.walk_over_all(function(pos, mem)
-- local node = techage.get_node_lvm(pos)
-- print(S(pos), node.name)
-- cnt = cnt + 1
-- end)
-- print("cnt = "..cnt)
--end
--minetest.after(1, test)

View File

@ -15,6 +15,7 @@
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos
local M = minetest.get_meta
local N = function(pos) return minetest.get_node(pos).name end
-- Techage Related Data
local PWR = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).power end
local PWRN = function(node) return (minetest.registered_nodes[node.name] or {}).power end
@ -92,6 +93,17 @@ function techage.power.after_rotate_node(pos, cable)
cable:after_place_node(pos)
end
local function add_connection(mem, pos, out_dir, peer_pos, peer_in_dir, power)
mem.connections = mem.connections or {}
if not peer_pos or not valid_indir(peer_pos, peer_in_dir)
or not valid_outdir(pos, out_dir)
or not matching_nodes(pos, peer_pos) then
mem.connections[out_dir] = nil -- del connection
else
mem.connections[out_dir] = {pos = peer_pos, in_dir = peer_in_dir}
end
end
function techage.power.register_node(names, pwr_def)
for _,name in ipairs(names) do
local ndef = minetest.registered_nodes[name]
@ -103,18 +115,20 @@ function techage.power.register_node(names, pwr_def)
on_nopower = pwr_def.on_nopower,
on_getpower = pwr_def.on_getpower,
power_network = pwr_def.power_network,
after_place_node = ndef.after_place_node,
after_dig_node = ndef.after_dig_node,
after_tube_update = ndef.after_tube_update,
after_place_node = pwr_def.after_place_node,
after_dig_node = pwr_def.after_dig_node,
after_tube_update = pwr_def.after_tube_update,
},
-- after_place_node decorator
after_place_node = function(pos, placer, itemstack, pointed_thing)
local res
local pwr = PWR(pos)
set_conn_dirs(pos, pwr.conn_sides)
pwr.power_network:after_place_node(pos)
if pwr.after_place_node then
return pwr.after_place_node(pos, placer, itemstack, pointed_thing)
res = pwr.after_place_node(pos, placer, itemstack, pointed_thing)
end
pwr.power_network:after_place_node(pos)
return res
end,
-- after_dig_node decorator
after_dig_node = function(pos, oldnode, oldmetadata, digger)
@ -129,16 +143,7 @@ function techage.power.register_node(names, pwr_def)
after_tube_update = function(node, pos, out_dir, peer_pos, peer_in_dir)
local pwr = PWR(pos)
local mem = tubelib2.get_mem(pos)
mem.connections = mem.connections or {}
if not peer_pos or not valid_indir(peer_pos, peer_in_dir)
or not valid_outdir(pos, out_dir)
or not matching_nodes(pos, peer_pos) then
mem.connections[out_dir] = nil -- del connection
else
mem.connections[out_dir] = {pos = peer_pos, in_dir = peer_in_dir}
end
-- To be called delayed, so that all network connections have been established
minetest.after(0.2, network_changed, pos, mem)
add_connection(mem, pos, out_dir, peer_pos, peer_in_dir, pwr)
if pwr.after_tube_update then
return pwr.after_tube_update(node, pos, out_dir, peer_pos, peer_in_dir)
end
@ -153,38 +158,12 @@ end
-- For all kind of nodes, used as cable filler/grout
function techage.power.after_tube_update(node, pos, out_dir, peer_pos, peer_in_dir, power)
local mem = tubelib2.get_mem(pos)
mem.connections = mem.connections or {}
if not peer_pos or not valid_indir(peer_pos, peer_in_dir)
or not valid_outdir(pos, out_dir)
or not matching_nodes(pos, peer_pos) then
mem.connections[out_dir] = nil -- del connection
else
mem.connections[out_dir] = {pos = peer_pos, in_dir = peer_in_dir}
end
-- To be called delayed, so that all network connections have been established
minetest.after(0.2, network_changed, pos, mem)
add_connection(mem, pos, out_dir, peer_pos, peer_in_dir, power)
if power.after_tube_update then
return power.after_tube_update(node, pos, out_dir, peer_pos, peer_in_dir)
end
end
-- Used for "Ad hoc" networking (nodes with support for two different network types)
function techage.power.add_connection(pos, out_dir, network, add)
local peer_pos, peer_in_dir = network:get_connected_node_pos(pos, out_dir)
if peer_pos then
local in_dir = tubelib2.Turn180Deg[out_dir]
local peer_out_dir = tubelib2.Turn180Deg[peer_in_dir]
local mem = tubelib2.get_mem(peer_pos)
mem.connections = mem.connections or {}
if add then
mem.connections[peer_out_dir] = {pos = pos, in_dir = in_dir}
else
mem.connections[peer_out_dir] = nil -- del connection
end
end
end
function techage.power.percent(max_val, curr_val)
return math.min(math.ceil(((curr_val or 0) * 100.0) / (max_val or 1.0)), 100)
end
@ -237,7 +216,7 @@ function techage.power.power_cut(pos, dir, cable, cut)
if cut then
mem.interrupted_dirs = {true, true, true, true, true, true}
for dir,_ in pairs(mem.connections) do
mem.interrupted_dirs[dir] = false
mem.interrupted_dirs[dir] = false -- open the port
techage.power.network_changed(npos, mem)
mem.interrupted_dirs[dir] = true
end

View File

@ -184,16 +184,6 @@ minetest.register_node("techage:power_pole", {
{ -2/32, -4/32, 12/32, 2/32, 4/32, 16/32},
},
},
after_place_node = function(pos, placer, itemstack, pointed_thing)
M(pos):set_string("owner", placer:get_player_name())
if techage.is_protected(pos, placer:get_player_name()) then
minetest.remove_node(pos)
return true
end
local node = minetest.get_node(pos)
node.name = "techage:power_pole_conn"
minetest.swap_node(pos, node)
end,
on_rotate = screwdriver.disallow, -- important!
paramtype = "light",
@ -331,7 +321,21 @@ minetest.register_node("techage:power_pole3", {
sounds = default.node_sound_defaults(),
})
techage.power.register_node({"techage:power_pole", "techage:power_pole_conn"}, {
techage.power.register_node({"techage:power_pole"}, {
power_network = Cable,
after_place_node = function(pos, placer, itemstack, pointed_thing)
M(pos):set_string("owner", placer:get_player_name())
if techage.is_protected(pos, placer:get_player_name()) then
minetest.remove_node(pos)
return true
end
local node = minetest.get_node(pos)
node.name = "techage:power_pole_conn"
minetest.swap_node(pos, node)
end,
})
techage.power.register_node({"techage:power_pole_conn"}, {
power_network = Cable,
})

View File

@ -23,15 +23,13 @@ local Solar = techage.TA4_Cable
local power = techage.power
local CYCLE_TIME = 2
local PWR_PERF = 120
local PWR_PERF = 100
local function determine_power(pos, mem)
-- We have to use get_connected_node_pos, because the inverter has already
-- a AC power connection. An additional DC power connection is not possibe,
-- so we have to start the connection_walk on the next node.
-- determine DC node position
local dir = M(pos):get_int("left_dir")
local pos1 = Solar:get_connected_node_pos(pos, dir)
local max_power, num_inverter = power.get_power(pos1, "techage:ta4_solar_inverter")
local pos1 = tubelib2.get_pos(pos, dir)
local max_power, num_inverter = power.get_power(pos1, "techage:ta4_solar_inverterDC")
if num_inverter == 1 then
mem.max_power = math.min(PWR_PERF, max_power)
else
@ -140,13 +138,13 @@ local function on_rightclick(pos)
end
minetest.register_node("techage:ta4_solar_inverter", {
description = S("TA4 Solar Inverter"),
description = S("TA4 Solar Inverter AC"),
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_top.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_ta4_cable.png",
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_open.png",
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_inverter.png",
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_inverter.png",
},
@ -155,42 +153,46 @@ minetest.register_node("techage:ta4_solar_inverter", {
on_rotate = screwdriver.disallow,
is_ground_content = false,
after_place_node = function(pos, placer)
local mem = tubelib2.init_mem(pos)
mem.running = false
mem.delivered = 0
local number = techage.add_node(pos, "techage:ta4_solar_inverter")
State:node_init(pos, mem, number)
local meta = M(pos)
meta:set_string("formspec", formspec(State, pos, mem))
-- Solar/low power cable direction
local outdir = techage.power.side_to_outdir(pos, "L")
meta:set_int("left_dir", outdir)
techage.power.add_connection(pos, outdir, Solar, true)
Solar:after_place_node(pos)
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
local outdir = M(pos):get_int("left_dir")
techage.power.add_connection(pos, outdir, Solar, false)
Solar:after_dig_node(pos)
end,
after_tube_update = function(node, pos, out_dir, peer_pos, peer_in_dir, power)
techage.power.add_connection(pos, out_dir, Solar, true)
end,
on_receive_fields = on_receive_fields,
on_rightclick = on_rightclick,
on_timer = node_timer,
})
minetest.register_node("techage:ta4_solar_inverterDC", {
description = S("TA4 Solar Inverter DC"),
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta4.png^techage_frame_ta4_top.png",
"techage_filling_ta4.png^techage_frame_ta4.png",
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_open.png",
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_ta4_cable.png",
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_inverterDC.png",
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_inverterDC.png",
},
paramtype2 = "facedir",
groups = {cracky=2, crumbly=2, choppy=2},
on_rotate = screwdriver.disallow,
is_ground_content = false,
})
techage.power.register_node({"techage:ta4_solar_inverter"}, {
conn_sides = {"R"},
power_network = Power,
after_place_node = function(pos, placer)
-- DC block direction
M(pos):set_int("left_dir", techage.power.side_to_outdir(pos, "L"))
local number = techage.add_node(pos, "techage:ta4_solar_inverter")
local mem = tubelib2.init_mem(pos)
State:node_init(pos, mem, number)
M(pos):set_string("formspec", formspec(State, pos, mem))
end,
})
Solar:add_secondary_node_names({"techage:ta4_solar_inverter"})
techage.power.register_node({"techage:ta4_solar_inverterDC"}, {
conn_sides = {"L"},
power_network = Solar,
})
techage.register_node({"techage:ta4_solar_inverter"}, {
on_recv_message = function(pos, src, topic, payload)
@ -205,8 +207,16 @@ minetest.register_craft({
output = "techage:ta4_solar_inverter",
recipe = {
{'default:steel_ingot', 'dye:green', 'default:steel_ingot'},
{'techage:ta4_power_cableS', 'techage:ta4_wlanchip', 'techage:electric_cableS'},
{'', 'techage:ta4_wlanchip', 'techage:electric_cableS'},
{'default:steel_ingot', "techage:baborium_ingot", 'default:steel_ingot'},
},
})
minetest.register_craft({
output = "techage:ta4_solar_inverterDC",
recipe = {
{'default:steel_ingot', 'dye:green', 'default:steel_ingot'},
{'techage:ta4_power_cableS', '', ''},
{'default:steel_ingot', "techage:baborium_ingot", 'default:steel_ingot'},
},
})

View File

@ -77,24 +77,6 @@ minetest.register_node("techage:ta4_solar_minicell", {
{-7/32, -16/32, -7/32, 7/32, -8/32, 7/32},
},
},
after_place_node = function(pos)
local meta = minetest.get_meta(pos)
local number = techage.add_node(pos, "techage:ta4_solar_minicell")
meta:set_string("node_number", number)
meta:set_string("infotext", S("TA4 Streetlamp Solar Cell").." "..number)
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
local mem = tubelib2.get_mem(pos)
mem.capa = 0
mem.providing = false
minetest.get_node_timer(pos):start(CYCLE_TIME)
end,
after_dig_node = function(pos)
techage.remove_node(pos)
tubelib2.del_mem(pos)
end,
paramtype2 = "facedir",
groups = {cracky=2, crumbly=2, choppy=2},
is_ground_content = false,
@ -104,6 +86,21 @@ minetest.register_node("techage:ta4_solar_minicell", {
techage.power.register_node({"techage:ta4_solar_minicell"}, {
power_network = Cable,
conn_sides = {"D"},
after_place_node = function(pos)
local meta = minetest.get_meta(pos)
local number = techage.add_node(pos, "techage:ta4_solar_minicell")
meta:set_string("node_number", number)
meta:set_string("infotext", S("TA4 Streetlamp Solar Cell").." "..number)
local mem = tubelib2.init_mem(pos)
mem.capa = 0
mem.providing = false
minetest.get_node_timer(pos):start(CYCLE_TIME)
end,
after_dig_node = function(pos)
techage.remove_node(pos)
tubelib2.del_mem(pos)
end,
})
techage.register_node({"techage:ta4_solar_minicell"}, {

View File

@ -17,7 +17,7 @@ local P = minetest.string_to_pos
local M = minetest.get_meta
local S = techage.S
local PWR_PERF = 4
local PWR_PERF = 3
local Cable = techage.TA4_Cable
local power = techage.power
@ -81,6 +81,7 @@ end
minetest.register_node("techage:ta4_solar_module", {
description = S("TA4 Solar Module"),
inventory_image = "techage_solar_module_top.png",
tiles = {
-- up, down, right, left, back, front
"techage_solar_module_top.png",
@ -120,13 +121,6 @@ minetest.register_node("techage:ta4_solar_carrier", {
{-3/8, 5/16, -1/2, 3/8, 7/16, 1/2},
},
},
after_place_node = function(pos)
M(pos):set_int("temperature", temperature(pos))
M(pos):set_int("left_param2", get_param2(pos, "L"))
M(pos):set_int("right_param2", get_param2(pos, "R"))
end,
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky=2, crumbly=2, choppy=2},
@ -152,13 +146,6 @@ minetest.register_node("techage:ta4_solar_carrierB", {
{-1/8, -6/16, -1/2, 1/8, 8/16, 1/2},
},
},
after_place_node = function(pos)
M(pos):set_int("temperature", temperature(pos))
M(pos):set_int("left_param2", get_param2(pos, "L"))
M(pos):set_int("right_param2", get_param2(pos, "R"))
end,
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky=2, crumbly=2, choppy=2},
@ -195,12 +182,22 @@ techage.power.register_node({"techage:ta4_solar_carrier"}, {
power_network = Cable,
on_getpower = on_getpower1,
conn_sides ={"F", "B"},
after_place_node = function(pos)
M(pos):set_int("temperature", temperature(pos))
M(pos):set_int("left_param2", get_param2(pos, "L"))
M(pos):set_int("right_param2", get_param2(pos, "R"))
end,
})
techage.power.register_node({"techage:ta4_solar_carrierB"}, {
power_network = Cable,
on_getpower = on_getpower2,
conn_sides ={"F", "B"},
after_place_node = function(pos)
M(pos):set_int("temperature", temperature(pos))
M(pos):set_int("left_param2", get_param2(pos, "L"))
M(pos):set_int("right_param2", get_param2(pos, "R"))
end,
})
minetest.register_craft({

View File

@ -246,22 +246,11 @@ minetest.register_node("techage:boiler2", {
on_rightclick = on_rightclick,
on_construct = function(pos)
tubelib2.init_mem(pos)
local inv = M(pos):get_inventory()
inv:set_size('water', 1)
inv:set_size('input', 1)
end,
after_place_node = function(pos, placer)
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
local mem = tubelib2.get_mem(pos)
State:node_init(pos, mem, "")
local node = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z})
if node.name == "techage:boiler1" then
on_rightclick(pos)
end
end,
on_metadata_inventory_put = function(pos)
minetest.after(0.5, move_to_water, pos)
end,
@ -275,6 +264,14 @@ minetest.register_node("techage:boiler2", {
techage.power.register_node({"techage:boiler2"}, {
conn_sides = {"U"},
power_network = Pipe,
after_place_node = function(pos, placer)
local mem = tubelib2.init_mem(pos)
State:node_init(pos, mem, "")
local node = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z})
if node.name == "techage:boiler1" then
on_rightclick(pos)
end
end,
})
techage.register_node({"techage:boiler2"}, {

View File

@ -28,14 +28,6 @@ local function swap_node(pos, name)
minetest.swap_node(pos, node)
end
-- called with any pipe change
local function after_tube_update(node, pos, out_dir, peer_pos, peer_in_dir)
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
local mem = tubelib2.get_mem(pos)
mem.running = false
swap_node(pos, "techage:cylinder")
end
minetest.register_node("techage:cylinder", {
description = S("TA2 Cylinder"),
tiles = {
@ -48,7 +40,6 @@ minetest.register_node("techage:cylinder", {
"techage_filling_ta2.png^techage_cylinder.png^techage_frame_ta2.png",
},
on_construct = tubelib2.init_mem,
paramtype2 = "facedir",
groups = {cracky=2, crumbly=2, choppy=2},
on_rotate = screwdriver.disallow,
@ -86,7 +77,6 @@ minetest.register_node("techage:cylinder_on", {
},
},
after_tube_update = after_tube_update,
paramtype2 = "facedir",
groups = {not_in_creative_inventory=1},
diggable = false,
@ -98,6 +88,11 @@ minetest.register_node("techage:cylinder_on", {
techage.power.register_node({"techage:cylinder", "techage:cylinder_on"}, {
conn_sides = {"L"},
power_network = Pipe,
after_tube_update = function(node, pos, out_dir, peer_pos, peer_in_dir)
local mem = tubelib2.get_mem(pos)
mem.running = false
swap_node(pos, "techage:cylinder")
end,
})
-- used by firebox

View File

@ -128,15 +128,6 @@ minetest.register_node("techage:flywheel", {
"techage_filling_ta2.png^techage_frame_ta2.png^techage_flywheel.png^[transformFX]",
},
on_construct = tubelib2.init_mem,
after_place_node = function(pos, placer)
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
local mem = tubelib2.get_mem(pos)
State:node_init(pos, mem, "")
on_rightclick(pos)
end,
on_receive_fields = on_receive_fields,
on_rightclick = on_rightclick,
on_timer = node_timer,
@ -203,6 +194,12 @@ minetest.register_node("techage:flywheel_on", {
techage.power.register_node({"techage:flywheel", "techage:flywheel_on"}, {
conn_sides = {"R"},
power_network = Axle,
after_place_node = function(pos, placer)
local mem = tubelib2.init_mem(pos)
State:node_init(pos, mem, "")
on_rightclick(pos)
end,
})
techage.register_node({"techage:flywheel", "techage:flywheel_on"}, {

View File

@ -49,31 +49,17 @@ local function node_timer(pos, elapsed)
end
-- to be able to restart the node after server crashes
local function on_rightclick(pos, node, clicker)
local function on_rightclick(pos)
local mem = tubelib2.get_mem(pos)
minetest.get_node_timer(pos):start(CYCLE_TIME)
power.consumer_start(pos, mem, CYCLE_TIME, PWR_NEEDED)
end
local function after_place_node(pos, placer, itemstack, pointed_thing)
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
local mem = tubelib2.get_mem(pos)
minetest.get_node_timer(pos):start(CYCLE_TIME)
power.consumer_start(pos, mem, CYCLE_TIME, PWR_NEEDED)
end
local function after_tube_update(node, pos, out_dir, peer_pos, peer_in_dir)
techage.switch_axles(pos, node.name == "techage:gearbox_on")
end
minetest.register_node("techage:gearbox", {
description = S("TA2 Gearbox"),
tiles = {"techage_filling_ta2.png^techage_axle_gearbox.png^techage_frame_ta2.png"},
on_construct = tubelib2.init_mem,
after_place_node = after_place_node,
on_rightclick = on_rightclick,
after_tube_update = after_tube_update,
on_timer = node_timer,
paramtype2 = "facedir",
groups = {cracky=2, crumbly=2, choppy=2},
@ -98,10 +84,8 @@ minetest.register_node("techage:gearbox_on", {
},
},
after_place_node = after_place_node,
on_rightclick = on_rightclick,
on_timer = node_timer,
after_tube_update = after_tube_update,
paramtype2 = "facedir",
groups = {not_in_creative_inventory=1},
diggable = false,
@ -115,6 +99,12 @@ techage.power.register_node({"techage:gearbox", "techage:gearbox_on"}, {
power_network = Axle,
on_power = on_power,
on_nopower = on_nopower,
after_place_node = function(pos, placer, itemstack, pointed_thing)
on_rightclick(pos)
end,
after_tube_update = function(node, pos, out_dir, peer_pos, peer_in_dir)
techage.switch_axles(pos, node.name == "techage:gearbox_on")
end,
})
minetest.register_craft({

Binary file not shown.

Before

Width:  |  Height:  |  Size: 184 B

After

Width:  |  Height:  |  Size: 248 B

View File

@ -113,6 +113,7 @@ local function start_rotor(pos, mem)
end
mem.providing = true
mem.delivered = 0
power.generator_start(pos, mem, PWR_PERF)
local hash = minetest.hash_node_position(pos)
if Rotors[hash] then
@ -122,6 +123,7 @@ end
local function stop_rotor(pos, mem)
mem.providing = false
mem.delivered = 0
power.generator_stop(pos, mem)
local hash = minetest.hash_node_position(pos)
if Rotors[hash] then
@ -147,7 +149,7 @@ local function node_timer(pos, elapsed)
end
end
if mem.providing then
power.generator_alive(pos, mem)
mem.delivered = power.generator_alive(pos, mem)
end
return true
end
@ -165,34 +167,7 @@ minetest.register_node("techage:ta4_wind_turbine", {
"techage_rotor.png^techage_appl_open.png",
},
on_construct = tubelib2.init_mem,
after_place_node = function(pos, placer)
local meta = M(pos)
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
local mem = tubelib2.get_mem(pos)
local own_num = techage.add_node(pos, "techage:ta4_wind_turbine")
meta:set_string("node_number", own_num)
meta:set_string("owner", placer:get_player_name())
meta:set_string("infotext", S("TA4 Wind Turbine").." "..own_num)
mem.providing = false
mem.running = true
add_rotor(pos, mem, placer:get_player_name())
minetest.get_node_timer(pos):start(CYCLE_TIME)
end,
on_timer = node_timer,
after_dig_node = function(pos)
local hash = minetest.hash_node_position(pos)
if Rotors[hash] and Rotors[hash]:get_luaentity() then
Rotors[hash]:remove()
end
Rotors[hash] = nil
techage.remove_node(pos)
tubelib2.del_mem(pos)
end,
paramtype2 = "facedir",
groups = {cracky=2, crumbly=2, choppy=2},
is_ground_content = false,
@ -230,6 +205,28 @@ minetest.register_entity("techage:rotor_ent", {initial_properties = {
techage.power.register_node({"techage:ta4_wind_turbine"}, {
power_network = Cable,
conn_sides = {"D"},
after_place_node = function(pos, placer)
local meta = M(pos)
local mem = tubelib2.init_mem(pos)
local own_num = techage.add_node(pos, "techage:ta4_wind_turbine")
meta:set_string("node_number", own_num)
meta:set_string("owner", placer:get_player_name())
meta:set_string("infotext", S("TA4 Wind Turbine").." "..own_num)
mem.providing = false
mem.running = true
add_rotor(pos, mem, placer:get_player_name())
minetest.get_node_timer(pos):start(CYCLE_TIME)
end,
after_dig_node = function(pos)
local hash = minetest.hash_node_position(pos)
if Rotors[hash] and Rotors[hash]:get_luaentity() then
Rotors[hash]:remove()
end
Rotors[hash] = nil
techage.remove_node(pos)
tubelib2.del_mem(pos)
end,
})
techage.register_node({"techage:ta4_wind_turbine"}, {