Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function OneChoice(option, exit,TC,STC)
- local w,h = term.getSize()
- local op1,op2 = 0, 0
- while true do
- if (string.len(option) >= (w-4)) then
- return error("Too Long")
- elseif (exit == true) then
- term.setCursorPos(4,(h-1))
- if (op1 == 1) then
- term.setTextColor(STC or colors.yellow)
- write("> "..option)
- else
- term.setTextColor(TC or colors.black)
- write("> "..option)
- end
- term.setCursorPos(4,h)
- if (op2 == 1) then
- term.setTextColor(STC or colors.yellow)
- write("> Exit")
- else
- term.setTextColor(TC or colors.black)
- write("> Exit")
- end
- else
- term.setCursorPos(4,h)
- if (op1 == 1) then
- term.setTextColor(STC or colors.yellow)
- write("> "..option)
- else
- term.setTextColor(TC or colors.black)
- write("> "..option)
- end
- end
- local event, side, mx, my = os.pullEvent("monitor_touch")
- if (my == (h-1) and op2 == 0 and op1 ~= 1) then
- op1 = 1
- elseif (my == h and op1 == 0 and op2 ~= 1) then
- if (exit == false) then
- op1 = 1
- else
- op2 = 1
- end
- elseif (my == (h-1) and op2 == 1) then
- op2 = 0
- op1 = 1
- elseif (my == h and op1 == 1) then
- op1 = 0
- op2 = 1
- elseif (my == (h-1) and op1 == 1) then
- if (exit == true) then
- return 1
- end
- elseif (my == h and op2 == 1) then
- if (exit == false) then
- return 1
- end
- return 2
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement