Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- options={ --This begins my options table.
- "option1",
- "option2",
- "option3",
- }
- function drawMenu() --Function where I draw the menu on the screen.
- if sel == 1 then--Tries to decide what the selected option is and draws the screen depending on that
- print("["..options[1].."]\n".. options[2].."\n".. options[3])
- elseif sel == 2 then
- print(options[1].."\n["..options[2].."]\n"..options[3])
- elseif sel == 3 then
- print(options[1].."\n"..options[2].."\n["..options[3].."]")
- else
- print("What?") --Pretty much just for debugging purposes
- end
- end
- function clear() --Had to clear the screen a lot so I thought"Well! May as well make a function for it!"
- term.clear()
- term.setCursorPos(1,1)
- end
- sel = 1--The first option is selected when the screen is first drawn
- clear()--clear the screen before starting
- while true do
- drawMenu()--draw the menu
- event, key=os.pullEvent("key")--wait for a key to be pressed
- if key == 200 and sel ~= 1 then--long and excessive logic(I feel it could be improved) to decide what to select next
- sel = sel-1
- clear()
- elseif key == 200 and sel == 1 then
- sel = sel
- clear()
- elseif key == 208 and sel ~= 3 then
- sel = sel+1
- clear()
- elseif key == 208 and sel == 3 then
- sel = sel
- clear()
- else
- sel = sel
- clear()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement