From 6e2ed8071b2e804ad87e9351cfe5ed84b02ad5a1 Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Sun, 14 May 2023 15:41:49 +0200 Subject: [PATCH] Add lua example for TA4 4x Button --- manuals/ta4_lua_controller_EN.md | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/manuals/ta4_lua_controller_EN.md b/manuals/ta4_lua_controller_EN.md index 59f9a5c..f7fb638 100644 --- a/manuals/ta4_lua_controller_EN.md +++ b/manuals/ta4_lua_controller_EN.md @@ -654,6 +654,45 @@ end +### Read the "TA4 4x Button" + +For the `$get_input(...)` function, the Lua controller expects received `on`/`off` commands. However, the "TA4 4x Button" is not able to send an `on` command followed by an `off` command. To be able to receive commands from "TA4 4x Button", the `$get_msg()` function has to be used. + +Therefore, the "TA4 4x Button" has to be programmed with commands like: `msg 1`, `msg 2`, `msg 3`, `msg 4`. + +The following example demonstrates receiving "TA4 4x Button" commands: + +init() code: + +```lua +$events(true) +$loopcycle(0) + +BUTTON = "372" -- "TA4 4x Button" number, to be adapted! +``` + +loop() code: + +```lua +if event then + num,text = $get_msg() + if num == BUTTON then + $print("button: " .. text) + end +end +``` + +If the buttons are pressed, the "outp" window of the Lua controller will look like: + +``` +button: 1 +button: 4 +button: 3 +button: 2 +``` + + + ### Emails For an email system you need a TA4 Lua Server and a TA4 Lua Controller with Terminal per player.