Advertisement
koki2000

bolt

Jul 26th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.53 KB | None | 0 0
  1. local pullEvent = os.pullEvent
  2. os.pullEvent = os.pullEventRaw
  3.  
  4. term.clear()
  5. w, h = term.getSize()
  6. local selecteditem = 1
  7. local side = 1
  8. local step = 1
  9. local running = false
  10. mainmenu = {
  11.  
  12. [1] = {text = "cactus", id = 81, price = 100},
  13. [2] = {text = "wool", id = 35, price = 100},
  14. [3] = {text = "soul sand", id = 88, price = 250},
  15. [4] = {text = "dispenser", id = 23, price = 250},
  16. [5] = {text = "piston", id = 33, price = 150},
  17. [6] = {text = "sticky piston", id = 29, price = 200},
  18. [7] = {text = "ench table", id = 116, price = 2500},
  19. [8] = {text = "furnace", id = 61, price = 100},
  20. [9] = {text = "chest", id = 54, price = 150},
  21. [10] = {text = "crafting table", id = 169, price = 100},
  22. [11] = {text = "pumpkin", id = 86, price = 100},
  23. [12] = {text = "melon", id = 103, price = 100},
  24. [13] = {text = "wood", id = 5, price = 50},
  25. [14] = {text = "obsidian", id = 49, price = 250},
  26. [15] = {text = "glowstone", id = "dust?", price = 250},
  27. [16] = {text = "block of c. stone", id = "214:1", price = 1000},
  28. [17] = {text = "block of steel", id = "214:2", price = 500},
  29. [18] = {text = "uranium block", id = "224:3", price = 1000},
  30. [19] = {text = "ruby block", id = "145", price = 1500},
  31. [20] = {text = "emerald block", id = "145:2", price = 1500},
  32. [21] = {text = "sapphire block", id = "145:3", price = 1500},
  33. [22] = {text = "copper block", id = "224", price = 500},
  34. [23] = {text = "tin block", id = "224:1", price = 600},
  35. [24] = {text = "bronze block", id = "224:2", price = 750},
  36. [25] = {text = "lapis lazuli block", id = "22", price = 1000},
  37. [26] = {text = "block of iron", id = "42", price = 1000},
  38. [27] = {text = "block of gold", id = "41", price = 2500},
  39. [28] = {text = "block of diamond", id = "57", price = 5000},
  40. [29] = {text = "DM block", id = "126:8", price = 7500},
  41. [30] = {text = "RM block", id = "126:9", price = 10000},
  42. [31] = {text = "32", id = "32", price = 1500},
  43. [32] = {text = "33", id = "33", price = 1500},
  44. [33] = {text = "34", id = "34", price = 1500},
  45. [34] = {text = "35", id = "35", price = 1500},
  46. [35] = {text = "36", id = "36", price = 1500},
  47. [36] = {text = "37", id = "37", price = 1500},
  48. [37] = {text = "38", id = "38", price = 1500},
  49. [38] = {text = "39", id = "39", price = 1500},
  50. [39] = {text = "40", id = "40", price = 1500},
  51. [40] = {text = "41", id = "41", price = 1500},
  52. [41] = {text = "42", id = "42", price = 1500},
  53. [42] = {text = "43", id = "43", price = 1500},
  54. [43] = {text = "44", id = "44", price = 1500},
  55. [44] = {text = "45", id = "45", price = 1500},
  56. [45] = {text = "46", id = "46", price = 1500},
  57. [46] = {text = "47", id = "47", price = 1500},
  58. [47] = {text = "48", id = "48", price = 1500},
  59. [48] = {text = "49", id = "49", price = 1500},
  60. [49] = {text = "50", id = "50", price = 1500},
  61. [50] = {text = "51", id = "51", price = 1500},
  62. [51] = {text = "52", id = "52", price = 1500},
  63. }
  64.  
  65. function tclr()
  66.  term.clear()
  67.  term.setCursorPos(1,1)
  68. end
  69.  
  70. function printmenu(menu)
  71.  term.clear()
  72.  term.setCursorPos(w-w+1, h-1)
  73.  print("gyorskereso: Right Shift")
  74.  if selecteditem<h*2-3 then
  75.   step = 1
  76.  elseif selecteditem>=h*2-4 then
  77.   step = 32
  78.  end
  79.  for i=step, #menu do
  80.   if selecteditem<h*2-3 then
  81.    if i<=h-2 then
  82.     if i == selecteditem then
  83.      term.setCursorPos(w-w+1, (i))
  84.      print("["..menu[i].text.."]")
  85.     else
  86.      term.setCursorPos(w-w+1, (i))
  87.      print(" "..menu[i].text.." ")
  88.     end
  89.    elseif i>=h-1 and i<=h*2-4 then
  90.     if i == selecteditem then
  91.      term.setCursorPos(w/2+5, (i-h+2))
  92.      print("["..menu[i].text.."]")
  93.     else
  94.      term.setCursorPos(w/2+5, (i-h+2))
  95.      print(" "..menu[i].text.." ")
  96.     end
  97.    end
  98.   elseif selecteditem > h*2-4 then
  99.    if i-32<=h-2 then
  100.     if i == selecteditem then
  101.      term.setCursorPos(w-w+1, (i-32))
  102.      print("["..menu[i].text.."]")
  103.     else
  104.      term.setCursorPos(w-w+1, (i-32))
  105.      print(" "..menu[i].text.." ")
  106.     end
  107.    elseif i-32>=h-1 and i-32<=h*2-4 then
  108.     if i == selecteditem then
  109.      term.setCursorPos(w/2+5, (i-32-h+2))
  110.      print("["..menu[i].text.."]")
  111.     else
  112.      term.setCursorPos(w/2+5, (i-32-h+2))
  113.      print(" "..menu[i].text.." ")
  114.     end
  115.    end
  116.   end
  117.  end
  118.  --term.setCursorPos(w, h)
  119. -- print(selecteditem)
  120. end
  121.  
  122. function onkeypressed(key, menu)
  123.  if key == 28 then
  124.   term.setCursorPos(w-w+1, h-1)
  125.   print("name: "..menu[selecteditem].text.." :: price: "..menu[selecteditem].price.." $") sleep(3)
  126.  elseif key == 54 then
  127.   term.clear()
  128.   term.setCursorPos(1, 1)
  129.   print("ird be a keresett targy azonositojat")
  130.   id = tonumber(read())
  131.    if id == nil then
  132.       term.setCursorPos(w-w+1, h-1)
  133.       print("Az azonosito csak szam lehet!") sleep(3)
  134.    else
  135.     id = id + 0
  136.     for i = 1, #menu do
  137.      if id == menu[i].id then
  138.       selecteditem = i
  139.       printmenu(mainmenu)
  140.       term.setCursorPos(w-w+1, h-1)
  141.       print("name: "..menu[selecteditem].text.." :: price: "..menu[selecteditem].price.." $") sleep(3)
  142.       return
  143.      else
  144.       if i == #menu then
  145.        term.setCursorPos(w-w+1, h-1)
  146.        print("nincs ilyen azonosito") sleep(1)
  147.       end
  148.      end
  149.     end
  150.    end
  151.  elseif key == 203 then
  152.   if selecteditem > h - 2 then
  153.    selecteditem = selecteditem - h + 2
  154.   end
  155.  elseif key == 205 then
  156.   if selecteditem < #menu - h + 3 then
  157.    selecteditem = selecteditem + h - 2
  158.   end
  159.  elseif key == 200 then
  160.   if selecteditem > 1 then
  161.    selecteditem = selecteditem - 1
  162.   end
  163.  elseif key == 208 then
  164.   if selecteditem < #menu then
  165.    selecteditem = selecteditem + 1
  166.   end
  167.  end
  168. end
  169.  
  170. while true do
  171.  printmenu(mainmenu)
  172.  event, key = os.pullEvent("key")
  173.  onkeypressed(key, mainmenu)
  174. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement