Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Load API's
- os.loadAPI("touchpoint")
- os.loadAPI("bigfont")
- -- Load monitor and make sure everything gets displayed there
- local monitor = peripheral.wrap("back")
- term.redirect(monitor)
- term.setBackgroundColor(colors.black)
- term.clear()
- local x, y = monitor.getSize()
- -- Variables
- local mainButtonWidth = 20
- local mainButtonHeight = 6
- local screen = "main"
- -- Create touchpoint and buttons
- ---- Main
- mainT = touchpoint.new("back")
- mainT:add("DONE", nil, math.ceil((x/2) - (mainButtonWidth/2)), y - (mainButtonHeight/2) - 2, math.ceil((x/2) + (mainButtonWidth/2)), y - 2, colors.white, colors.white, colors.black, colors.black)
- mainT:add("DEPOSIT", nil, math.ceil((x/2) - (mainButtonWidth/2)), y - (mainButtonHeight/2) - 8, math.ceil((x/2) + (mainButtonWidth/2)), y - 8, colors.green, colors.green, colors.black, colors.black)
- mainT:add("PAYOUT", nil, math.ceil((x/2) - (mainButtonWidth/2)), y - (mainButtonHeight/2) - 14, math.ceil((x/2) + (mainButtonWidth/2)), y - 14, colors.red, colors.red, colors.black, colors.black)
- ---- Deposit
- depositT = touchpoint.new("back")
- depositT:add("DONE", nil, math.ceil((x/2) - (mainButtonWidth/2)), y - (mainButtonHeight/2) - 2, math.ceil((x/2) + (mainButtonWidth/2)), y - 2, colors.white, colors.white, colors.black, colors.black)
- ---- Payout
- payoutT = touchpoint.new("back")
- payoutT:add("DONE", nil, math.ceil((x/2) - (mainButtonWidth/2)), y - (mainButtonHeight/2) - 2, math.ceil((x/2) + (mainButtonWidth/2)), y - 2, colors.white, colors.white, colors.black, colors.black)
- -- Button Functions
- function done()
- if screen == "main" then
- screen = "start"
- else
- screen = "main"
- mainScreen()
- end
- end
- function deposit()
- screen = "deposit"
- depositScreen()
- end
- function payout()
- screen = "payout"
- payoutScreen()
- end
- --Screens
- function mainScreen()
- while screen == "main" do
- mainT:draw()
- term.setCursorPos(1, 1)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.setCursorPos(math.ceil((x/2) - #"WELCOME"), 5)
- bigfont.bigWrite("WELCOME")
- local event, p1 = mainT:handleEvents(os.pullEvent())
- term.setCursorPos(1,1)
- term.write(event)
- if event == "button_click" then
- if p1 == "DONE" then
- done()
- elseif p1 == "DEPOSIT" then
- deposit()
- elseif p1 == "PAYOUT" then
- payout()
- end
- end
- end
- end
- function depositScreen()
- while screen == "deposit" do
- depositT:draw()
- term.setCursorPos(1, 1)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.setCursorPos(math.ceil((x/2) - #"DEPOSIT"), 5)
- bigfont.bigWrite("DEPOSIT")
- local event, p1 = depositT:handleEvents(os.pullEvent())
- if event == "button_click" then
- if p1 == "DONE" then
- done()
- end
- end
- end
- end
- function payoutScreen()
- while screen == "payout" do
- payoutT:draw()
- term.setCursorPos(1, 1)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.setCursorPos(math.ceil((x/2) - #"PAYOUT"), 5)
- bigfont.bigWrite("PAYOUT")
- local event, p1 = payoutT:handleEvents(os.pullEvent())
- if event == "button_click" then
- if p1 == "DONE" then
- done()
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment