TheyCallMeAmi

test_monitor

Jul 22nd, 2025 (edited)
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. -- find_monitor_colors.lua
  2. local monitor = peripheral.wrap("monitor_0") -- Ersätt om ditt namn är annorlunda
  3. if not monitor then error("Monitor hittades inte!") end
  4.  
  5. monitor.clear()
  6. monitor.setTextScale(0.75)
  7. monitor.setBackgroundColor(0x8000) -- Din svarta bakgrund
  8. monitor.setCursorPos(1,1)
  9. monitor.setTextColor(0x1) -- Din vita text
  10. monitor.write("Hitta farger for din monitor:")
  11.  
  12. local x_pos = 1
  13. local y_pos = 3
  14.  
  15. -- Testa 16-bitars bitmaskvärden (2^0 till 2^15) som är vanliga i äldre CC
  16. for i = 0, 15 do
  17. local color_id = 2^i
  18. monitor.setCursorPos(x_pos, y_pos)
  19. monitor.setTextColor(color_id)
  20. monitor.write(string.format("ID 0x%X ", color_id))
  21.  
  22. x_pos = x_pos + 12 -- Flytta till nästa kolumn
  23. if x_pos > monitor.getWidth() - 12 then -- Om för långt, gå till nästa rad
  24. x_pos = 1
  25. y_pos = y_pos + 1
  26. end
  27. end
  28.  
  29. -- Testa sekventiella ID:n 0-15 också, för säkerhets skull
  30. monitor.setCursorPos(1, y_pos + 2)
  31. monitor.setTextColor(0x1) -- Vit
  32. monitor.write("Sekventiella ID:n 0-15:")
  33. x_pos = 1
  34. y_pos = y_pos + 3
  35.  
  36. for i = 0, 15 do
  37. monitor.setCursorPos(x_pos, y_pos)
  38. monitor.setTextColor(i)
  39. monitor.write(string.format("ID %d ", i))
  40.  
  41. x_pos = x_pos + 8 -- Flytta till nästa kolumn
  42. if x_pos > monitor.getWidth() - 8 then
  43. x_pos = 1
  44. y_pos = y_pos + 1
  45. end
  46. end
  47.  
  48. print("Test klart. Titta pa monitorn for farg-ID:n.")
Advertisement
Add Comment
Please, Sign In to add comment