Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tWidth,tHeight = term.getSize()
- function title(nameA)
- paintutils.drawLine(1,1,tWidth,1,colors.lime)
- paintutils.drawLine(1,2,tWidth,2,colors.lime)
- paintutils.drawLine(1,3,tWidth,3,colors.lime)
- paintutils.drawLine(1,4,tWidth,4,colors.lime)
- paintutils.drawLine(1,5,tWidth,5,colors.lime)
- paintutils.drawLine(1,6,tWidth,6,colors.lime)
- term.setTextColor(colors.black)
- term.setCursorPos(4,2)
- write(nameA)
- end
- function Button(label,line,alignment,bgColor,tColor)
- local button = {}
- button.label = label or " "
- button.bgColor = bgColor or colors.lightGray
- button.tColor = tColor or colors.cyan
- button.line = line or 1
- button.alignment = alignment
- button.width = 12
- if alignment == "left" then
- button.startXpos = math.floor(1+(#label/2))
- elseif alignment == "right" then
- button.startXpos = math.floor(43-(#label/2))
- end
- function button.draw()
- --correct for basic terminals
- if not term.isColor() then button.bgColor = colors.white end
- if not term.isColor() then button.tColor = colors.black end
- --draw button background
- if button.alignment == "left" then
- term.setCursorPos(2, button.line)
- term.setBackgroundColor(button.bgColor)
- write(string.rep(" ",button.width))
- elseif button.alignment == "right" then
- term.setCursorPos(37, button.line)
- term.setBackgroundColor(button.bgColor)
- write(string.rep(" ",button.width))
- end
- --draw button label
- term.setCursorPos(button.startXpos,button.line)
- term.setTextColor(button.tColor)
- write(label)
- --reset colours to default
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- end
- return button
- function button.clicked(column,row)
- return (column >= button.line and column < button.startXpos + button.width and row == button.line)
- end
- end
- buttons = {}
- buttons.balance = Button("Balance", 9, "left", colors.orange,colors.purple)
- buttons.withdraw = Button("Withdraw", 9, "right", colors.orange,colors.purple)
- buttons.deposit = Button("Deposit", 11, "left", colors.orange,colors.purple)
- buttons.transfer = Button("Transfer", 11, "right", colors.orange,colors.purple)
- buttons.quit = Button("Quit", 15, "right", colors.red,colors.lime)
- term.clear()
- title(",-.-. | || | \n | | |,---.,---|,---||---|,---.. .,---.,---.\n | | |,---|| || || || || | ---.|---'\n | | ||___||___||___|| ||___||___||___||___|")
- for key,button in pairs(buttons) do
- button.draw()
- end
- while true do
- event ={os.pullEvent("monitor_touch")}
- for key,button in pairs(buttons)
- if button.clicked(event[3],event[4]) then -- column,row
- break
- end
Advertisement
Add Comment
Please, Sign In to add comment