Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Gui = {
- version="0.0.3",
- buttons={}
- }
- function Gui.newButton(name, x, y, width, height, text)
- local button = {
- name=name,
- x=x,
- y=y,
- width=width,
- height=height,
- text=text,
- color=colors.white,
- textColor=colors.black,
- clickColor=colors.gray,
- baseColor=colors.white
- }
- table.insert(Gui.buttons, button)
- end
- function Gui.drawButtons()
- for i,button in ipairs(Gui.buttons) do
- paintutils.drawFilledBox(button.x, button.y, button.x+button.width-1, button.y+button.height-1, button.color)
- term.setTextColor(button.textColor)
- term.setCursorPos(button.x, math.ceil((button.height/2) + button.y - 1))
- term.write(button.text)
- end
- end
- function Gui.buttonPressed(x,y)
- for i,button in ipairs(Gui.buttons) do
- if ((x >= button.x and x <= button.x+button.width-1) and (y >= button.y and y <= button.y+button.height-1)) then
- return button
- end
- end
- return null
- end
- return Gui
Advertisement
Add Comment
Please, Sign In to add comment