TA4 Sequencer: Add 'on' and 'off' commands

Allows the sequencer to be used with buttons, for example.
This commit is contained in:
Thomas--S 2022-05-02 17:12:52 +02:00
parent 47c391c679
commit 806af873b4
5 changed files with 7 additions and 3 deletions

View File

@ -1686,6 +1686,7 @@ techage.manual_DE.aText = {
"\n".. "\n"..
" - 'goto <num>' Zu einer Kommandozeile springen und damit den Sequenzer starten\n".. " - 'goto <num>' Zu einer Kommandozeile springen und damit den Sequenzer starten\n"..
" - 'stop' Den Sequenzer anhalten\n".. " - 'stop' Den Sequenzer anhalten\n"..
" - 'on' und 'off' als Alias für 'goto 1' bzw. 'stop'\n"..
"\n".. "\n"..
"Das 'goto' Kommando wird nur angenommen\\, wenn der Sequenzer gestoppt ist.\n".. "Das 'goto' Kommando wird nur angenommen\\, wenn der Sequenzer gestoppt ist.\n"..
"\n".. "\n"..

View File

@ -1682,6 +1682,7 @@ techage.manual_EN.aText = {
"\n".. "\n"..
" - 'goto <num>' Jump to a command line and start the sequencer\n".. " - 'goto <num>' Jump to a command line and start the sequencer\n"..
" - 'stop' Stop the sequencer\n".. " - 'stop' Stop the sequencer\n"..
" - 'on' and 'off' as aliases for 'goto 1' resp. 'stop'\n"..
"\n".. "\n"..
"The 'goto' command is only accepted when the sequencer is stopped.\n".. "The 'goto' command is only accepted when the sequencer is stopped.\n"..
"\n".. "\n"..

View File

@ -290,18 +290,18 @@ minetest.register_craft({
}, },
}) })
local INFO = [[Commands: 'goto <num>', 'stop']] local INFO = [[Commands: 'goto <num>', 'stop', 'on', 'off']]
techage.register_node({"techage:ta4_sequencer"}, { techage.register_node({"techage:ta4_sequencer"}, {
on_recv_message = function(pos, src, topic, payload) on_recv_message = function(pos, src, topic, payload)
local nvm = techage.get_nvm(pos) local nvm = techage.get_nvm(pos)
if topic == "goto" and not nvm.running then if (topic == "goto" or topic == "on") and not nvm.running then
local mem = techage.get_mem(pos) local mem = techage.get_mem(pos)
nvm.running = true nvm.running = true
mem.idx = tonumber(payload or 1) or 1 mem.idx = tonumber(payload or 1) or 1
restart_timer(pos, 0.1) restart_timer(pos, 0.1)
logic.infotext(M(pos), S("TA4 Sequencer"), S("running")) logic.infotext(M(pos), S("TA4 Sequencer"), S("running"))
elseif topic == "stop" then elseif topic == "stop" or topic == "off" then
nvm.running = false nvm.running = false
minetest.get_node_timer(pos):stop() minetest.get_node_timer(pos):stop()
logic.infotext(M(pos), S("TA4 Sequencer"), S("stopped")) logic.infotext(M(pos), S("TA4 Sequencer"), S("stopped"))

View File

@ -550,6 +550,7 @@ Der TA4 Sequenzer unterstützt folgende techage Kommandos:
- `goto <num>` Zu einer Kommandozeile springen und damit den Sequenzer starten - `goto <num>` Zu einer Kommandozeile springen und damit den Sequenzer starten
- `stop` Den Sequenzer anhalten - `stop` Den Sequenzer anhalten
- `on` und `off` als Alias für `goto 1` bzw. `stop`
Das `goto` Kommando wird nur angenommen, wenn der Sequenzer gestoppt ist. Das `goto` Kommando wird nur angenommen, wenn der Sequenzer gestoppt ist.

View File

@ -542,6 +542,7 @@ The TA4 sequencer supports the following techage commands:
- `goto <num>` Jump to a command line and start the sequencer - `goto <num>` Jump to a command line and start the sequencer
- `stop` Stop the sequencer - `stop` Stop the sequencer
- `on` and `off` as aliases for `goto 1` resp. `stop`
The `goto` command is only accepted when the sequencer is stopped. The `goto` command is only accepted when the sequencer is stopped.