Advertisement
Guest User

debug.lua

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