silo/tank: Add second return value for load command

This commit is contained in:
Joachim Stolberg 2020-10-07 22:06:43 +02:00
parent a2405122fc
commit eb1ed8890c
4 changed files with 6 additions and 4 deletions

View File

@ -55,7 +55,9 @@ techage.liquid.recv_message = {
on_recv_message = function(pos, src, topic, payload)
if topic == "load" then
local nvm = techage.get_nvm(pos)
return techage.power.percent(LQD(pos).capa, (nvm.liquid and nvm.liquid.amount) or 0)
nvm.liquid = nvm.liquid or {}
nvm.liquid.amount = nvm.liquid.amount or 0
return techage.power.percent(LQD(pos).capa, nvm.liquid.amount), nvm.liquid.amount
elseif topic == "size" then
return LQD(pos).capa
else

View File

@ -309,7 +309,7 @@ techage.register_node({"techage:ta3_silo", "techage:ta4_silo"}, {
local nvm = techage.get_nvm(pos)
nvm.item_count = nvm.item_count or get_item_count(pos)
nvm.capa = nvm.capa or get_silo_capa(pos)
return techage.power.percent(nvm.capa, nvm.item_count)
return techage.power.percent(nvm.capa, nvm.item_count), nvm.item_count
else
return "unsupported"
end

View File

@ -358,12 +358,12 @@ In addition to Lua standard function the Lua Controller provides the following f
| "state" | one of: "empty", "loaded", "full" | State of a chest or Sensor Chest |
| "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/storage block, a silo block, an accu block, or of the Signs Bot Box. |
| "load" | number | Read the load value in percent (0..100) of a tank/storage block, a silo block, an accu block, or of the Signs Bot Box. Silo and tank return two values: The percentage value and the absolute value in units.<br /> Example: percent, absolute = $read_data("223", "load") |
| "delivered" | number | Read the current delivered power value of a generator block. A power consuming block (accu) provides a negative value |
| "action" | player-name, action-string | only for Sensor Chests |
| "stacks" | Array with up to 4 Stores with the inventory content (see example) | only for Sensor Chests |
| "count" | number | Read the item counter of the TA4 Item Detector block |
| "count" | number of items | Read the total amount of TA4 chest items. An optional number as `add_data` is used to address only on inventory slot (1..8, from left to right). |
| "count" | number of items | Read the total amount of TA4 chest items. An optional number as `add_data` is used to address only one inventory slot (1..8, from left to right). |
| "itemstring" | item string of the given slot | Specific command for the TA4 8x2000 Chest to read the item type (technical name) of one chest slot, specified via `add_data` (1..8).<br />Example: s = $read_data("223", "itemstring", 1) |

Binary file not shown.