Printing useful information when starting rscr programs
authorOlav Bakke Svendsen <mail@olavbs.no>
Thu, 30 May 2024 14:30:43 +0000 (16:30 +0200)
committerOlav Bakke Svendsen <mail@olavbs.no>
Thu, 30 May 2024 14:30:43 +0000 (16:30 +0200)
rscr/controller.lua
rscr/remote.lua

index 057dfedba654f8c1690847bf4a859d7783bdf5bf..c7bfb4ef154abc47610a70d1f9f5a3f26ef41181 100644 (file)
@@ -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)
index 20238e349f58faf621a6c4a46f43449584ee5ddf..d88d57947bfbb738fbea7d349a02ec0c265530db 100644 (file)
@@ -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)