Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.unloadAPI("gui")
- os.loadAPI("gui")
- function waitMouse()
- while true do
- local 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 firstFunction()
- term.setBackgroundColor(colors.black)
- term.clear()
- local progBar = gui.createBar("bar")
- progBar:draw(15, 8, 20, colors.white, colors.blue, true, colors.black, colors.white)
- for i = 1, 100 do
- progBar:update(i)
- sleep(0.05)
- end
- local dBox = gui.createDialogueBox("Finished!", "The progressbar is full!", "ok")
- dBox:draw(12,6,5,colors.lightGray, colors.gray, colors.white)
- end
- function secondFunction()
- term.setBackgroundColor(colors.black)
- term.clear()
- local userinput = gui.newTextBox(20,10,20, colors.white, colors.black)
- local dBox = gui.createDialogueBox("Really?", {"Did you really write this:", string.char(34) .. userinput .. string.char(34) .. "?"}, "yn")
- local result = dBox:draw(12,6,6,colors.lightGray, colors.gray, colors.white)
- if result == true then
- print("Great. Awesome!")
- else
- print("Not cool! Really not cool!")
- end
- sleep(3)
- end
- function main()
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- term.setCursorPos(1,1)
- local firstButton = gui.createButton("First ", firstFunction)
- local secondButton = gui.createButton("Second", secondFunction)
- firstButton:draw(20, 3, 3, colors.red, colors.white)
- secondButton:draw(20, 9, 3, colors.green, colors.white)
- local clicked = waitMouse()
- firstButton:remove()
- secondButton:remove()
- if clicked == "First " then
- firstFunction()
- elseif clicked == "Second" then
- secondFunction()
- end
- end
- while true do
- main()
- end
Advertisement
Add Comment
Please, Sign In to add comment