Advertisement
Dragoon209

colors_example.lua

Sep 12th, 2024 (edited)
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.77 KB | Gaming | 0 0
  1.  local p = {}
  2.  local c = ""
  3.  if v == 0 then p = colors.white
  4.      c = "white"
  5.  elseif v == 1 then p = colors.orange
  6.      c = "orange"
  7.  elseif v == 2 then p = colors.magenta
  8.      c = "magenta"
  9.  elseif v == 3 then p = colors.lightBlue
  10.      c = "light blue"
  11.  elseif v == 4 then p = colors.yellow
  12.      c = "yellow"
  13.  elseif v == 5 then p = colors.lime
  14.      c = "lime"
  15.  elseif v == 6 then p = colors.pink
  16.      c = "pink"
  17.  elseif v == 7 then p = colors.gray
  18.      c = "gray"
  19.  elseif v == 8 then p = colors.lightGray
  20.      c = "light gray"
  21.  elseif v == 9 then p = colors.cyan
  22.      c = "cyan"
  23.     elseif v == 10 then p = colors.purple
  24.     c = "purple"
  25.     elseif v == 11 then p = colors.blue
  26.     c = "blue"
  27.     elseif v == 12 then p = colors.brown
  28.     c = "brown"
  29.     elseif v == 13 then p = colors.green
  30.     c = "green"
  31.     elseif v == 14 then p = colors.red
  32.     c = "red"
  33.     elseif v == 15 then p = colors.black
  34.     c = "black"
  35.  else p = colors.black
  36.      c = "black"
  37.  end
  38.  
  39. return p, c
  40. end
  41.  
  42. local monitor = peripheral.find("monitor")
  43. term.redirect(monitor)
  44. local scale = monitor.getTextScale()
  45. local size = monitor.getSize()
  46. print("current text scale is " .. scale)
  47. print("current screen size is " .. size)
  48. sleep(5)
  49. monitor.clear()
  50.  
  51. local header = window.create(term.current(), 1, 1, 29, 1)
  52. header.setBackgroundColor(colors.gray)
  53. local body = window.create(term.current(), 1,2, 29, 18)
  54. body.setBackgroundColor(colors.black)
  55. header.write("Color Testing")
  56. term.redirect(body)
  57.  
  58. function drawLoop()
  59.     for i=0, 15 do
  60.   local curColor, curName = getColor(i)
  61.         body.setTextColor(curColor)
  62.         body.setBackgroundColor(colors.black)
  63.         if i == 15 then body.setBackgroundColor(colors.white) end
  64.         print("Hello World! - " .. curName)
  65.         sleep(1)
  66.         end
  67. end
  68.  
  69. while true do drawLoop() end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement