From f41271c8d60e50213aa87e1b4cd22bdecdc5f6fc Mon Sep 17 00:00:00 2001 From: Olav Bakke Svendsen Date: Thu, 30 May 2024 16:30:43 +0200 Subject: [PATCH] Printing useful information when starting rscr programs --- rscr/controller.lua | 38 ++++++++++++++++++++++++++++++++++++++ rscr/remote.lua | 20 ++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/rscr/controller.lua b/rscr/controller.lua index 057dfed..c7bfb4e 100644 --- a/rscr/controller.lua +++ b/rscr/controller.lua @@ -1,5 +1,17 @@ local config = dofile("/etc/rscr.lua") +do + if config then + print("Current config:") + term.setTextColor(colors.lightGray) + print(textutils.serialize(config)) + term.setTextColor(colors.white) + else + print("No config found") + return false + end +end + local modem do local m @@ -10,7 +22,11 @@ do end if m then modem = peripheral.getName(m) + print("Modem found: "..modem) peripheral.call(modem, "open", config.controller_port) + term.setTextColor(colors.lightGray) + print(" listening on port "..tostring(config.controller_port)) + term.setTextColor(colors.white) else print("No modem connected") return false @@ -27,6 +43,7 @@ do end if sc then speed_controller = peripheral.getName(sc) + print("Rotation speed controller found: "..speed_controller) else print("No rotation speed controller connected") return false @@ -43,11 +60,28 @@ do end if sm then stressometer = peripheral.getName(sm) + print("Stressometer found: "..stressometer) else print("No stressometer connected, limited functionality") end end +local chatbox +do + local cb + if config.chatbox ~= nil then + cb = peripheral.wrap(config.chatbox) + else + cb = peripheral.find("chatBox") + end + if cb then + chatbox = peripheral.getName(cb) + print("Chatbox found: "..chatbox) + else + print("No chatbox connected, limited functionality") + end +end + local transmit = function(payload) peripheral.call(modem, "transmit", config.remote_port, config.controller_port, textutils.serialize(payload, { compact = true })) end @@ -129,4 +163,8 @@ update_remotes = function() return update_remotes() end +term.setTextColor(colors.green) +print("Controller online") +term.setTextColor(colors.white) + parallel.waitForAny(receive, update_remotes) diff --git a/rscr/remote.lua b/rscr/remote.lua index 20238e3..d88d579 100644 --- a/rscr/remote.lua +++ b/rscr/remote.lua @@ -3,6 +3,17 @@ -- listens for modem messages from controller local config = dofile("/etc/rscr.lua") +do + if config then + print("Current config:") + term.setTextColor(colors.lightGray) + print(textutils.serialize(config)) + term.setTextColor(colors.white) + else + print("No config found!") + return false + end +end local modem do @@ -14,7 +25,11 @@ do end if m then modem = peripheral.getName(m) + print("Modem found: "..modem) peripheral.call(modem, "open", config.remote_port) + term.setTextColor(colors.lightGray) + print(" listening on port "..tostring(config.remote_port)) + term.setTextColor(colors.white) else print("No modem connected") return false @@ -31,6 +46,7 @@ do end if m then monitor = peripheral.getName(m) + print("Monitor found: "..monitor) peripheral.call(monitor, "setTextScale", 0.5) else print("No advanced monitor connected") @@ -190,6 +206,10 @@ local on_terminate = function() peripheral.call(monitor, "clear") end +term.setTextColor(colors.green) +print("Remote online") +term.setTextColor(colors.white) + draw() transmit({ connect = true }) parallel.waitForAny(on_terminate, touch_screen, receive) -- 2.30.2