Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function AddButton(name,text,x,y,width,height,mainColor)
- buttons[name] = {name,text,x,y,width,height,mainColor}
- end
- function RemoveButton(name)
- buttons[name] = nil
- end
- function IsButtonPressed(name)
- value = buttons[name]
- uX = value[3]
- uY = value[4]
- bX = value[3] + value[5]
- bY = value[4] + value[6]
- if(uX <= xPos and xPos <= bX and uY <= yPos and yPos <= bY) then
- return true
- else
- return false
- end
- end
- function IsAnyButtonPressed()
- for key, value in pairs(buttons) do
- uX = value[3]
- uY = value[4]
- bX = value[3] + value[5]
- bY = value[4] + value[6]
- if(uX <= xPos and xPos <= bX and uY <= yPos and yPos <= bY) then
- return true
- else
- return false
- end
- end
- end
- function SetCurrentCursorPos(x,y)
- xPos = x
- yPos = y
- end
- function DrawButtons(d)
- term.redirect(d)
- for key, value in pairs(buttons) do
- --Draw Button box
- paintutils.drawFilledBox(value[3],value[4],value[3] + value[5], value[4] + value[6],value[7])
- --Set Cursor for text
- d.setCursorPos(value[3] + math.floor((value[5] - #value[2])/2),value[4] + math.floor(value[6]))
- d.write(value[2])
- end
- d.setCursorPos(0,0)
- term.redirect(term.native())
- end
- buttons = {}
- xPos = 0
- yPos = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement