diff --git a/icta_controller/battery.lua b/icta_controller/battery.lua
index 7d3f262..de7f328 100644
--- a/icta_controller/battery.lua
+++ b/icta_controller/battery.lua
@@ -24,8 +24,9 @@ end
local function on_timer(pos, elapsed)
local meta = minetest.get_meta(pos)
+ local number = meta:get_string("node_number")
local percent = calc_percent(meta:get_int("content"))
- meta:set_string("infotext", S("Battery").." ("..percent.."%)")
+ meta:set_string("infotext", S("Battery").." "..number..": "..percent.." %")
if percent == 0 then
local node = minetest.get_node(pos)
node.name = "techage:ta4_battery_empty"
@@ -75,10 +76,16 @@ minetest.register_node("techage:ta4_battery", {
end
end
M(pos):set_int("content", content)
+ local number = techage.add_node(pos, "techage:ta4_battery")
+ M(pos):set_string("node_number", number)
on_timer(pos, 1)
minetest.get_node_timer(pos):start(30)
end,
+ after_dig_node = function(pos, oldnode, oldmetadata, digger)
+ techage.remove_node(pos, oldnode, oldmetadata)
+ end,
+
on_timer = on_timer,
preserve_metadata = function(pos, oldnode, oldmetadata, drops)
@@ -154,9 +161,17 @@ else
})
end
-techage.register_node({"techage:ta4_battery"},
- {
- on_node_load = function(pos)
- minetest.get_node_timer(pos):start(30)
- end,
+techage.register_node({"techage:ta4_battery"}, {
+ on_node_load = function(pos)
+ minetest.get_node_timer(pos):start(30)
+ end,
+
+ on_recv_message = function(pos, src, topic, payload)
+ if topic == "load" then
+ local meta = minetest.get_meta(pos)
+ return calc_percent(meta:get_int("content"))
+ else
+ return "unsupported"
+ end
+ end,
})
diff --git a/manuals/ta4_lua_controller_EN.md b/manuals/ta4_lua_controller_EN.md
index aa97019..34f0f34 100644
--- a/manuals/ta4_lua_controller_EN.md
+++ b/manuals/ta4_lua_controller_EN.md
@@ -358,7 +358,7 @@ 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. Silo and tank return two values: The percentage value and the absolute value in units.
Example: percent, absolute = $read_data("223", "load") |
+| "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.
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 |
diff --git a/manuals/ta4_lua_controller_EN.pdf b/manuals/ta4_lua_controller_EN.pdf
index 39d8dce..7469d82 100644
Binary files a/manuals/ta4_lua_controller_EN.pdf and b/manuals/ta4_lua_controller_EN.pdf differ
diff --git a/tools/repairkit.lua b/tools/repairkit.lua
index 7b641b2..548e449 100644
--- a/tools/repairkit.lua
+++ b/tools/repairkit.lua
@@ -237,10 +237,10 @@ local function read_state(itemstack, user, pointed_thing)
fuel = dump(fuel)
minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": fuel = "..fuel.." ")
end
- local load = techage.send_single("0", number, "load", nil)
+ local load, abs = techage.send_single("0", number, "load", nil)
if load and load ~= "" and load ~= "unsupported" then
- load = dump(load)
- minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": load = "..load.." % ")
+ load, abs = dump(load), abs and dump(abs) or "--"
+ minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": load = "..load.." % / "..abs.." units ")
end
local delivered = techage.send_single("0", number, "delivered", nil)
if delivered and delivered ~= "" and delivered ~= "unsupported" then