Advertisement
Guest User

screens

a guest
Aug 4th, 2015
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.81 KB | None | 0 0
  1. local mon = peripheral.find("monitor")
  2.  
  3. function cls()
  4.   mon.setTextColor(colors.white)
  5.   mon.setBackgroundColor(colors.black)
  6.   mon.setCursorPos(1, 1)
  7.   mon.clear()
  8. end
  9.  
  10. function center(words)
  11.   local x, y = mon.getSize()
  12.   local posx = math.floor((x / 2) - (string.len(words) / 2) + 1)
  13.   local posy = math.floor((y / 2) + 1)
  14.   mon.setCursorPos(posx, posy)
  15.   mon.write(words)
  16. end
  17.  
  18. function center2(words, xmin, ymin)
  19.   local x = xmin
  20.   local y = ymin
  21.   --print(words)
  22.   --print(x)
  23.   local posx = math.floor((x / 2) - (string.len(words) / 2) + 1)
  24.   local posy = math.floor((y / 2) + 1)
  25.   cls()
  26.   --local prevColor = mon.getBackgroundColor()
  27.   mon.setTextColor(colors.white)
  28.   mon.setBackgroundColor(colors.red)
  29.   mon.setCursorPos(xmin, ymin)
  30.   mon.write(words)
  31.   mon.setBackgroundColor(colors.black)
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement