Advertisement
Dragoon209

debugMulti.lua

Sep 13th, 2024 (edited)
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local display = peripheral.find("monitor")
  2. local screenWidth = display.getSize()
  3. term.redirect(display)
  4.  
  5. rednet.open('top')
  6.  
  7. display.setTextScale(0.5)
  8.  
  9. local broadcastCat1 = "sorting"
  10. local broadcastCat2 = "chatting"
  11. local broadcastCat3 = "colors"
  12.  
  13. local header = window.create(display, 1, 1, 100, 1)
  14. local cat1 = window.create(display, 1, 2, 100, 1)
  15. local body1 = window.create(display, 1, 3, 100, 10)
  16. local cat2 = window.create(display, 1, 13, 100, 1)
  17. local body2 = window.create(display, 1, 14, 100, 10)
  18. local cat3 = window.create(display, 1, 24, 100, 1)
  19. local body3 = window.create(display, 1, 25, 100, 10)
  20.  
  21. function setHeader(h, m)
  22.     h.clear()
  23.     h.setBackgroundColor(colors.gray)
  24.     h.setTextColor(colors.black)
  25.     h.write(m)
  26. end
  27.  
  28. function setBody(b, m)
  29.     term.redirect(b)
  30.     b.setBackgroundColor(colors.black)
  31.     b.setTextColor(colors.green)
  32.     print(tostring(m))
  33. end
  34.  
  35. function waitCat1()
  36.     local ID, msg = rednet.receive(broadcastCat1)
  37.  
  38.     setBody(body1, ID .. ':'.. tostring(msg))
  39. end
  40.  
  41. function waitCat2()
  42.     local ID, msg = rednet.receive(broadcastCat2)
  43.  
  44.     setBody(body2, ID .. ':' .. tostring(msg))
  45. end
  46.  
  47. function waitCat3()
  48.     local ID, msg = rednet.receive(broadcastCat3)
  49.  
  50.     setBody(body3, ID .. ':' .. tostring(msg))
  51. end
  52.  
  53. print("Debug starting...")
  54. sleep(5)
  55. display.clear()
  56.  
  57. setHeader(header, "Debug Console")
  58. setHeader(cat1, "Sorting")
  59. setHeader(cat2, "Chatting")
  60. setHeader(cat3, "Text Color")
  61.  
  62. setBody(body1, "init")
  63. setBody(body2, "init")
  64. setBody(body3, "init")
  65.  
  66. while true do parallel.waitForAny(waitCat1, waitCat2, waitCat3) end
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement