Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --JDA Tools GUI By: JdogAwesome
- os.unloadAPI("gui")
- os.loadAPI("gui")
- local disk = "disk2" --Replace "disk2" with whatever your disk is called when you type in "dir"
- function waitMouse()
- while true do
- ev,mb,x,y = os.pullEvent("mouse_click")
- if (mb == 1 and gui.detect(x,y, false) ~= nil) then
- return gui.detect(x,y, false)
- end
- end
- end
- function gamesFunc()
- term.setBackgroundColor(colors.black)
- term.clear()
- firstButton:remove()
- secondButton:remove()
- gamesButton:remove()
- exitButton2 = gui.createButton("Exit")
- tronButton = gui.createButton("Tron", tronGame)
- flappyButton = gui.createButton("Flappy Pixel", flappyGame)
- tronButton:draw(23, 2, 3, colors.blue, colors.black)
- flappyButton:draw(22, 6, 3, colors.blue, colors.black)
- exitButton2:draw(2, 1, 3, colors.blue, colors.black)
- clicked2 = waitMouse()
- if clicked2 == "Tron" then
- tronButton:remove()
- mazeButton:remove()
- exitButton2:remove()
- tronGame()
- end
- if clicked2 == "Flappy Pixel" then
- tronButton:remove()
- flappyButton:remove()
- exitButton2:remove()
- flappyGame()
- end
- if clicked2 == "Exit" then
- tronButton:remove()
- mazeButton:remove()
- exitButton2:remove()
- end
- end
- function tronGame()
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(10,10)
- env = {}
- os.run(env,"Tron")
- end
- function flappyGame()
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(10,10)
- env2 = {}
- os.run(env2,"FlappyPixel")
- end
- function pastebinGet()
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(10,10)
- print("What you want to name the file:")
- local filename = gui.newTextBox(15,13,20, colors.red, colors.black)
- term.setCursorPos(10,15)
- print("Pastebin URL thing, example: KwJ87j7A")
- local pastebinUrl = gui.newTextBox(15,16,20, colors.red, colors.black)
- shell.run("pastebin get ",pastebinUrl, filename)
- sleep(2)
- end
- function diskCopy()
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(10,10)
- print("Name of file to copy to disk: ")
- local userinput = gui.newTextBox(15,16,20, colors.white, colors.black)
- shell.run("cp",userinput, disk)
- sleep(3)
- end
- function exitProgram()
- term.clear()
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.black)
- term.setCursorPos(1,1)
- term.clear()
- error()
- end
- function main()
- term.setBackgroundColor(colors.blue)
- term.clear()
- term.setCursorPos(20,2)
- term.setTextColor(colors.white)
- print("JDA Tools")
- term.setCursorPos(2,19)
- print("By JdogAwesome")
- firstButton = gui.createButton("Pastebin Get ", pastebinGet)
- secondButton = gui.createButton("Disk Copy", diskCopy)
- exitButton = gui.createButton("Exit", exitProgram)
- gamesButton = gui.createButton("Games", gamesFunc)
- firstButton:draw(18, 3, 3, colors.red, colors.white)
- secondButton:draw(20, 9, 3, colors.orange, colors.white)
- exitButton:draw(2, 1, 3, colors.red, colors.black)
- gamesButton:draw(22, 15, 3, colors.green, colors.white)
- clicked = waitMouse()
- if clicked == "Pastebin Get " then
- pastebinGet()
- elseif clicked == "Disk Copy" then
- diskCopy()
- elseif clicked == "Exit" then
- exitProgram()
- elseif clicked == "Games" then
- gamesFunc()
- end
- end
- while true do
- main()
- end
- --Base code credits:
- --https://www.youtube.com/watch?v=-oXDm92KZRc
- --http://www.computercraft.info/forums2/index.php?/topic/18977-guiapi-simple-powerful-buttonsdialogue-boxes-text-boxes-and-more/
Add Comment
Please, Sign In to add comment