From acb54d7e8d06b4e7fa29baddae9e583f8a306b39 Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Tue, 7 Jun 2022 22:32:03 +0200 Subject: [PATCH] Improve TA3 doorcontroller2 --- doc/manual_DE.lua | 8 ++++++-- doc/manual_EN.lua | 8 ++++++-- items/registered_nodes.lua | 3 +++ manuals/manual_ta3_DE.md | 10 ++++++---- manuals/manual_ta3_EN.md | 10 ++++++---- manuals/ta4_lua_controller_EN.md | 4 +++- move_controller/doorcontroller2.lua | 27 ++++++++++++++++++++++----- 7 files changed, 52 insertions(+), 18 deletions(-) diff --git a/doc/manual_DE.lua b/doc/manual_DE.lua index 4fe7eb2..48336a5 100644 --- a/doc/manual_DE.lua +++ b/doc/manual_DE.lua @@ -1146,9 +1146,13 @@ techage.manual_DE.aText = { "\n".. "Wird ein 'on' / 'off' Kommando an den Tür Controller II gesendet\\, entfernt bzw. setzt er die Blöcke ebenfalls.\n".. "\n".. - "Über ein 'exchange' Kommando können einzelne Böcke gesetzt\\, entfernt\\, bzw. durch andere Blöcke ersetzt werden. Die Slot-Nummer des Inventars (1 .. 16) muss als payload übergeben werden\\, also:\n".. + "Mit '$send_cmnd(node_number\\, \"exchange\"\\, 2)' können einzelne Böcke gesetzt\\, entfernt\\, bzw. durch andere Blöcke aus dem Inventar ersetzt werden. \n".. "\n".. - " $send_cmnd(node_number\\, \"exchange\"\\, 2)\n".. + "Mit '$send_cmnd(node_number\\, \"set\"\\, 2)' kann ein Block aus dem Inventory explizit gesetzt werden\\, sofern der Inventory Slot nicht leer ist.\n".. + "\n".. + "Mit '$send_cmnd(node_number\\, \"dig\"\\, 2)' kann ein Block wieder entfernt werden\\, sofern der Inventory Slot leer ist. \n".. + "\n".. + "Die Slot-Nummer des Inventars (1 .. 16) muss in allen drei Fällen als payload übergeben werden.\n".. "\n".. "Damit lassen sich auch ausfahrbare Treppen und ähnliches simulieren.\n".. "\n".. diff --git a/doc/manual_EN.lua b/doc/manual_EN.lua index 1adc444..53ce0f5 100644 --- a/doc/manual_EN.lua +++ b/doc/manual_EN.lua @@ -1144,9 +1144,13 @@ techage.manual_EN.aText = { "\n", "The Door Controller II can remove and set all types of blocks. To teach in the Door Controller II\\, the \"Record\" button must be pressed. Then all blocks that should be part of the door / gate must be clicked. Then the \"Done\" button must be pressed. Up to 16 blocks can be selected. The removed blocks are saved in the controller's inventory. The function of the controller can be tested manually using the \"Remove\" or \"Set\" buttons. If an 'on' /'off' command is sent to the Door Controller II\\, it removes or sets the blocks as well.\n".. "\n".. - "Individual blocks can be set\\, removed or replaced by other blocks via an 'exchange' command. The slot number of the inventory (1 .. 16) must be transferred as payload\\, i.e.:\n".. + "With '$send_cmnd(node_number\\, \"exchange\"\\, 2)' individual blocks can be set\\, removed or replaced by other blocks from the inventory. \n".. "\n".. - " $send_cmnd(node_number\\, \"exchange\"\\, 2)\n".. + "With '$send_cmnd(node_number\\, \"set\"\\, 2)' a block from the inventory can be set explicitly\\, as long as the inventory slot is not empty.\n".. + "\n".. + "A block can be removed again with '$send_cmnd(node_number\\, \"dig\"\\, 2)' if the inventory slot is empty. \n".. + "\n".. + "The slot number of the inventory (1 .. 16) must be passed as payload in all three cases.\n".. "\n".. "This can also be used to simulate extendable stairs and the like. \n".. "\n".. diff --git a/items/registered_nodes.lua b/items/registered_nodes.lua index c193ea0..8ff4fd8 100644 --- a/items/registered_nodes.lua +++ b/items/registered_nodes.lua @@ -65,3 +65,6 @@ techage.register_mobs_mods("mobs_skeletons") techage.register_mobs_mods("mobs_dwarves") techage.register_mobs_mods("mobf_trader") techage.register_mobs_mods("ts_vehicles_cars") + +-- Used as e.g. crane cable +techage.logic.register_doorcontroller_nodes({"techage:power_lineS"}) \ No newline at end of file diff --git a/manuals/manual_ta3_DE.md b/manuals/manual_ta3_DE.md index 48ee85d..76f2030 100644 --- a/manuals/manual_ta3_DE.md +++ b/manuals/manual_ta3_DE.md @@ -661,11 +661,13 @@ Der Tür Controller II kann alle Arten von Blöcken entfernen und wieder setzen. Wird ein `on` / `off` Kommando an den Tür Controller II gesendet, entfernt bzw. setzt er die Blöcke ebenfalls. -Über ein `exchange` Kommando können einzelne Böcke gesetzt, entfernt, bzw. durch andere Blöcke ersetzt werden. Die Slot-Nummer des Inventars (1 .. 16) muss als payload übergeben werden, also: +Mit `$send_cmnd(node_number, "exchange", 2)` können einzelne Böcke gesetzt, entfernt, bzw. durch andere Blöcke aus dem Inventar ersetzt werden. -``` -$send_cmnd(node_number, "exchange", 2) -``` +Mit `$send_cmnd(node_number, "set", 2)` kann ein Block aus dem Inventory explizit gesetzt werden, sofern der Inventory Slot nicht leer ist. + +Mit `$send_cmnd(node_number, "dig", 2)` kann ein Block wieder entfernt werden, sofern der Inventory Slot leer ist. + +Die Slot-Nummer des Inventars (1 .. 16) muss in allen drei Fällen als payload übergeben werden. Damit lassen sich auch ausfahrbare Treppen und ähnliches simulieren. diff --git a/manuals/manual_ta3_EN.md b/manuals/manual_ta3_EN.md index 67af7fd..9176378 100644 --- a/manuals/manual_ta3_EN.md +++ b/manuals/manual_ta3_EN.md @@ -654,11 +654,13 @@ The door controller is used to control the TA3 door/gate blocks. With the door c The Door Controller II can remove and set all types of blocks. To teach in the Door Controller II, the "Record" button must be pressed. Then all blocks that should be part of the door / gate must be clicked. Then the "Done" button must be pressed. Up to 16 blocks can be selected. The removed blocks are saved in the controller's inventory. The function of the controller can be tested manually using the "Remove" or "Set" buttons. If an `on` /`off` command is sent to the Door Controller II, it removes or sets the blocks as well. -Individual blocks can be set, removed or replaced by other blocks via an `exchange` command. The slot number of the inventory (1 .. 16) must be transferred as payload, i.e.: +With `$send_cmnd(node_number, "exchange", 2)` individual blocks can be set, removed or replaced by other blocks from the inventory. -``` -$send_cmnd(node_number, "exchange", 2) -``` +With `$send_cmnd(node_number, "set", 2)` a block from the inventory can be set explicitly, as long as the inventory slot is not empty. + +A block can be removed again with `$send_cmnd(node_number, "dig", 2)` if the inventory slot is empty. + +The slot number of the inventory (1 .. 16) must be passed as payload in all three cases. This can also be used to simulate extendable stairs and the like. diff --git a/manuals/ta4_lua_controller_EN.md b/manuals/ta4_lua_controller_EN.md index 51bf2a7..460c178 100644 --- a/manuals/ta4_lua_controller_EN.md +++ b/manuals/ta4_lua_controller_EN.md @@ -394,7 +394,9 @@ Please note, that this is not a technical distinction, only a logical. | "reset" | nil | Reset the item counter of the TA4 Item Detector block | | "pull" | item string | Start the TA4 pusher to pull/push items.
Example: `default:dirt 8` | | "config" | item string | Configure the TA4 pusher.
Example: `wool:blue` | -| "exchange" | inventory slot number | place/remove/exchange an block by means of the TA3 Door Controller II (techage:ta3_doorcontroller2) | +| "exchange" | inventory slot number | TA3 Door Controller II (techage:ta3_doorcontroller2)
Exchange a block
*idx* is the inventory slot number (1..n) of/for the block to be exchanged | +| "set" | inventory slot number | TA3 Door Controller II (techage:ta3_doorcontroller2)
Set/add a block
*idx* is the inventory slot number (1..n) with the block to be set | +| "dig" | inventory slot number | TA3 Door Controller II (techage:ta3_doorcontroller2)
Dig/remove a block
*idx* is the empty inventory slot number (1..n) for the block | | "a2b" | nil | TA4 Move Controller command to move the block(s) from position A to B | | "b2a" | nil | TA4 Move Controller command to move the block(s) from position B to A | | "move" | nil | TA4 Move Controller command to move the block(s) to the opposite position | diff --git a/move_controller/doorcontroller2.lua b/move_controller/doorcontroller2.lua index 19204d1..86b8399 100644 --- a/move_controller/doorcontroller2.lua +++ b/move_controller/doorcontroller2.lua @@ -167,7 +167,7 @@ local function exchange_node(pos, item, param2) return item, param2 end -local function exchange_nodes(pos, nvm, slot) +local function exchange_nodes(pos, nvm, slot, force) local meta = M(pos) local inv = meta:get_inventory() @@ -179,9 +179,14 @@ local function exchange_nodes(pos, nvm, slot) for idx = (slot or 1), (slot or 16) do local pos = nvm.pos_list[idx] + local item = item_list[idx] if pos then - item_list[idx], nvm.param2_list[idx] = exchange_node(pos, item_list[idx], nvm.param2_list[idx]) - res = true + if (force == nil) + or (force == "dig" and item:get_count() == 0) + or (force == "set" and item:get_count() > 0) then + item_list[idx], nvm.param2_list[idx] = exchange_node(pos, item, nvm.param2_list[idx]) + res = true + end end end @@ -342,6 +347,12 @@ techage.register_node({"techage:ta3_doorcontroller2"}, { elseif topic == "exchange" then local nvm = techage.get_nvm(pos) return exchange_nodes(pos, nvm, tonumber(payload)) + elseif topic == "set" then + local nvm = techage.get_nvm(pos) + return exchange_nodes(pos, nvm, tonumber(payload), "set") + elseif topic == "dig" then + local nvm = techage.get_nvm(pos) + return exchange_nodes(pos, nvm, tonumber(payload), "dig") end return false end, @@ -350,9 +361,15 @@ techage.register_node({"techage:ta3_doorcontroller2"}, { return hide_nodes(pos) and 0 or 3 elseif topic == 1 and payload[1] == 0 then return show_nodes(pos) and 0 or 3 - elseif topic == 9 then -- Exchange Block + elseif topic == 9 and payload[1] == 0 then -- Exchange Block local nvm = techage.get_nvm(pos) - return exchange_nodes(pos, nvm, payload[1] or 1) and 0 or 3 + return exchange_nodes(pos, nvm, payload[2] or 1) and 0 or 3 + elseif topic == 9 and payload[1] == 1 then -- Set Block + local nvm = techage.get_nvm(pos) + return exchange_nodes(pos, nvm, payload[2] or 1, "set") and 0 or 3 + elseif topic == 9 and payload[1] == 2 then -- Dig Block + local nvm = techage.get_nvm(pos) + return exchange_nodes(pos, nvm, payload[2] or 1, "dig") and 0 or 3 end return 2 end,