RebelliousUno

Subscriber Wall

Oct 17th, 2014
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.11 KB | None | 0 0
  1. --Author: RebelliousUno
  2. --Date: 16/10/2014
  3. --Last Modified: 17/10/2014
  4.  
  5.  
  6. cabinet = peripheral.wrap("bottom")
  7. monitor = peripheral.wrap("top")
  8. monitor.setTextScale(1.5)
  9. maxLength = 15
  10. x, y = monitor.getSize();
  11.  
  12. function doMain()
  13.     lastInvSize=0
  14.     while(true) do
  15.         invSize =cabinet.getInventorySize()
  16.         if invSize>lastInvSize then
  17.             monitor.clear()
  18.             doTitles()
  19.             monitor.setCursorPos(1,2)
  20.             for i= 1, invSize-1 do
  21.                 name = cabinet.getStackInSlot(i)["name"]
  22.                 nameLen = string.len(name)
  23.                 posX, posY = monitor.getCursorPos()
  24.                 if posX+nameLen > x then
  25.                     posY = posY+1
  26.                     posX = 1
  27.                 end
  28.          
  29.                 monitor.setCursorPos(posX,posY)
  30.                 monitor.write(name)
  31.                 newX, newY = monitor.getCursorPos()
  32.                 newX = 1+math.ceil(newX/maxLength)*maxLength
  33.                 print(newX)
  34.                 monitor.setCursorPos(newX,newY)
  35.             end
  36.         lastInvSize = invSize
  37.         end
  38.         sleep(5)
  39.     end
  40. end
  41.  
  42. function doTitles()
  43.     titleText = "Subscribers Wall"
  44.     monitor.setCursorPos(((x/2)-(string.len(titleText)/2)),1)
  45.     monitor.setTextColor(colors.cyan)
  46.     monitor.write(titleText)
  47.     monitor.setTextColor(colors.white)
  48. end
  49.  
  50. doMain()
Advertisement
Add Comment
Please, Sign In to add comment