Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Basic menus:
- -- Creating programs
- -- Text
- -- Debugging
- -- Variables
- --
- --
- -- Advanced menus:
- -- Pull event
- -- input
- -- loop
- -- functions
- -- redstone signal
- local width, length = term.getSize()
- function centerText(text,yCursor)
- local xPos =(width-string.len(text))/2
- term.setCursorPos(xPos, yCursor)
- write(text)
- end
- -------------------------
- -- MAIN MENU
- function nothingMenu()
- term.clear()
- term.setCursorPos(1,1)
- print("Nothing here yet")
- centerText("Click to go to menu", length-1)
- event = os.pullEvent("mouse_click")
- basicMenu()
- end
- function basicMenu()
- term.clear()
- centerText("Select subject", 1)
- centerText("Creating programs",5)
- centerText("Printing text", 7)
- centerText("Variables", 9)
- centerText("Another one", 11)
- centerText("Another one", 13)
- centerText("Reading errors", 15)
- local event, button, clickX, clickY = os.pullEvent("mouse_click")
- if clickY == 5 then
- fileMenu()
- elseif clickY == 7 then
- textMenu()
- elseif clickY == 9 then
- nothingMenu()
- elseif clickY == 11 then
- nothingMenu()
- elseif clickY == 13 then
- nothingMenu()
- elseif clickY == 15 then
- debugMenu()
- end
- end
- function fileMenu()
- term.clear()
- term.setCursorPos(1,1)
- print("To edit a file type edit [file name] without the square brackets. This will open the file. If the file doesn't exist yet, a file with the chosen name will be made.")
- print(" ")
- print("To save a file hit ctrl to bring up the menu. You can chose using the arrow keys and select by hitting enter.")
- print(" ")
- print("To run a program, enter the file name and hit enter.")
- centerText("Right click to go back", length-1)
- centerText("Left clcik to continue", length)
- local event, button = os.pullEvent("mouse_click")
- if button == 1 then
- fileMenu2()
- elseif button == 2 then
- basicMenu()
- end
- end
- function fileMenu2()
- term.clear()
- term.setCursorPos(1,1)
- print("To see available programs type 'ls' at a start screen")
- print(" ")
- print("To exit a program hold ctrl+t, or ctrl+r to reboot the computer")
- print(" ")
- print("When editing a file each line will count as one action in the program")
- print(" ")
- print("Anything written on a line starting with ''--'' will not be considered code.")
- print(" ")
- print("Command words are case sensitive")
- print(" ")
- print("Using the sleep() command will make the program wait a number of seconds specified by a number in the brackets. sleep(2) will make it wait two seconds")
- centerText("Right click to go back", length-1)
- centerText("left click for menu", length)
- local event, button = os.pullEvent("mouse_click")
- if button == 1 then
- basicMenu()
- elseif button == 2 then
- fileMenu()
- end
- end
- function textMenu()
- term.clear()
- term.setCursorPos(1,1)
- print("To make the program print a text use the command print(''your text''). It will look like this:")
- print(" ")
- print("your text")
- centerText("Right click for menu", length-1)
- centerText("Left clik to continue", length)
- local event, button = os.pullEvent("mouse_click")
- if button == 1 then
- term.clear()
- term.setCursorPos(1,1)
- print("You can also make the text roll in slowly by using the command textutils.slowPrint(''your text''). It will look like this:")
- print(" ")
- sleep(3)
- textutils.slowPrint("your text")
- centerText("Right click for menu", length-1)
- centerText("Left clik to continue", length)
- elseif button == 2 then
- basicMenu()
- end
- local event, button = os.pullEvent("mouse_click")
- if button == 1 then
- term.clear()
- term.setCursorPos(1,1)
- print("Or you can have the text centered by setting the cursor position: term.setCursorPos(x,y). Like this:")
- centerText("your text", length-10)
- elseif button == 2 then
- basicMenu()
- end
- while true do
- centerText("Right click for menu", length-1)
- local event, button = os.pullEvent("mouse_click")
- if button == 2 then
- basicMenu()
- end
- end
- end
- function debugMenu()
- term.clear()
- term.setCursorPos(1,1)
- print("If you make a mistake in a code you will get an error when running the program.")
- print("It will show the following information")
- print("bios:336: [string ''program name'']:line the error occurs in: Type of error")
- print(" ")
- print("The name of the program you're trying to run, what line the error occurs in and what type of error is occuring.")
- centerText("Click to continue", length-1)
- local event, button = os.pullEvent("mouse_click")
- term.clear()
- term.setCursorPos(1,1)
- centerText("Common errors:", 1)
- term.setCursorPos(1,2)
- print(" ")
- print("bios:366:[string ''Test'']:5: unfinished string")
- print(" ")
- print("There's an unfinished string in line 5 of the program Test")
- print("To fix, add '' at the end of your string.")
- centerText("Click to continue", length-1)
- local event, button = os.pullEvent("mouse_click")
- term.clear()
- term.setCursorPos(1,1)
- print("bios:366: [string ''test'']:3: ')' expected")
- print(" ")
- print("You haven't finished a command in line 3, and the program is expecting a ')' at the end")
- centerText("Click to continue", length-1)
- local event, button = os.pullEvent("mouse_click")
- term.clear()
- term.setCursorPos(1,1)
- print("bios:366: [string ''test'']:6: unexpected symbol")
- print(" ")
- print("You have used an unexpected symbol in line 6.")
- centerText("Click to continue", length-1)
- local event, button = os.pullEvent("mouse_click")
- term.clear()
- term.setCursorPos(1,1)
- print("bios:366: [string ''test'']:6: 'end' expected (to close 'if' at line 4)")
- print(" ")
- print("You have an unfinished if loop starting at line 4 and ending at line 6. You need to add an 'end'.")
- centerText(" Right click to go to menu", length-1)
- while true do
- local event, button = os.pullEvent("mouse_click")
- if button == 2 then
- mainMenu()
- end
- end
- end
- function mainMenu()
- term.clear()
- centerText("Select difficulty",1)
- centerText("Basic", 5)
- centerText("Advanced", 9)
- local event, button, clickX, clickY = os.pullEvent("mouse_click")
- if clickY >= 4 and clickY <=6 then
- basicMenu()
- elseif clickY >= 8 and cluckY <=10 then
- advancedMenu()
- end
- end
- -- LOOP
- mainMenu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement