Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local stringQuestionAsked = "Do you want to?"
- local choices = {"Yes I do", "No I don't"}
- local chosenOne
- local highlighted = 1
- local x,y = term.getSize()
- function writeChoices() --writes the choices down made for the menu
- for i=1,#choices do
- if i == highlighted then
- term.setCursorPos(((x/2)-(("<| "..choices[i].." |>"):len()/2)),i + 2)
- term.clearLine()
- term.write("<| "..choices[i].." |>")
- else
- term.setCursorPos(((x/2)-(choices[i]:len()/2)),i + 2)
- term.clearLine()
- term.write(choices[i])
- end
- end
- end
- function menuSelection() --waits for key input and changes the highlighted menuElemnt
- while true do
- writeChoices()
- local event, key = os.pullEvent( "key" )
- if key == keys.down then
- highlighted = highlighted + 1
- end
- if key == keys.up then
- highlighted = highlighted - 1
- end
- if key == keys.enter then
- chosenOne = choices[highlighted]
- break
- end
- if highlighted == 0 then
- highlighted = #choices
- end
- if highlighted == #choices + 1 then
- highlighted = 1
- end
- end
- end
- function Menu() --Creates a menu
- term.clear()
- term.setCursorPos(math.ceil((x/2)-(stringQuestionAsked:len()/2)),1)
- term.write(stringQuestionAsked)
- menuSelection()
- end
- term.clear()
- term.setCursorPos(1,1)
- print("Are you sure you want to delete the Positional data of the turtle. This will mean you will have to replace it in a new Starting Position and your number of holes dug will be reset.")
- os.sleep(8)
- Menu()
- if chosenOne == choices[1] then
- fs.delete("Data/".."turtleDataFile")
- fs.delete("Data/".."turtleActivity")
- fs.delete("Data/".."turtleModemFile")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement