Advertisement
Daraketh

serverDisp

May 23rd, 2014
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.55 KB | None | 0 0
  1. os.loadAPI("buttonAPI")
  2. m = peripheral.wrap("bottom")
  3. m.setTextScale(2)
  4.  
  5. local count = 1
  6.  
  7. function centerText(text, posY)
  8.   local x, y = m.getSize()
  9.   m.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), posY)
  10.   m.write(text)
  11. end
  12.  
  13. function fillTable()
  14.   buttonAPI.setTable("Back", back, 2, 13, 16, 19)
  15.   buttonAPI.setTable("Forward", fwd, 24, 35, 16, 19)
  16.   buttonAPI.screen()
  17. end
  18.  
  19. function getClick()
  20.   event, side, x, y = os.pullEvent("monitor_touch")
  21.   buttonAPI.checkxy(x,y)
  22. end
  23.  
  24. function back()
  25.   buttonAPI.flash("Back")
  26.  
  27.   if count == 2 then
  28.     dispOne()
  29.     count = 1
  30.   elseif count == 3 then
  31.     dispTwo()
  32.     count = 2
  33.   end
  34. end
  35.  
  36. function fwd()
  37.   buttonAPI.flash("Forward")
  38.  
  39.   if count == 1 then
  40.     dispTwo()
  41.     count = 2
  42.   elseif count == 2 then
  43.     dispThree()
  44.     count = 3
  45.   end
  46. end
  47.  
  48. function dispOne()
  49.   m.clear()
  50.   fillTable()
  51.   centerText("1/3", 1)
  52.   centerText("Welcome to UmbraCraft", 5)
  53.   centerText("Oceanic Minecraft Community", 7)
  54.   centerText("Newcomers please read", 9)
  55. end
  56.  
  57. function dispTwo()
  58.   m.clear()
  59.   fillTable()
  60.   centerText("2/3", 1)
  61.   centerText("Rules:", 5)
  62.   centerText("Be Friendly", 7)
  63.   centerText("No Griefing", 8)
  64.   centerText("Follow these 2 basic rules", 10)
  65.   centerText("and all should be well", 11)
  66. end
  67.  
  68. function dispThree()
  69.   m.clear()
  70.   fillTable()
  71.   centerText("3/3", 1)
  72.   centerText("Useful Commands:", 5)
  73.   centerText("/nv - turn on Night Vision", 7)
  74.   centerText("/nv off - turn off Night Vision", 8)
  75. end
  76.  
  77. dispOne()
  78.  
  79. while true do
  80.   getClick()
  81. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement