Add new power terminal commands
This commit is contained in:
parent
276a6a37f3
commit
b632ee6212
@ -243,7 +243,7 @@ local function collect_network_nodes(pos, outdir, tlib2)
|
||||
end
|
||||
for _,ntype in ipairs(ntypes) do
|
||||
if not netw[ntype] then netw[ntype] = {} end
|
||||
netw[ntype][#netw[ntype] + 1] = {pos = pos, indir = indir, nominal = ndef.nominal}
|
||||
netw[ntype][#netw[ntype] + 1] = {pos = pos, indir = indir, nominal = ndef.nominal, regenerative = ndef.regenerative}
|
||||
end
|
||||
end)
|
||||
netw.best_before = minetest.get_gametime() + BEST_BEFORE
|
||||
@ -332,6 +332,10 @@ function techage.networks.build_network(pos, outdir, tlib2, netID)
|
||||
Networks[tlib2.tube_type] = Networks[tlib2.tube_type] or {}
|
||||
Networks[tlib2.tube_type][netID] = netw
|
||||
netw.alive = 3
|
||||
-- sort generating1 nodes, so that regenerative ones will be used first
|
||||
if netw.gen1 then
|
||||
table.sort(netw.gen1, function(a,b) return a.regenerative and not b.regenerative end)
|
||||
end
|
||||
techage.schedule.start(tlib2.tube_type, netID)
|
||||
end
|
||||
|
||||
|
@ -1238,7 +1238,7 @@ techage.manual_DE.aText = {
|
||||
"\n"..
|
||||
"\n",
|
||||
"Der Wärmetauscher besteht aus 3 Teilen\\, die aufeinander gesetzt werden müssen\\, wobei der Pfeil des ersten Blockes Richtung Turbine zeigen muss. Die Rohrleitungen müssen mit den gelben TA4 Röhren aufgebaut werden.\n"..
|
||||
"Der Wärmetauscher muss am Stromnetz angeschlossen werden. Der Wärmetauscher kann 60 ku aufnehmen.\n"..
|
||||
"Der Wärmetauscher muss am Stromnetz angeschlossen werden. Der Wärmetauscher lädt den Energiespeicher wieder auf\\, wenn ausreichend Strom zur Verfügung steht und der Energiespeicher weniger als 95 % geladen ist. Der Wärmetauscher nimmt dabei 60 ku auf.\n"..
|
||||
"\n"..
|
||||
"\n"..
|
||||
"\n",
|
||||
@ -1610,7 +1610,7 @@ techage.manual_DE.aText = {
|
||||
"\n"..
|
||||
"\n",
|
||||
"Der Recycler ist eine Maschine\\, die alle Techage Rezepte rückwärts abarbeitet\\, also Maschinen und Blöcke wieder in die Bestandteile zerlegen kann. Die Maschine kann so ziemlich alle Techage und Hyperloop Blöcke zerlegen.\n"..
|
||||
"Aber nicht alle Materialen lassen sich recyclen:\n"..
|
||||
"Aber nicht alle Zutaten/Materialien der Rezepte lassen sich recyclen:\n"..
|
||||
"\n"..
|
||||
" - Holz wird zu Sticks\n"..
|
||||
" - Stein wird zu Sand oder Kies\n"..
|
||||
@ -1629,7 +1629,7 @@ techage.manual_DE.aText = {
|
||||
"\n"..
|
||||
"Die Laserblöcke selbst benötigen keinen Strom.\n"..
|
||||
"\n"..
|
||||
"\n"..
|
||||
"t\n"..
|
||||
"\n",
|
||||
}
|
||||
|
||||
|
@ -1215,7 +1215,7 @@ techage.manual_EN.aText = {
|
||||
"\n"..
|
||||
"\n",
|
||||
"The heat exchanger consists of 3 parts that must be placed on top of each other\\, with the arrow of the first block pointing towards the turbine. The pipes must be built with the yellow TA4 pipes.\n"..
|
||||
"The heat exchanger must be connected to the power grid. The heat exchanger can consume 60 ku.\n"..
|
||||
"The heat exchanger must be connected to the power grid. The heat exchanger charges the energy store again when sufficient electricity is available and the energy storage is less than 95% charged. The heat exchanger takes up 60 ku. \n"..
|
||||
"\n"..
|
||||
"\n"..
|
||||
"\n",
|
||||
@ -1589,7 +1589,7 @@ techage.manual_EN.aText = {
|
||||
"\n",
|
||||
"The recycler is a machine that processes all Techage recipes backwards\\, i.e. it can dismantle machines and blocks back into their components. \n"..
|
||||
"\n"..
|
||||
"The machine can disassemble pretty much any Techage and Hyperloop blocks. But not all materials can be recycled:\n"..
|
||||
"The machine can disassemble pretty much any Techage and Hyperloop blocks. But not all recipe items/materials can be recycled:\n"..
|
||||
"\n"..
|
||||
" - Wood turns into sticks\n"..
|
||||
" - Stone turns into sand or gravel\n"..
|
||||
|
@ -228,6 +228,9 @@ techage.register_node({"techage:ta4_generator", "techage:ta4_generator_on"}, {
|
||||
local nvm = techage.get_nvm(pos)
|
||||
if topic == "delivered" then
|
||||
return math.floor((nvm.provided or 0) + 0.5)
|
||||
elseif topic == "load" then
|
||||
local capa_max, capa = transfer_turbine(pos, "state")
|
||||
return techage.power.percent(capa_max, capa)
|
||||
else
|
||||
return State:on_receive_message(pos, topic, payload)
|
||||
end
|
||||
|
@ -171,7 +171,7 @@ local function node_timer(pos, elapsed)
|
||||
local taken = 0
|
||||
local given = 0
|
||||
|
||||
if nvm.capa < (nvm.capa_max * 0.9) and not nvm.charging then
|
||||
if nvm.capa < (nvm.capa_max * 0.95) and not nvm.charging then
|
||||
taken = power.consumer_alive(pos, Cable, CYCLE_TIME)
|
||||
elseif nvm.capa < nvm.capa_max and nvm.charging then
|
||||
taken = power.consumer_alive(pos, Cable, CYCLE_TIME)
|
||||
|
@ -112,8 +112,9 @@ local function get_diameter(pos, in_dir)
|
||||
end
|
||||
|
||||
local function check_volume(pos, in_dir, owner)
|
||||
local radius = (get_diameter(pos, in_dir) - 1) / 2
|
||||
if radius then
|
||||
local diameter = get_diameter(pos, in_dir)
|
||||
if diameter then
|
||||
local radius = (diameter - 1) / 2
|
||||
local dir = tubelib2.Dir6dToVector[in_dir]
|
||||
local cpos = vector.add(pos, vector.multiply(dir, radius))
|
||||
-- calculate size
|
||||
@ -138,8 +139,9 @@ end
|
||||
|
||||
-- provide position behind the obsidian_glass
|
||||
local function check_window(pos, in_dir)
|
||||
local radius = (get_diameter(pos, in_dir) - 1) / 2
|
||||
if radius then
|
||||
local diameter = get_diameter(pos, in_dir)
|
||||
if diameter then
|
||||
local radius = (diameter - 1) / 2
|
||||
local dir = tubelib2.Dir6dToVector[in_dir]
|
||||
local cpos = vector.add(pos, vector.multiply(dir, radius))
|
||||
-- calculate size
|
||||
|
@ -23,6 +23,11 @@ local function transfer_heatexchanger3(pos, topic, payload)
|
||||
{"techage:heatexchanger3"})
|
||||
end
|
||||
|
||||
local function transfer_heatexchanger1(pos, topic, payload)
|
||||
return techage.transfer(pos, "L", topic, payload, Pipe,
|
||||
{"techage:heatexchanger1"})
|
||||
end
|
||||
|
||||
local function transfer_generator(pos, topic, payload)
|
||||
return techage.transfer(pos, "R", topic, payload, nil,
|
||||
{"techage:ta4_generator", "techage:ta4_generator_on"})
|
||||
@ -156,6 +161,8 @@ techage.register_node({"techage:ta4_turbine", "techage:ta4_turbine_on"}, {
|
||||
stop_sound(pos)
|
||||
nvm.running = false
|
||||
return true
|
||||
elseif topic == "state" then
|
||||
return transfer_heatexchanger1(pos, topic, payload)
|
||||
end
|
||||
end,
|
||||
on_node_load = function(pos, node)
|
||||
|
28
i18n.py
28
i18n.py
@ -21,20 +21,24 @@ params = {"recursive": False,
|
||||
"mods": False,
|
||||
"verbose": False,
|
||||
"folders": [],
|
||||
"no-old-file": False
|
||||
"no-old-file": False,
|
||||
"break-long-lines": False,
|
||||
"sort": False
|
||||
}
|
||||
# Available CLI options
|
||||
options = {"recursive": ['--recursive', '-r'],
|
||||
"help": ['--help', '-h'],
|
||||
"mods": ['--installed-mods'],
|
||||
"mods": ['--installed-mods', '-m'],
|
||||
"verbose": ['--verbose', '-v'],
|
||||
"no-old-file": ['--no-old-file']
|
||||
"no-old-file": ['--no-old-file', '-O'],
|
||||
"break-long-lines": ['--break-long-lines', '-b'],
|
||||
"sort": ['--sort', '-s']
|
||||
}
|
||||
|
||||
# Strings longer than this will have extra space added between
|
||||
# them in the translation files to make it easier to distinguish their
|
||||
# beginnings and endings at a glance
|
||||
doublespace_threshold = 60
|
||||
doublespace_threshold = 80
|
||||
|
||||
def set_params_folders(tab: list):
|
||||
'''Initialize params["folders"] from CLI arguments.'''
|
||||
@ -69,6 +73,10 @@ DESCRIPTION
|
||||
run on locally installed modules
|
||||
{', '.join(options["no-old-file"])}
|
||||
do not create *.old files
|
||||
{', '.join(options["sort"])}
|
||||
sort output strings alphabetically
|
||||
{', '.join(options["break-long-lines"])}
|
||||
add extra line breaks before and after long strings
|
||||
{', '.join(options["verbose"])}
|
||||
add output information
|
||||
''')
|
||||
@ -221,6 +229,7 @@ def strings_to_text(dkeyStrings, dOld, mod_name, header_comments):
|
||||
|
||||
for key in dkeyStrings:
|
||||
sourceList = list(dkeyStrings[key])
|
||||
if params["sort"]:
|
||||
sourceList.sort()
|
||||
sourceString = "\n".join(sourceList)
|
||||
listForSource = dGroupedBySource.get(sourceString, [])
|
||||
@ -231,6 +240,7 @@ def strings_to_text(dkeyStrings, dOld, mod_name, header_comments):
|
||||
lSourceKeys.sort()
|
||||
for source in lSourceKeys:
|
||||
localizedStrings = dGroupedBySource[source]
|
||||
if params["sort"]:
|
||||
localizedStrings.sort()
|
||||
lOut.append("")
|
||||
lOut.append(source)
|
||||
@ -239,12 +249,12 @@ def strings_to_text(dkeyStrings, dOld, mod_name, header_comments):
|
||||
val = dOld.get(localizedString, {})
|
||||
translation = val.get("translation", "")
|
||||
comment = val.get("comment")
|
||||
if len(localizedString) > doublespace_threshold and not lOut[-1] == "":
|
||||
if params["break-long-lines"] and len(localizedString) > doublespace_threshold and not lOut[-1] == "":
|
||||
lOut.append("")
|
||||
if comment != None:
|
||||
lOut.append(comment)
|
||||
lOut.append(f"{localizedString}={translation}")
|
||||
if len(localizedString) > doublespace_threshold:
|
||||
if params["break-long-lines"] and len(localizedString) > doublespace_threshold:
|
||||
lOut.append("")
|
||||
|
||||
|
||||
@ -260,12 +270,12 @@ def strings_to_text(dkeyStrings, dOld, mod_name, header_comments):
|
||||
if not unusedExist:
|
||||
unusedExist = True
|
||||
lOut.append("\n\n##### not used anymore #####\n")
|
||||
if len(key) > doublespace_threshold and not lOut[-1] == "":
|
||||
if params["break-long-lines"] and len(key) > doublespace_threshold and not lOut[-1] == "":
|
||||
lOut.append("")
|
||||
if comment != None:
|
||||
lOut.append(comment)
|
||||
lOut.append(f"{key}={translation}")
|
||||
if len(key) > doublespace_threshold:
|
||||
if params["break-long-lines"] and len(key) > doublespace_threshold:
|
||||
lOut.append("")
|
||||
return "\n".join(lOut) + '\n'
|
||||
|
||||
@ -335,7 +345,7 @@ def import_tr_file(tr_file):
|
||||
if line[:3] == "###":
|
||||
if header_comment is None:
|
||||
# Save header comments
|
||||
header_comment = latest_comment_block or ""
|
||||
header_comment = latest_comment_block
|
||||
# Stip textdomain line
|
||||
tmp_h_c = ""
|
||||
for l in header_comment.split('\n'):
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -151,7 +151,7 @@ Damit das Wärmespeichersystem funktioniert, müssen alle Blöcke (auch Betonhü
|
||||
### TA4 Wärmetauscher / Heat Exchanger
|
||||
|
||||
Der Wärmetauscher besteht aus 3 Teilen, die aufeinander gesetzt werden müssen, wobei der Pfeil des ersten Blockes Richtung Turbine zeigen muss. Die Rohrleitungen müssen mit den gelben TA4 Röhren aufgebaut werden.
|
||||
Der Wärmetauscher muss am Stromnetz angeschlossen werden. Der Wärmetauscher kann 60 ku aufnehmen.
|
||||
Der Wärmetauscher muss am Stromnetz angeschlossen werden. Der Wärmetauscher lädt den Energiespeicher wieder auf, wenn ausreichend Strom zur Verfügung steht und der Energiespeicher weniger als 95 % geladen ist. Der Wärmetauscher nimmt dabei 60 ku auf.
|
||||
|
||||
[ta4_heatexchanger|image]
|
||||
|
||||
@ -666,7 +666,7 @@ Die Verarbeitungsleistung beträgt bis zu 8 mal vier Items alle 4 Sekunden.
|
||||
### TA4 Recycler
|
||||
|
||||
Der Recycler ist eine Maschine, die alle Techage Rezepte rückwärts abarbeitet, also Maschinen und Blöcke wieder in die Bestandteile zerlegen kann. Die Maschine kann so ziemlich alle Techage und Hyperloop Blöcke zerlegen.
|
||||
Aber nicht alle Materialen lassen sich recyclen:
|
||||
Aber nicht alle Zutaten/Materialien der Rezepte lassen sich recyclen:
|
||||
|
||||
- Holz wird zu Sticks
|
||||
- Stein wird zu Sand oder Kies
|
||||
@ -687,4 +687,4 @@ Ist die Verbindung aufgebaut (es muss dazu noch kein Strom fließen), wird dies
|
||||
|
||||
Die Laserblöcke selbst benötigen keinen Strom.
|
||||
|
||||
[ta4_laser|image]
|
||||
[ta4_laser|image]t
|
@ -151,7 +151,7 @@ In order for the heat storage system to work, all blocks (also the concrete shel
|
||||
### TA4 Heat Exchanger
|
||||
|
||||
The heat exchanger consists of 3 parts that must be placed on top of each other, with the arrow of the first block pointing towards the turbine. The pipes must be built with the yellow TA4 pipes.
|
||||
The heat exchanger must be connected to the power grid. The heat exchanger can consume 60 ku.
|
||||
The heat exchanger must be connected to the power grid. The heat exchanger charges the energy store again when sufficient electricity is available and the energy storage is less than 95% charged. The heat exchanger takes up 60 ku.
|
||||
|
||||
[ta4_heatexchanger|image]
|
||||
|
||||
@ -668,7 +668,7 @@ The processing power is up to 8 times four items every 4 seconds.
|
||||
|
||||
The recycler is a machine that processes all Techage recipes backwards, i.e. it can dismantle machines and blocks back into their components.
|
||||
|
||||
The machine can disassemble pretty much any Techage and Hyperloop blocks. But not all materials can be recycled:
|
||||
The machine can disassemble pretty much any Techage and Hyperloop blocks. But not all recipe items/materials can be recycled:
|
||||
|
||||
- Wood turns into sticks
|
||||
- Stone turns into sand or gravel
|
||||
|
@ -171,7 +171,7 @@ end
|
||||
local function marker(player_name, pos)
|
||||
local posC = {x = center(pos.x), y = pos.y, z = center(pos.z)}
|
||||
local pos1 = {x = posC.x - 2, y = posC.y - 2, z = posC.z - 2}
|
||||
local pos2 = {x = posC.x + 2, y = posC.y + 5, z = posC.z + 2}
|
||||
local pos2 = {x = posC.x + 2, y = posC.y + 7, z = posC.z + 2}
|
||||
techage.switch_region(player_name, pos1, pos2)
|
||||
end
|
||||
|
||||
|
@ -65,6 +65,7 @@ function techage.register_junction(name, size, boxes, tlib2, node, index)
|
||||
ndef.paramtype2 = "facedir"
|
||||
ndef.on_rotate = screwdriver.disallow
|
||||
ndef.paramtype = "light"
|
||||
ndef.use_texture_alpha = "clip"
|
||||
ndef.sunlight_propagates = true
|
||||
ndef.is_ground_content = false
|
||||
ndef.drop = name..(index or "0")
|
||||
|
@ -28,6 +28,16 @@ local STOPPED = techage.power.STOPPED
|
||||
local NOPOWER = techage.power.NOPOWER
|
||||
local RUNNING = techage.power.RUNNING
|
||||
|
||||
local HELP = [[Commands
|
||||
help print this text
|
||||
cls clear screen
|
||||
gen1 print all cat. 1 generators
|
||||
gen2 print all cat. 2 generators
|
||||
con2 print all cat. 2 consumers
|
||||
num print number of network blocks
|
||||
pow print provided and needed power]]
|
||||
|
||||
|
||||
local Generators = {
|
||||
S("Power station"),
|
||||
S("Tiny generator"),
|
||||
@ -65,10 +75,16 @@ local GeneratorPerformances = {
|
||||
local Gentypes = table.concat(Generators, ",")
|
||||
local Gentype2Idx = {}
|
||||
local Gentype2Maxvalue = {}
|
||||
local Gentype = {}
|
||||
|
||||
for idx,name in ipairs(Generators) do
|
||||
Gentype2Idx[name] = idx
|
||||
Gentype2Maxvalue[name] = GeneratorPerformances[idx]
|
||||
Gentype[GeneratorPerformances[idx]] = name
|
||||
end
|
||||
|
||||
local function short_node_name(nominal)
|
||||
return Gentype[nominal or 1] or "unknown"
|
||||
end
|
||||
|
||||
local function generator_data(gen_tbl, nominal)
|
||||
@ -94,6 +110,40 @@ local function generator_data(gen_tbl, nominal)
|
||||
return pow_max, pow_curr, num_nodes
|
||||
end
|
||||
|
||||
local function get_generator_data(gen)
|
||||
local nvm = techage.get_nvm(gen.pos)
|
||||
local pow_max = 0
|
||||
local pow_curr = 0
|
||||
if nvm.ele1 and nvm.ele1.gstate and nvm.ele1.galive and nvm.ele1.given then
|
||||
if nvm.ele1.gstate == RUNNING then
|
||||
if nvm.ele1.curr_power and nvm.ele1.curr_power > 0 then
|
||||
pow_max = nvm.ele1.curr_power
|
||||
else
|
||||
pow_max = gen.nominal
|
||||
end
|
||||
if nvm.ele1.galive > 0 and nvm.ele1.given > 0 then
|
||||
pow_curr = nvm.ele1.given
|
||||
end
|
||||
end
|
||||
end
|
||||
return pow_curr, pow_max
|
||||
end
|
||||
|
||||
local function get_consumer_data(gen)
|
||||
local nvm = techage.get_nvm(gen.pos)
|
||||
local pow_max = 0
|
||||
local pow_curr = 0
|
||||
if nvm.ele1 and nvm.ele1.cstate and nvm.ele1.calive and nvm.ele1.taken then
|
||||
if nvm.ele1.cstate == RUNNING then
|
||||
pow_max = gen.nominal
|
||||
if nvm.ele1.calive > 0 and nvm.ele1.taken > 0 then
|
||||
pow_curr = nvm.ele1.taken
|
||||
end
|
||||
end
|
||||
end
|
||||
return pow_curr, pow_max
|
||||
end
|
||||
|
||||
local function consumer_data(gen_tbl, nominal)
|
||||
local pow_max = 0
|
||||
local pow_curr = 0
|
||||
@ -125,7 +175,7 @@ local function storage_load(gen_tbl, nominal)
|
||||
if gen.nominal == nominal then
|
||||
local ndef = techage.NodeDef[techage.get_node_lvm(gen.pos).name]
|
||||
if ndef and ndef.on_recv_message then
|
||||
local resp = ndef.on_recv_message(gen.pos, "0", "load")
|
||||
local resp, _ = ndef.on_recv_message(gen.pos, "0", "load")
|
||||
if type(resp) == "number" then
|
||||
load_curr = load_curr + resp
|
||||
num = num + 1
|
||||
@ -231,7 +281,7 @@ local function formspec_type(pos, nvm)
|
||||
"button[0,2.4;5,1;set;"..S("Store").."]"
|
||||
end
|
||||
|
||||
local function formspec(pos, nvm)
|
||||
local function formspec1(pos, nvm)
|
||||
local gentype = nvm.gentype or S("Power station")
|
||||
local netw, gen1, gen2 = calc_network_data_type(pos, nvm, gentype)
|
||||
local _, sum1, sum2 = calc_network_data_total(pos, nvm)
|
||||
@ -239,47 +289,179 @@ local function formspec(pos, nvm)
|
||||
local star = netw.prop == 1 and "*" or ""
|
||||
local state = get_state(netw)
|
||||
|
||||
return "size[9,7]"..
|
||||
return "size[11,9]"..
|
||||
"tabheader[0,0;tab;status,console;1;;true]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"box[0,-0.1;8.8,0.5;#c6e8ff]"..
|
||||
"label[3.5,-0.1;"..minetest.colorize( "#000000", S("Network Data")).."]"..
|
||||
"label[8.5,-0.1;"..minetest.colorize( "#000000", star).."]"..
|
||||
"box[0,-0.1;10.8,0.5;#c6e8ff]"..
|
||||
"label[4.5,-0.1;"..minetest.colorize( "#000000", S("Network Data")).."]"..
|
||||
"label[10.5,-0.1;"..minetest.colorize( "#000000", star).."]"..
|
||||
|
||||
"style_type[button;bgcolor=#395c74]"..
|
||||
"button[0,0.7;3,1;config;"..S("Type").."]"..
|
||||
|
||||
"box[0,1.6;8.8,0.4;#c6e8ff]"..
|
||||
"box[0,2.15;8.8,0.4;#395c74]"..
|
||||
"box[0,2.65;8.8,0.4;#395c74]"..
|
||||
"box[0,3.15;8.8,0.4;#395c74]"..
|
||||
"box[0,3.65;8.8,0.4;#395c74]"..
|
||||
"box[0,1.6;10.8,0.4;#c6e8ff]"..
|
||||
"box[0,2.15;10.8,0.4;#395c74]"..
|
||||
"box[0,2.65;10.8,0.4;#395c74]"..
|
||||
"box[0,3.15;10.8,0.4;#395c74]"..
|
||||
"box[0,3.65;10.8,0.4;#395c74]"..
|
||||
"label[0.1,1.55;"..minetest.colorize( "#000000", gentype).."]"..
|
||||
"label[3.7,1.55;"..minetest.colorize( "#000000", S("Output")).."]"..
|
||||
"label[6.2,1.55;"..minetest.colorize( "#000000", S("Intake")).."]"..
|
||||
"label[5.7,1.55;"..minetest.colorize( "#000000", S("Output")).."]"..
|
||||
"label[8.2,1.55;"..minetest.colorize( "#000000", S("Intake")).."]"..
|
||||
"label[0.1,2.1;"..S("Number blocks:").."]"..
|
||||
"label[0.1,2.6;"..S("Maximum power:").."]"..
|
||||
"label[0.1,3.1;"..S("Current power:").."]"..
|
||||
"label[0.1,3.6;"..S("Energy stored:").."]"..
|
||||
column(3.7, 2.1, gen1)..
|
||||
column(6.2, 2.1, gen2)..
|
||||
column(5.7, 2.1, gen1)..
|
||||
column(8.2, 2.1, gen2)..
|
||||
|
||||
--"box[0,5.3;8.8,0.4;#c6e8ff]"..
|
||||
"box[0,4.5;8.8,0.4;#c6e8ff]"..
|
||||
"box[0,5.05;8.8,0.4;#395c74]"..
|
||||
"box[0,5.55;8.8,0.4;#395c74]"..
|
||||
"box[0,6.05;8.8,0.4;#395c74]"..
|
||||
"box[0,4.5;10.8,0.4;#c6e8ff]"..
|
||||
"box[0,5.05;10.8,0.4;#395c74]"..
|
||||
"box[0,5.55;10.8,0.4;#395c74]"..
|
||||
"box[0,6.05;10.8,0.4;#395c74]"..
|
||||
"label[0.1,4.45;"..minetest.colorize( "#000000", S("Power grid total")).."]"..
|
||||
"label[3.7,4.45;"..minetest.colorize( "#000000", S("Generators")).."]"..
|
||||
"label[6.2,4.45;"..minetest.colorize( "#000000", S("Storage systems")).."]"..
|
||||
"label[5.7,4.45;"..minetest.colorize( "#000000", S("Generators")).."]"..
|
||||
"label[8.2,4.45;"..minetest.colorize( "#000000", S("Storage systems")).."]"..
|
||||
"label[0.1,5.0;"..S("Number blocks:").."]"..
|
||||
"label[0.1,5.5;"..S("Maximum power:").."]"..
|
||||
"label[0.1,6.0;"..S("Current power:").."]"..
|
||||
column(3.7, 5.0, sum1)..
|
||||
column(6.2, 5.0, sum2)..
|
||||
"box[0,6.75;8.8,0.4;#000000]"..
|
||||
"label[0.1,6.7;"..state.."]"
|
||||
column(5.7, 5.0, sum1)..
|
||||
column(8.2, 5.0, sum2)..
|
||||
"box[0,7.75;10.8,0.4;#000000]"..
|
||||
"label[0.1,7.7;"..state.."]"
|
||||
end
|
||||
|
||||
local function formspec2(pos, mem)
|
||||
local meta = M(pos)
|
||||
local output = meta:get_string("output")
|
||||
local command = mem.cmnd or ""
|
||||
output = minetest.formspec_escape(output)
|
||||
output = output:gsub("\n", ",")
|
||||
|
||||
return "size[11,9]"..
|
||||
"tabheader[0,0;tab;status,console;2;;true]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"box[0,-0.1;10.8,0.5;#c6e8ff]"..
|
||||
"label[4.5,-0.1;"..minetest.colorize( "#000000", S("Network Data")).."]"..
|
||||
"style_type[table,field;font=mono]"..
|
||||
"table[0,0.5;10.8,7.8;output;"..output..";200]"..
|
||||
"field[0.4,8.7;8.6,1;cmnd;;"..command.."]" ..
|
||||
"field_close_on_enter[cmnd;false]"..
|
||||
"button[8.9,8.4;2,1;enter;"..S("Enter").."]"
|
||||
end
|
||||
|
||||
local function generators(pos, gen_tbl)
|
||||
local tbl = {}
|
||||
for _, item in ipairs(gen_tbl) do
|
||||
if item and item.pos then
|
||||
local node = techage.get_node_lvm(item.pos)
|
||||
local ndef = minetest.registered_nodes[node.name]
|
||||
local name = short_node_name(item.nominal)
|
||||
local spos = P2S(item.pos)
|
||||
local pow_curr, pow_max = get_generator_data(item, ndef)
|
||||
if Storage[name] then
|
||||
local load_percent = 0
|
||||
local tdef = techage.NodeDef[node.name]
|
||||
if tdef and tdef.on_recv_message then
|
||||
load_percent = tdef.on_recv_message(item.pos, "0", "load") or 0
|
||||
end
|
||||
local s = string.format("%-16s %s = %u/%u ku (%u %%)",
|
||||
spos, name, pow_curr, pow_max, load_percent)
|
||||
tbl[#tbl + 1] = s
|
||||
else
|
||||
local s = string.format("%-16s %s = %u/%u ku", spos, name, pow_curr, pow_max)
|
||||
tbl[#tbl + 1] = s
|
||||
end
|
||||
end
|
||||
end
|
||||
return table.concat(tbl, "\n")
|
||||
end
|
||||
|
||||
local function consumers(pos, gen_tbl)
|
||||
local tbl = {}
|
||||
for _, item in ipairs(gen_tbl) do
|
||||
if item and item.pos then
|
||||
local node = techage.get_node_lvm(item.pos)
|
||||
local ndef = minetest.registered_nodes[node.name]
|
||||
local name = short_node_name(item.nominal)
|
||||
local spos = P2S(item.pos)
|
||||
local pow_curr, pow_max = get_consumer_data(item, ndef)
|
||||
if Storage[name] then
|
||||
local load_percent = 0
|
||||
local tdef = techage.NodeDef[node.name]
|
||||
if tdef and tdef.on_recv_message then
|
||||
load_percent = tdef.on_recv_message(item.pos, "0", "load") or 0
|
||||
end
|
||||
local s = string.format("%-16s %s = %u/%u ku (%u %%)",
|
||||
spos, name, pow_curr, pow_max, load_percent)
|
||||
tbl[#tbl + 1] = s
|
||||
else
|
||||
local s = string.format("%-16s %s = %u/%u ku", spos, name, pow_curr, pow_max)
|
||||
tbl[#tbl + 1] = s
|
||||
end
|
||||
end
|
||||
end
|
||||
return table.concat(tbl, "\n")
|
||||
end
|
||||
|
||||
local function number_nodes(pos, netw)
|
||||
return
|
||||
"num. generators cat. 1: " .. #(netw.gen1 or {}) .. "\n" ..
|
||||
"num. generators cat. 2: " .. #(netw.gen2 or {}) .. "\n" ..
|
||||
"num. consumers cat. 1: " .. #(netw.con1 or {}) .. "\n" ..
|
||||
"num. consumers cat. 2: " .. #(netw.con2 or {})
|
||||
end
|
||||
|
||||
local function power_network(pos, netw)
|
||||
return
|
||||
"pow. generators cat. 1: " .. (netw.available1 or 0) .. " ku\n" ..
|
||||
"pow. generators cat. 2: " .. (netw.available2 or 0) .. " ku\n" ..
|
||||
"pow. consumers cat. 1: " .. (netw.needed1 or 0) .. " ku\n" ..
|
||||
"pow. consumers cat. 2: " .. (netw.needed2 or 0) .. " ku"
|
||||
end
|
||||
|
||||
|
||||
local function output(pos, command, text)
|
||||
local meta = M(pos)
|
||||
text = meta:get_string("output") .. "\n$ " .. command .. "\n" .. (text or "")
|
||||
text = text:sub(-2000,-1)
|
||||
meta:set_string("output", text)
|
||||
end
|
||||
|
||||
local function command(pos, nvm, command)
|
||||
local meta = M(pos)
|
||||
|
||||
if command then
|
||||
command = command:sub(1,80)
|
||||
command = string.trim(command)
|
||||
|
||||
if command == "cls" then
|
||||
meta:set_string("output", "")
|
||||
elseif command == "help" then
|
||||
output(pos, command, HELP)
|
||||
elseif command == "gen1" then
|
||||
local netw = techage.networks.has_network("ele1", nvm.ele1 and nvm.ele1.netID) or {}
|
||||
output(pos, command, generators(pos, netw.gen1 or {}))
|
||||
elseif command == "gen2" then
|
||||
local netw = techage.networks.has_network("ele1", nvm.ele1 and nvm.ele1.netID) or {}
|
||||
output(pos, command, generators(pos, netw.gen2 or {}))
|
||||
elseif command == "con2" then
|
||||
local netw = techage.networks.has_network("ele1", nvm.ele1 and nvm.ele1.netID) or {}
|
||||
output(pos, command, consumers(pos, netw.con2 or {}))
|
||||
elseif command == "num" then
|
||||
local netw = techage.networks.has_network("ele1", nvm.ele1 and nvm.ele1.netID) or {}
|
||||
output(pos, command, number_nodes(pos, netw))
|
||||
elseif command == "pow" then
|
||||
local netw = techage.networks.has_network("ele1", nvm.ele1 and nvm.ele1.netID) or {}
|
||||
output(pos, command, power_network(pos, netw))
|
||||
elseif command ~= "" then
|
||||
output(pos, command, "")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("techage:ta3_power_terminal", {
|
||||
@ -305,7 +487,7 @@ minetest.register_node("techage:ta3_power_terminal", {
|
||||
local nvm = techage.get_nvm(pos)
|
||||
M(pos):set_int("outdir", networks.side_to_outdir(pos, "B"))
|
||||
Cable:after_place_node(pos)
|
||||
M(pos):set_string("formspec", formspec(pos, nvm))
|
||||
M(pos):set_string("formspec", formspec1(pos, nvm))
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
Cable:after_dig_node(pos)
|
||||
@ -315,15 +497,13 @@ minetest.register_node("techage:ta3_power_terminal", {
|
||||
power.update_network(pos, outdir, tlib2)
|
||||
end,
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
techage.set_activeformspec(pos, clicker)
|
||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
M(pos):set_string("formspec", formspec(pos, nvm))
|
||||
local mem = techage.get_mem(pos)
|
||||
M(pos):set_string("formspec", formspec2(pos, mem))
|
||||
end,
|
||||
on_timer = function(pos, elapsed)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
if techage.is_activeformspec(pos) then
|
||||
M(pos):set_string("formspec", formspec(pos, nvm))
|
||||
M(pos):set_string("formspec", formspec1(pos, nvm))
|
||||
end
|
||||
return true
|
||||
end,
|
||||
@ -333,15 +513,29 @@ minetest.register_node("techage:ta3_power_terminal", {
|
||||
return
|
||||
end
|
||||
local nvm = techage.get_nvm(pos)
|
||||
local mem = techage.get_mem(pos)
|
||||
|
||||
if fields.config then
|
||||
if fields.key_enter_field or fields.enter then
|
||||
command(pos, nvm, fields.cmnd)
|
||||
mem.cmnd = ""
|
||||
M(pos):set_string("formspec", formspec2(pos, mem))
|
||||
mem.cmnd = fields.cmnd
|
||||
elseif fields.config then
|
||||
techage.reset_activeformspec(pos, player)
|
||||
M(pos):set_string("formspec", formspec_type(pos, nvm))
|
||||
elseif fields.set then
|
||||
nvm.gentype = fields.gentype
|
||||
nvm.gentype_idx = Gentype2Idx[fields.gentype] or 1
|
||||
techage.set_activeformspec(pos, player)
|
||||
M(pos):set_string("formspec", formspec(pos, nvm))
|
||||
M(pos):set_string("formspec", formspec1(pos, nvm))
|
||||
elseif fields.tab == "1" then
|
||||
M(pos):set_string("formspec", formspec1(pos, nvm))
|
||||
techage.set_activeformspec(pos, player)
|
||||
elseif fields.tab == "2" then
|
||||
M(pos):set_string("formspec", formspec2(pos, mem))
|
||||
techage.reset_activeformspec(pos, player)
|
||||
elseif fields.key_up and mem.cmnd then
|
||||
M(pos):set_string("formspec", formspec2(pos, mem))
|
||||
end
|
||||
end,
|
||||
|
||||
|
@ -187,6 +187,7 @@ minetest.register_node("techage:ta4_solar_inverter", {
|
||||
sides = {R = 1},
|
||||
ntype = "gen1",
|
||||
nominal = PWR_PERF,
|
||||
regenerative = true,
|
||||
},
|
||||
ele2 = {
|
||||
sides = {L = 1},
|
||||
|
@ -51,7 +51,7 @@ end
|
||||
local function add_rotor(pos, nvm, player_name)
|
||||
nvm.error = false
|
||||
|
||||
if not techage.valid_place_for_windturbine(pos, nil, 1) then
|
||||
if not techage.valid_place_for_windturbine(pos, player_name, 1) then
|
||||
nvm.error = true
|
||||
M(pos):set_string("infotext", S("TA4 Wind Turbine")..": "..S("Not suitable position!"))
|
||||
return
|
||||
@ -167,6 +167,7 @@ minetest.register_node("techage:ta4_wind_turbine", {
|
||||
sides = {D = 1},
|
||||
ntype = "gen1",
|
||||
nominal = PWR_PERF,
|
||||
regenerative = true,
|
||||
},
|
||||
},
|
||||
after_place_node = after_place_node,
|
||||
|
Loading…
Reference in New Issue
Block a user