Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Basic Menu
- by
- Big Shiny Toys
- ]]--
- local function menu(...)
- local sel = 1
- local list = {...}
- local offX,offY = 1,1 -- change this to what ever off set you want
- local curX,curY = term.getCursorPos()
- while true do
- if sel > #list then sel = #list end
- if sel < 1 then sel = 1 end
- for i = 1,#list do
- term.setCursorPos(offX,offY+i-1)
- if sel == i then
- print("["..list[i].."]")
- else
- print(" "..list[i].." ")
- end
- end
- while true do
- local e,e1,e2,e3,e4,e5 = os.pullEvent()
- if e == "key" then
- if e1 == 200 then -- up key
- sel = sel-1
- break
- end
- if e1 == 208 then -- down key
- sel = sel+1
- break
- end
- if e1 == 28 then
- term.setCursorPos(curX,curY)
- return sel
- end
- end
- end
- end
- end
- term.clear() -- clears all test from screen
- print(menu("Item one","Item two","item three","there there")) -- add as many items as you want
Advertisement
Add Comment
Please, Sign In to add comment