Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- This is a demonstration of the use ofthe menu library at:
- https://pastebin.com/BhjbYsw4
- ]]
- function main()
- local menu = require("menu")
- local prompt = "Choose your option:"
- --[[ table of options. The first choice will be cut down to size,
- the 11th exceeds permissible views on a turtle so will not
- appear, but will appear on a computer, which can show 16 options
- ]]
- local options = {"First choice which has been made into a very long string",
- "Second choice", "Third choice", "Fourth choice",
- "Fifth choice", "Sixth choice","Seventh choice", "Eighth choice",
- "Ninth choice", "Tenth choice","This choice won't show on a turtle"}
- -- show the menu to get user input
- local choice = menu.new(prompt, options)
- if choice == nil then
- print ("You chose to cancel the menu")
- else
- print("You chose option no "..choice..": "..options[choice])
- end
- sleep(3)
- prompt = "which direction do you want to go?"
- options = {"North", "East", "South", "West"}
- choice = menu.new(prompt, options)
- if choice == nil then
- print ("You chose to stay where you are")
- else
- print("Great! We are heading "..options[choice])
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement