Add command 'load' to the TA4 power terminal
This commit is contained in:
parent
a53ab04ca2
commit
2826423e5b
@ -84,7 +84,8 @@ techage.liquid.recv_message = {
|
||||
nvm.liquid = nvm.liquid or {}
|
||||
nvm.liquid.amount = nvm.liquid.amount or 0
|
||||
if payload[1] == 1 then
|
||||
return 0, {techage.power.percent(LQD(pos).capa, nvm.liquid.amount)}
|
||||
local value = techage.power.percent(LQD(pos).capa, nvm.liquid.amount)
|
||||
return 0, {math.floor(value + 0.5)}
|
||||
else
|
||||
return 0, {nvm.liquid.amount}
|
||||
end
|
||||
|
@ -382,7 +382,8 @@ techage.register_node({"techage:heatexchanger2"}, {
|
||||
local data = power.get_network_data(pos, Cable, DOWN)
|
||||
return 0, {data.consumed - data.provided}
|
||||
elseif topic == 134 then -- Tank Load Percent
|
||||
return 0, {techage.power.percent(nvm.capa_max, nvm.capa)}
|
||||
local value = techage.power.percent(nvm.capa_max, nvm.capa)
|
||||
return 0, {math.floor(value + 0.5)}
|
||||
else
|
||||
return 2, ""
|
||||
end
|
||||
|
4
init.lua
4
init.lua
@ -36,8 +36,8 @@ elseif minetest.global_exists("lcdlib") and lcdlib.version < 1.01 then
|
||||
elseif minetest.global_exists("safer_lua") and safer_lua.version < 1.01 then
|
||||
minetest.log("error", "[techage] Techage requires safer_lua version 1.01 or newer!")
|
||||
return
|
||||
elseif minetest.global_exists("networks") and networks.version < 0.12 then
|
||||
minetest.log("error", "[techage] Techage requires networks version 0.12 or newer!")
|
||||
elseif minetest.global_exists("networks") and networks.version < 0.13 then
|
||||
minetest.log("error", "[techage] Techage requires networks version 0.13 or newer!")
|
||||
return
|
||||
elseif minetest.global_exists("hyperloop") and hyperloop.version < 2.07 then
|
||||
minetest.log("error", "[techage] Techage requires hyperloop version 2.07 or newer!")
|
||||
|
@ -366,7 +366,9 @@ Please note, that this is not a technical distinction, only a logical.
|
||||
| "state" | one of: "on", "off" | State of a TA4 Button |
|
||||
| "fuel" | number | fuel value of a fuel consuming block |
|
||||
| "depth" | number | Read the current depth value of a quarry block (1..80) |
|
||||
| "load" | number | Read the load value in percent (0..100) of a tank, silo, accu, or battery block, or from the Signs Bot Box. Silo and tank return two values: The percentage value and the absolute value in units.<br /> Example: percent, absolute = $send_cmnd("223", "load") |
|
||||
| "load" | number | Read the load value in percent (0..100) of a accu, or battery block. |
|
||||
| "load" | number | Read the load value in percent (0..100) of a tank or silo. <br />Silo and tank return two values: <br />The percentage value and the absolute value in units.<br /> Example: percent, absolute = $send_cmnd("223", "load") |
|
||||
| "load" | number | Read the grid storage amount in percent (0..100) from a TA3 Power Terminal. |
|
||||
| "delivered" | number | Read the current delivered power value of a generator block. A power consuming block (accu) provides a negative value |
|
||||
| "flowrate" | Total flow rate in liquid units | Only for TA4 Pumps |
|
||||
| "action" | player-name, action-string | Only for Sensor Chests |
|
||||
|
@ -238,13 +238,18 @@ minetest.register_node("techage:ta3_power_terminal", {
|
||||
},
|
||||
},
|
||||
|
||||
after_place_node = function(pos)
|
||||
after_place_node = function(pos, placer)
|
||||
M(pos):set_int("outdir", networks.side_to_outdir(pos, "B"))
|
||||
Cable:after_place_node(pos)
|
||||
M(pos):set_string("formspec", formspec1(pos))
|
||||
local number = techage.add_node(pos, "techage:ta3_power_terminal")
|
||||
M(pos):set_string("node_number", number)
|
||||
M(pos):set_string("owner", placer:get_player_name())
|
||||
M(pos):set_string("infotext", S("TA3 Power Terminal").." "..number)
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
Cable:after_dig_node(pos)
|
||||
techage.remove_node(pos, oldnode, oldmetadata)
|
||||
techage.del_mem(pos)
|
||||
end,
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
@ -305,6 +310,28 @@ minetest.register_node("techage:ta3_power_terminal", {
|
||||
|
||||
power.register_nodes({"techage:ta3_power_terminal"}, Cable, "con", {"B"})
|
||||
|
||||
techage.register_node({"techage:ta3_power_terminal"}, {
|
||||
on_recv_message = function(pos, src, topic, payload)
|
||||
if topic == "load" then
|
||||
local outdir = M(pos):get_int("outdir")
|
||||
local value = networks.power.get_storage_percent(pos, Cable, outdir)
|
||||
return techage.round(value)
|
||||
else
|
||||
return "unsupported"
|
||||
end
|
||||
end,
|
||||
on_beduino_request_data = function(pos, src, topic, payload)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
if topic == 134 then
|
||||
local outdir = M(pos):get_int("outdir")
|
||||
local value = networks.power.get_storage_percent(pos, Cable, outdir)
|
||||
return 0, {math.floor(value + 0.5)}
|
||||
else
|
||||
return 2, ""
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "techage:ta3_power_terminal",
|
||||
recipe = {
|
||||
|
Loading…
Reference in New Issue
Block a user