Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local pullEvent = os.pullEvent
- os.pullEvent = os.pullEventRaw
- term.clear()
- w, h = term.getSize()
- local selecteditem = 1
- local side = 1
- local step = 1
- local running = false
- mainmenu = {
- [1] = {text = "cactus", id = 81, price = 100},
- [2] = {text = "wool", id = 35, price = 100},
- [3] = {text = "soul sand", id = 88, price = 250},
- [4] = {text = "dispenser", id = 23, price = 250},
- [5] = {text = "piston", id = 33, price = 150},
- [6] = {text = "sticky piston", id = 29, price = 200},
- [7] = {text = "ench table", id = 116, price = 2500},
- [8] = {text = "furnace", id = 61, price = 100},
- [9] = {text = "chest", id = 54, price = 150},
- [10] = {text = "crafting table", id = 169, price = 100},
- [11] = {text = "pumpkin", id = 86, price = 100},
- [12] = {text = "melon", id = 103, price = 100},
- [13] = {text = "wood", id = 5, price = 50},
- [14] = {text = "obsidian", id = 49, price = 250},
- [15] = {text = "glowstone", id = "dust?", price = 250},
- [16] = {text = "block of c. stone", id = "214:1", price = 1000},
- [17] = {text = "block of steel", id = "214:2", price = 500},
- [18] = {text = "uranium block", id = "224:3", price = 1000},
- [19] = {text = "ruby block", id = "145", price = 1500},
- [20] = {text = "emerald block", id = "145:2", price = 1500},
- [21] = {text = "sapphire block", id = "145:3", price = 1500},
- [22] = {text = "copper block", id = "224", price = 500},
- [23] = {text = "tin block", id = "224:1", price = 600},
- [24] = {text = "bronze block", id = "224:2", price = 750},
- [25] = {text = "lapis lazuli block", id = "22", price = 1000},
- [26] = {text = "block of iron", id = "42", price = 1000},
- [27] = {text = "block of gold", id = "41", price = 2500},
- [28] = {text = "block of diamond", id = "57", price = 5000},
- [29] = {text = "DM block", id = "126:8", price = 7500},
- [30] = {text = "RM block", id = "126:9", price = 10000},
- [31] = {text = "32", id = "32", price = 1500},
- [32] = {text = "33", id = "33", price = 1500},
- [33] = {text = "34", id = "34", price = 1500},
- [34] = {text = "35", id = "35", price = 1500},
- [35] = {text = "36", id = "36", price = 1500},
- [36] = {text = "37", id = "37", price = 1500},
- [37] = {text = "38", id = "38", price = 1500},
- [38] = {text = "39", id = "39", price = 1500},
- [39] = {text = "40", id = "40", price = 1500},
- [40] = {text = "41", id = "41", price = 1500},
- [41] = {text = "42", id = "42", price = 1500},
- [42] = {text = "43", id = "43", price = 1500},
- [43] = {text = "44", id = "44", price = 1500},
- [44] = {text = "45", id = "45", price = 1500},
- [45] = {text = "46", id = "46", price = 1500},
- [46] = {text = "47", id = "47", price = 1500},
- [47] = {text = "48", id = "48", price = 1500},
- [48] = {text = "49", id = "49", price = 1500},
- [49] = {text = "50", id = "50", price = 1500},
- [50] = {text = "51", id = "51", price = 1500},
- [51] = {text = "52", id = "52", price = 1500},
- }
- function tclr()
- term.clear()
- term.setCursorPos(1,1)
- end
- function printmenu(menu)
- term.clear()
- term.setCursorPos(w-w+1, h-1)
- print("gyorskereso: Right Shift")
- if selecteditem<h*2-3 then
- step = 1
- elseif selecteditem>=h*2-4 then
- step = 32
- end
- for i=step, #menu do
- if selecteditem<h*2-3 then
- if i<=h-2 then
- if i == selecteditem then
- term.setCursorPos(w-w+1, (i))
- print("["..menu[i].text.."]")
- else
- term.setCursorPos(w-w+1, (i))
- print(" "..menu[i].text.." ")
- end
- elseif i>=h-1 and i<=h*2-4 then
- if i == selecteditem then
- term.setCursorPos(w/2+5, (i-h+2))
- print("["..menu[i].text.."]")
- else
- term.setCursorPos(w/2+5, (i-h+2))
- print(" "..menu[i].text.." ")
- end
- end
- elseif selecteditem > h*2-4 then
- if i-32<=h-2 then
- if i == selecteditem then
- term.setCursorPos(w-w+1, (i-32))
- print("["..menu[i].text.."]")
- else
- term.setCursorPos(w-w+1, (i-32))
- print(" "..menu[i].text.." ")
- end
- elseif i-32>=h-1 and i-32<=h*2-4 then
- if i == selecteditem then
- term.setCursorPos(w/2+5, (i-32-h+2))
- print("["..menu[i].text.."]")
- else
- term.setCursorPos(w/2+5, (i-32-h+2))
- print(" "..menu[i].text.." ")
- end
- end
- end
- end
- --term.setCursorPos(w, h)
- -- print(selecteditem)
- end
- function onkeypressed(key, menu)
- if key == 28 then
- term.setCursorPos(w-w+1, h-1)
- print("name: "..menu[selecteditem].text.." :: price: "..menu[selecteditem].price.." $") sleep(3)
- elseif key == 54 then
- term.clear()
- term.setCursorPos(1, 1)
- print("ird be a keresett targy azonositojat")
- id = tonumber(read())
- if id == nil then
- term.setCursorPos(w-w+1, h-1)
- print("Az azonosito csak szam lehet!") sleep(3)
- else
- id = id + 0
- for i = 1, #menu do
- if id == menu[i].id then
- selecteditem = i
- printmenu(mainmenu)
- term.setCursorPos(w-w+1, h-1)
- print("name: "..menu[selecteditem].text.." :: price: "..menu[selecteditem].price.." $") sleep(3)
- return
- else
- if i == #menu then
- term.setCursorPos(w-w+1, h-1)
- print("nincs ilyen azonosito") sleep(1)
- end
- end
- end
- end
- elseif key == 203 then
- if selecteditem > h - 2 then
- selecteditem = selecteditem - h + 2
- end
- elseif key == 205 then
- if selecteditem < #menu - h + 3 then
- selecteditem = selecteditem + h - 2
- end
- elseif key == 200 then
- if selecteditem > 1 then
- selecteditem = selecteditem - 1
- end
- elseif key == 208 then
- if selecteditem < #menu then
- selecteditem = selecteditem + 1
- end
- end
- end
- while true do
- printmenu(mainmenu)
- event, key = os.pullEvent("key")
- onkeypressed(key, mainmenu)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement