Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function menu(...) -- ver 0.1
- local sel = 1
- local list = {...}
- local offX,offY = term.getCursorPos()
- local curX,curY = term.getCursorPos()
- while true do
- if sel > #list then sel = 1 end
- if sel < 1 then sel = #list end
- for i = 1,#list do
- term.setCursorPos(offX,offY+i-1)
- if sel == i then
- print("["..list[i].."]") -- very customisible example print(">"..list[i])
- else
- print(" "..list[i].." ") -- very customisible
- 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 list[sel],sel
- end
- end
- end
- end
- end
- -- Example Usage
- print("Please select Option")
- local selection = menu("Redstone","Hardware","WiFi","Event Monitor","Turtle Driver","Infomation/Help","Exit")
- if selection == "Redstone" then
- RedstoneControl()
- elseif selection == "Hardware" then
- Hardware()
- elseif selection == "WiFi" then
- wifi()
- elseif selection == "Event Monitor" then
- EventMonitor()
- elseif selection == "Turtle Driver" then
- TurtleDriver()
- elseif selection == "Infomation/Help" then
- help()
- elseif selection == "Exit" then
- bRunning = false
- end
Add Comment
Please, Sign In to add comment