Advertisement
natie3

Menu

Sep 19th, 2014
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.44 KB | None | 0 0
  1. m = peripheral.wrap("back")
  2. list = { "diamond","gold","iron","leather"}
  3. ready = false
  4. x = 7
  5. y = 2
  6. term.clear()
  7.  
  8. function changePos(xpos,ypos)
  9.   term.setCursorPos(posx,posy)
  10.   term.write(" ")
  11.   term.setCursorPos(posx+12,posy)
  12.   term.write(" ")
  13.   posx = xpos
  14.   posy = ypos
  15.   term.setCursorPos(posx,posy)
  16.   term.write("[")
  17.   term.setCursorPos(posx+12,posy)
  18.   term.write("]")
  19. end
  20. term.setCursorPos(7-(string.len("exit")/2-1),1)
  21. term.write("exit")
  22. term.setCursorPos(20-(string.len("floor")/2-1),1)
  23. term.write("floor")
  24.  
  25. for i = 1, #list do
  26.   term.setCursorPos(x-(string.len(list[i])/2-1),y)
  27.   term.write(list[i])
  28.   if x == 20 then
  29.     x = 7
  30.     y = y + 1
  31.   else
  32.     x = 20
  33.   end
  34. end
  35. posx = 1
  36. posy = 1
  37. changePos(posx,posy)
  38.  
  39. while not ready do
  40.   event = { os.pullEvent("key") }
  41.   if event[2] == 17 and posy > 1 then
  42.     changePos(posx,posy-1)
  43.   elseif event[2] == 31 and posy < ((#list/2)+1) then
  44.     changePos(posx,posy+1)
  45.   elseif event[2] == 30 and posx == 14 then
  46.     changePos(posx-13,posy)
  47.   elseif event[2] == 32 and posx == 1 then
  48.     changePos(posx+13,posy)
  49.   elseif event[2] == 28 then
  50.     location = (posy*2)-2
  51.     if posx == 1 then
  52.       location = location + 1
  53.     else
  54.       location = location + 2
  55.     end
  56.     if location == 1 then
  57.       ready = true
  58.     end
  59.     if location == 2 then
  60.       m.transmit(100,101,"floor")
  61.     elseif location > 1 then
  62.       m.transmit(100,101,location-2)
  63.     end
  64.   end
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement