Necessary adjustments for upcoming Touchscreen mod

* Make some LCD display related things globally accessible
* Deprecate `read_data` to avoid confusion (use `send_cmnd` instead)
* Allow arbitrary data for `send_msg` and `get_msg` (with optional parameter)
This commit is contained in:
Thomas--S 2020-11-05 20:04:21 +01:00
parent 976dd379ca
commit 7934a17ba5
8 changed files with 84 additions and 66 deletions

View File

@ -1160,7 +1160,7 @@ techage.manual_DE.aText = {
" - Hülle mit 7x7x7 Concrete Blocks\\, gefüllt mit 125 Gravel\\, Speicherkapazität: 2\\,5 Tage bei 60 ku\n"..
" - Hülle mit 9x9x9 Concrete Blocks\\, gefüllt mit 343 Gravel\\, Speicherkapazität: 6\\,5 Tage bei 60 ku\n"..
"\n"..
"In der Betonhülle darf ein Fenster aus einem Obsidian Glas Block sein. Dieses muss ziemlich in der Mitte der Wand platziert werden. Durch dieses Fenster sieht man\\, ob der Speicher mehr als 80 % geladen ist. Im Plan rechts sieht man den Aufbau aus TA4 Wärmetauscher bestehend aus 3 Blöcken\\, der TA4 Turbine und dem TA4 Generator. Beim Wärmetauscher ist auf die Ausrichtung achten (der Pfeil bei Block 1 muss zur Turbine zeigen).\n"..
"In der Betonhülle darf ein Fenster aus einem Obsidian Glas Block sein. Dieses muss ziemlich in der Mitte der Wand platziert werden. Durch dieses Fenster sieht man\\, ob der Speicher mehr als 80 % geladen ist. Im Plan rechts sieht man den Aufbau aus TA4 Wärmetauscher bestehend aus 3 Blöcken\\, der TA4 Turbine und dem TA4 Generator. Beim Wärmetauscher ist auf die Ausrichtung zu achten (der Pfeil bei Block 1 muss zur Turbine zeigen).\n"..
"\n"..
"Entgegen dem Plan rechts müssen die Anschlüsse am Speicherblock auf gleicher Ebene sein (horizontal angeordnet\\, also nicht unten und oben). Die Rohrzuläufe (TA4 Pipe Inlet) müssen genau in der Mitte der Wand sein und stehen sich damit gegenüber. Als Röhren kommen die gelbel TA4 Röhren zum Einsatz. Die TA3 Dampfrohre können hier nicht verwendet werden.\n"..
"Sowohl der Generator als auch der Wärmetauscher haben einen Stromanschluss und müssen mit dem Stromnetz verbunden werden.\n"..
@ -1349,9 +1349,9 @@ techage.manual_DE.aText = {
"Wird etwas in die Kiste gelegt\\, oder entnommen\\, oder eine der Tasten \"F1\"/\"F2\" gedrückt\\, so wird ein Event-Signal an den Lua Controller gesendet.\n"..
"Die Sensor Kiste unterstützt folgende Kommandos:\n"..
"\n"..
" - Über 'state = $read_data(<num>\\, \"state\")' kann der Status der Kiste abgefragt werden. Mögliche Antworten sind: \"empty\"\\, \"loaded\"\\, \"full\"\n"..
" - Über 'name\\, action = $read_data(<num>\\, \"action\")' kann die letzte Spieleraktion abgefragt werden. 'name' ist der Spielername\\, Als 'action' wird zurückgeliefert: \"put\"\\, \"take\"\\, \"f1\"\\, \"f2\".\n"..
" - Über 'stacks = $read_data(<num>\\, \"stacks\")' kann der Inhalt der Kiste ausgelesen werden. Siehe dazu: https://github.com/joe7575/techage/blob/master/manuals/ta4_lua_controller_EN.md#sensor-chest\n"..
" - Über 'state = $send_cmnd(<num>\\, \"state\")' kann der Status der Kiste abgefragt werden. Mögliche Antworten sind: \"empty\"\\, \"loaded\"\\, \"full\"\n"..
" - Über 'name\\, action = $send_cmnd(<num>\\, \"action\")' kann die letzte Spieleraktion abgefragt werden. 'name' ist der Spielername\\, Als 'action' wird zurückgeliefert: \"put\"\\, \"take\"\\, \"f1\"\\, \"f2\".\n"..
" - Über 'stacks = $send_cmnd(<num>\\, \"stacks\")' kann der Inhalt der Kiste ausgelesen werden. Siehe dazu: https://github.com/joe7575/techage/blob/master/manuals/ta4_lua_controller_EN.md#sensor-chest\n"..
" - Über '$send_cmnd(<num>\\, \"text\"\\, \"press both buttons andnput something into the chest\")' kann der Text im Menü der Sensor Kiste gesetzt werden.\n"..
"\n"..
"Über die Checkbox \"Erlaube öffentlichen Zugriff\" kann eingestellt werden\\, ob die Kiste von jedem genutzt werden darf\\, oder nur von Spielern die hier Zugriffsrechte haben.\n"..
@ -1497,7 +1497,7 @@ techage.manual_DE.aText = {
"\n"..
"Der Kiste besitzt ein zusätzliches Kommandos für den Lua Controller:\n"..
"\n"..
" - 'count' dient zur Anfrage\\, wie viele Items in der Kiste sind.\nBeispiel 1: '$read_data(CHEST\\, \"count\")' --> Summe der Items über alle 8 Speicher\nBeispiel 2: '$read_data(CHEST\\, \"count\"\\, 2)' --> Anzahl der Items in Speicher 2 (zweiter von links)\n"..
" - 'count' dient zur Anfrage\\, wie viele Items in der Kiste sind.\nBeispiel 1: '$send_cmnd(CHEST\\, \"count\")' --> Summe der Items über alle 8 Speicher\nBeispiel 2: '$send_cmnd(CHEST\\, \"count\"\\, 2)' --> Anzahl der Items in Speicher 2 (zweiter von links)\n"..
"\n"..
"\n"..
"\n",

View File

@ -1340,9 +1340,9 @@ techage.manual_EN.aText = {
"If something is put into the box or removed\\, or one of the \"F1\" / \"F2\" keys is pressed\\, an event signal is sent to the Lua controller.\n"..
"The sensor box supports the following commands:\n"..
"\n"..
" - The status of the box can be queried via 'state = $read_data(<num>\\, \"state\")'. Possible answers are: \"empty\"\\, \"loaded\"\\, \"full\"\n"..
" - The last player action can be queried via 'name\\, action = $read_data(<num>\\, \"action\")'. 'name' is the player name. One of the following is returned as 'action': \"put\"\\, \"take\"\\, \"f1\"\\, \"f2\".\n"..
" - The contents of the box can be read out via 'stacks = $read_data(<num>\\, \"stacks\")'. See: https://github.com/joe7575/techage/blob/master/manuals/ta4_lua_controller_EN.md#sensor-chest\n"..
" - The status of the box can be queried via 'state = $send_cmnd(<num>\\, \"state\")'. Possible answers are: \"empty\"\\, \"loaded\"\\, \"full\"\n"..
" - The last player action can be queried via 'name\\, action = $send_cmnd(<num>\\, \"action\")'. 'name' is the player name. One of the following is returned as 'action': \"put\"\\, \"take\"\\, \"f1\"\\, \"f2\".\n"..
" - The contents of the box can be read out via 'stacks = $send_cmnd(<num>\\, \"stacks\")'. See: https://github.com/joe7575/techage/blob/master/manuals/ta4_lua_controller_EN.md#sensor-chest\n"..
" - Via '$send_cmnd(<num>\\, \"text\"\\, \"press both buttons andnput something into the chest\")' the text can be set in the menu of the sensor box.\n"..
"\n"..
"The checkbox \"Allow public chest access\" can be used to set whether the box can be used by everyone or only by players who have access/protection rights here.\n"..
@ -1488,7 +1488,7 @@ techage.manual_EN.aText = {
"\n"..
"The chest has an additional command for the Lua controller:\n"..
"\n"..
" - 'count' is used to request how many items are in the chest.\nExample 1: '$read_data(CHEST\\, \"count\")' -> Sum of items across all 8 stores\nExample 2: '$read_data(CHEST\\, \"count\"\\, 2)' -> number of items in store 2 (second from left)\n"..
" - 'count' is used to request how many items are in the chest.\nExample 1: '$send_cmnd(CHEST\\, \"count\")' -> Sum of items across all 8 stores\nExample 2: '$send_cmnd(CHEST\\, \"count\"\\, 2)' -> number of items in store 2 (second from left)\n"..
"\n"..
"\n"..
"\n",

View File

@ -14,6 +14,8 @@
local S = techage.S
techage.display = {}
local NUM_ROWS = 5
local RADIUS = 6
local Param2ToFacedir = {[0] = 0, 0, 3, 1, 2, 0}
@ -33,7 +35,7 @@ local function lcdlib_bugfix(text_tbl)
return ""
end
local function display_update(pos, objref)
function techage.display.display_update(pos, objref)
pos = vector.round(pos)
local nvm = techage.get_nvm(pos)
local text = lcdlib_bugfix(nvm.text)
@ -44,7 +46,7 @@ local function display_update(pos, objref)
visual_size = {x=0.94, y=0.94} })
end
local function display_updateXL(pos, objref)
function techage.display.display_updateXL(pos, objref)
pos = vector.round(pos)
local nvm = techage.get_nvm(pos)
local text = lcdlib_bugfix(nvm.text)
@ -55,7 +57,7 @@ local function display_updateXL(pos, objref)
visual_size = {x=0.94*1.9, y=0.94} })
end
local function on_timer(pos)
function techage.display.on_timer(pos)
local mem = techage.get_mem(pos)
mem.ticks = mem.ticks or 0
@ -77,7 +79,7 @@ local function on_timer(pos)
return true
end
local lcd_box = {
techage.display.lcd_box = {
type = "wallmounted",
wall_top = {-8/16, 15/32, -8/16, 8/16, 8/16, 8/16}
}
@ -90,13 +92,13 @@ minetest.register_node("techage:ta4_display", {
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "wallmounted",
node_box = lcd_box,
selection_box = lcd_box,
node_box = techage.display.lcd_box,
selection_box = techage.display.lcd_box,
light_source = 6,
display_entities = {
["techage:display_entity"] = { depth = 0.42,
on_display_update = display_update},
on_display_update = techage.display.display_update},
},
after_place_node = function(pos, placer)
@ -114,7 +116,7 @@ minetest.register_node("techage:ta4_display", {
techage.remove_node(pos, oldnode, oldmetadata)
end,
on_timer = on_timer,
on_timer = techage.display.on_timer,
on_place = lcdlib.on_place,
on_construct = lcdlib.on_construct,
on_destruct = lcdlib.on_destruct,
@ -124,7 +126,7 @@ minetest.register_node("techage:ta4_display", {
sounds = default.node_sound_glass_defaults(),
})
local lcd_boxXL = {
techage.display.lcd_boxXL = {
type = "fixed",
fixed = {-0.9, -8/16, -8/16, 0.9, -15/32, 8/16}
}
@ -137,13 +139,13 @@ minetest.register_node("techage:ta4_displayXL", {
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "wallmounted",
node_box = lcd_boxXL,
selection_box = lcd_boxXL,
node_box = techage.display.lcd_boxXL,
selection_box = techage.display.lcd_boxXL,
light_source = 6,
display_entities = {
["techage:display_entityXL"] = { depth = 0.42,
on_display_update = display_updateXL},
on_display_update = techage.display.display_updateXL},
},
after_place_node = function(pos, placer)
@ -161,7 +163,7 @@ minetest.register_node("techage:ta4_displayXL", {
techage.remove_node(pos, oldnode, oldmetadata)
end,
on_timer = on_timer,
on_timer = techage.display.on_timer,
on_place = lcdlib.on_place,
on_construct = lcdlib.on_construct,
on_destruct = lcdlib.on_destruct,
@ -189,7 +191,7 @@ minetest.register_craft({
},
})
local function add_line(pos, payload, cycle_time)
function techage.display.add_line(pos, payload, cycle_time)
local nvm = techage.get_nvm(pos)
local mem = techage.get_mem(pos)
nvm.text = nvm.text or {}
@ -206,7 +208,7 @@ local function add_line(pos, payload, cycle_time)
table.insert(nvm.text, payload)
end
local function write_row(pos, payload, cycle_time)
function techage.display.write_row(pos, payload, cycle_time)
local nvm = techage.get_nvm(pos)
local mem = techage.get_mem(pos)
nvm.text = nvm.text or {}
@ -227,7 +229,7 @@ local function write_row(pos, payload, cycle_time)
nvm.text[row] = str
end
local function clear_screen(pos, cycle_time)
function techage.display.clear_screen(pos, cycle_time)
local nvm = techage.get_nvm(pos)
local mem = techage.get_mem(pos)
mem.ticks = mem.ticks or 0
@ -242,11 +244,11 @@ end
techage.register_node({"techage:ta4_display"}, {
on_recv_message = function(pos, src, topic, payload)
if topic == "add" then -- add one line and scroll if necessary
add_line(pos, payload, 1)
techage.display.add_line(pos, payload, 1)
elseif topic == "set" then -- overwrite the given row
write_row(pos, payload, 1)
techage.display.write_row(pos, payload, 1)
elseif topic == "clear" then -- clear the screen
clear_screen(pos, 1)
techage.display.clear_screen(pos, 1)
end
end,
})
@ -254,11 +256,11 @@ techage.register_node({"techage:ta4_display"}, {
techage.register_node({"techage:ta4_displayXL"}, {
on_recv_message = function(pos, src, topic, payload)
if topic == "add" then -- add one line and scroll if necessary
add_line(pos, payload, 2)
techage.display.add_line(pos, payload, 2)
elseif topic == "set" then -- overwrite the given row
write_row(pos, payload, 2)
techage.display.write_row(pos, payload, 2)
elseif topic == "clear" then -- clear the screen
clear_screen(pos, 2)
techage.display.clear_screen(pos, 2)
end
end,
})

View File

@ -631,7 +631,7 @@ techage.register_node({"techage:ta4_lua_controller"}, {
elseif topic == "term" then
set_input(pos, number, "term", payload)
elseif topic == "msg" then
set_input(pos, number, "msg", payload)
set_input(pos, number, "msg", {src = src, data = payload})
elseif topic == "state" then
local running = meta:get_int("running") or STATE_STOPPED
return techage.StateStrings[running] or "stopped"

View File

@ -108,7 +108,7 @@ local function command(pos, cmnd, player)
if techage.lua_ctlr.not_protected(owner, num) then
--output(pos, player..":$ msg "..num.." "..text)
output(pos, "> msg "..num.." "..text)
techage.send_single(own_number, num, "msg", {src=own_number, text=text})
techage.send_single(own_number, num, "msg", text)
return
end
end
@ -230,26 +230,31 @@ techage.lua_ctlr.register_action("put_term", {
})
techage.lua_ctlr.register_function("get_msg", {
cmnd = function(self)
cmnd = function(self, raw)
local msg = techage.lua_ctlr.get_msg(self.meta.number)
if msg then
return msg.src, msg.text
local data = msg.data
if not raw then
data = tostring(data or "")
end
return msg.src, data
end
end,
help = ' $get_msg() --> number and text string or nil\n'..
help = ' $get_msg([raw]) --> any value or nil\n'..
' If the optional `raw` parameter is not set or false,\n'..
' the return value is guaranteed to be a string.\n'..
' Read a received messages. Number is the node\n'..
' number of the sender.\n'..
' example: num,msg = $get_msg().'
})
techage.lua_ctlr.register_action("send_msg", {
cmnd = function(self, num, text)
local msg = {src = self.meta.number, text = tostring(text or "")}
cmnd = function(self, num, data)
if techage.lua_ctlr.not_protected(self.meta.owner, num) then
techage.send_single(self.meta.number, num, "msg", msg)
techage.send_single(self.meta.number, num, "msg", data)
end
end,
help = " $send_msg(num, text)\n"..
help = " $send_msg(num, data)\n"..
' Send a message to the controller with number "num".\n'..
' example: $send_msg("0123", "test")'
})

View File

@ -390,9 +390,9 @@ Die TA4 Sensor Kiste dient zum Aufbau von Automatischen Lagern oder Verkaufsauto
Wird etwas in die Kiste gelegt, oder entnommen, oder eine der Tasten "F1"/"F2" gedrückt, so wird ein Event-Signal an den Lua Controller gesendet.
Die Sensor Kiste unterstützt folgende Kommandos:
- Über `state = $read_data(<num>, "state")` kann der Status der Kiste abgefragt werden. Mögliche Antworten sind: "empty", "loaded", "full"
- Über `name, action = $read_data(<num>, "action")` kann die letzte Spieleraktion abgefragt werden. `name` ist der Spielername, Als `action` wird zurückgeliefert: "put", "take", "f1", "f2".
- Über `stacks = $read_data(<num>, "stacks")` kann der Inhalt der Kiste ausgelesen werden. Siehe dazu: https://github.com/joe7575/techage/blob/master/manuals/ta4_lua_controller_EN.md#sensor-chest
- Über `state = $send_cmnd(<num>, "state")` kann der Status der Kiste abgefragt werden. Mögliche Antworten sind: "empty", "loaded", "full"
- Über `name, action = $send_cmnd(<num>, "action")` kann die letzte Spieleraktion abgefragt werden. `name` ist der Spielername, Als `action` wird zurückgeliefert: "put", "take", "f1", "f2".
- Über `stacks = $send_cmnd(<num>, "stacks")` kann der Inhalt der Kiste ausgelesen werden. Siehe dazu: https://github.com/joe7575/techage/blob/master/manuals/ta4_lua_controller_EN.md#sensor-chest
- Über `$send_cmnd(<num>, "text", "press both buttons and\nput something into the chest")` kann der Text im Menü der Sensor Kiste gesetzt werden.
Über die Checkbox "Erlaube öffentlichen Zugriff" kann eingestellt werden, ob die Kiste von jedem genutzt werden darf, oder nur von Spielern die hier Zugriffsrechte haben.
@ -596,8 +596,8 @@ Die Kiste kann nur von den Spielern genutzt werden, die an diesem Ort auch bauen
Der Kiste besitzt ein zusätzliches Kommandos für den Lua Controller:
- `count` dient zur Anfrage, wie viele Items in der Kiste sind.
Beispiel 1: `$read_data(CHEST, "count")` --> Summe der Items über alle 8 Speicher
Beispiel 2: `$read_data(CHEST, "count", 2)` --> Anzahl der Items in Speicher 2 (zweiter von links)
Beispiel 1: `$send_cmnd(CHEST, "count")` --> Summe der Items über alle 8 Speicher
Beispiel 2: `$send_cmnd(CHEST, "count", 2)` --> Anzahl der Items in Speicher 2 (zweiter von links)
[ta4_8x2000_chest|image]

View File

@ -392,9 +392,9 @@ The TA4 sensor box is used to set up automatic warehouses or vending machines in
If something is put into the box or removed, or one of the "F1" / "F2" keys is pressed, an event signal is sent to the Lua controller.
The sensor box supports the following commands:
- The status of the box can be queried via `state = $read_data(<num>, "state")`. Possible answers are: "empty", "loaded", "full"
- The last player action can be queried via `name, action = $read_data(<num>, "action")`. `name` is the player name. One of the following is returned as `action`: "put", "take", "f1", "f2".
- The contents of the box can be read out via `stacks = $read_data(<num>, "stacks")`. See: https://github.com/joe7575/techage/blob/master/manuals/ta4_lua_controller_EN.md#sensor-chest
- The status of the box can be queried via `state = $send_cmnd(<num>, "state")`. Possible answers are: "empty", "loaded", "full"
- The last player action can be queried via `name, action = $send_cmnd(<num>, "action")`. `name` is the player name. One of the following is returned as `action`: "put", "take", "f1", "f2".
- The contents of the box can be read out via `stacks = $send_cmnd(<num>, "stacks")`. See: https://github.com/joe7575/techage/blob/master/manuals/ta4_lua_controller_EN.md#sensor-chest
- Via `$send_cmnd(<num>, "text", "press both buttons and\nput something into the chest")` the text can be set in the menu of the sensor box.
The checkbox "Allow public chest access" can be used to set whether the box can be used by everyone or only by players who have access/protection rights here.
@ -597,8 +597,8 @@ The chest can only be used by players who can build at this location, i.e. who h
The chest has an additional command for the Lua controller:
- `count` is used to request how many items are in the chest.
Example 1: `$read_data(CHEST, "count")` -> Sum of items across all 8 stores
Example 2: `$read_data(CHEST, "count", 2)` -> number of items in store 2 (second from left)
Example 1: `$send_cmnd(CHEST, "count")` -> Sum of items across all 8 stores
Example 2: `$send_cmnd(CHEST, "count", 2)` -> number of items in store 2 (second from left)
[ta4_8x2000_chest|image]

View File

@ -346,7 +346,11 @@ In addition to Lua standard function the Lua Controller provides the following f
### Techage Command Functions
* `$read_data(num, ident, add_data)` - Read any kind of data from another block with the given number _num_.
With the `$send_cmnd(num, ident, add_data)` function, you can send commands to and retrieve data from another block with the given number _num_.
The possible commands can be classified in two groups: Commands for reading data and commands for causing an action.
Please note, that this is not a technical distinction, only a logical.
* Reading data
_ident_ specifies the data to be read.
_add_data_ is for additional data and normally not needed.
The result is block dependent (see table below):
@ -358,18 +362,21 @@ 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, 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 = $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.<br /> Example: percent, absolute = $send_cmnd("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 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) |
| "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 = $send_cmnd("223", "itemstring", 1) |
* `$send_cmnd(num, cmnd, data)` - Send a command to another block. _num_ is the number of the remote block, like "1234". _cmnd_ is the command, _data_ is additional data (see table below):
* Causing an action
_num_ is the number of the remote block, like "1234".
_cmnd_ is the command,
_data_ is additional data (see table below):
| cmnd | data | comment |
| -------------------------------- | ------------ | ------------------------------------------------------------ |
@ -406,10 +413,14 @@ In contrast the Controller can send text strings to the terminal.
### Further Functions
Messages are used to transport data between Controllers. Messages are text strings or any other data. Incoming messages are stored in order (up to 10) and can be read one after the other.
Messages are used to transport data between Controllers. Messages are always converted to text strings. Incoming messages are stored in order (up to 10) and can be read one after the other.
* `$get_msg()` - Read a received message. The function returns the sender number and the message. (see example "Emails")
* `$send_msg(num, msg)` - Send a message to another Controller. _num_ is the destination number. (see example "Emails")
Similiar to the concept above you can also exchange arbitrary data. Please note that external devices might also send such data.
* `$get_data()` - Read received data. The function returns the sender number and the data.
* `$send_data(num, data)` - Send data to another Controller. _num_ is the destination number.
* `$chat(text)` - Send yourself a chat message. _text_ is a text string.
@ -419,7 +430,7 @@ Messages are used to transport data between Controllers. Messages are text strin
* `$item_description("default:apple")`
Get the description (item name) for a specified itemstring, e. g. determined via the TA4 8x2000 Chest command `itemstring`:
`str = $read_data("223", "itemstring", 1)`
`str = $send_cmnd("223", "itemstring", 1)`
`descr = $item_description(str)`
@ -504,15 +515,15 @@ if ticks % 60 == 0 then
$display(DISPLAY, 1, min.." min")
-- Cactus chest overrun
sts = $read_data("1034", "state") -- read pusher status
sts = $send_cmnd("1034", "state") -- read pusher status
if sts == "blocked" then $display(DISPLAY, 2, "Cactus full") end
-- Tree chest overrun
sts = $read_data("1065", "state") -- read pusher status
sts = $send_cmnd("1065", "state") -- read pusher status
if sts == "blocked" then $display(DISPLAY, 3, "Tree full") end
-- Furnace fuel empty
sts = $read_data("1544", "state") -- read pusher status
sts = $send_cmnd("1544", "state") -- read pusher status
if sts == "standby" then $display(DISPLAY, 4, "Furnace fuel") end
end
```
@ -570,7 +581,7 @@ loop() code:
```lua
if event then
name = $read_data(SENSOR, "name")
name = $send_cmnd(SENSOR, "name")
if name == "" then -- no player arround
$clear_screen(DISPLAY)
else
@ -602,13 +613,13 @@ loop() code:
```lua
if event and $get_input(SENSOR) == "on" then
-- read inventory state
state = $read_data(SENSOR, "state")
state = $send_cmnd(SENSOR, "state")
$print("state: "..state)
-- read player name and action
name, action = $read_data(SENSOR, "action")
name, action = $send_cmnd(SENSOR, "action")
$print("action"..": "..name.." "..action)
-- read inventory content
stacks = $read_data(SENSOR, "stacks")
stacks = $send_cmnd(SENSOR, "stacks")
for i,stack in stacks.next() do
$print("stack: "..stack.get("name").." "..stack.get("count"))
end