Advertisement
MagmaLP

Test Center text

Jan 15th, 2023 (edited)
981
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.47 KB | None | 0 0
  1. os.loadAPI("ocs/apis/sensor")
  2. s = sensor.wrap("right")
  3. mon = peripheral.wrap("back")
  4. mon.setBackgroundColor(colors.black)
  5. mon.setTextScale(3)
  6. mon.clear()
  7.  
  8. mon.setTextColor(colors.yellow)
  9.  
  10. function centerText(text)
  11.     local x,y = mon.getSize()
  12.     local x2,y2 = mon.getCursorPos()
  13.     mon.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
  14.     write(text)
  15. end
  16.  
  17. while true do
  18.     for name,info in pairs(s.getTargets()) do        
  19.         centerText(name)
  20.     end
  21.     sleep(2)
  22. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement