Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local back = colors.blue
- local button = colors.green
- local text = colors.black
- function draw()
- term.setTextColor(text)
- term.setBackgroundColor(back)
- term.clear()
- for i,v in pairs(buttons) do
- term.setBackgroundColor(button)
- term.setCursorPos(v[2],v[3])
- write(v[1])
- end
- term.setBackgroundColor(back)
- end
- buttons = {}
- buttons[1] = {} --create a new button
- buttons[1][1] = "Test"-- button title
- buttons[1][2] = 3 --button x
- buttons[1][3] =10 --buttons y
- buttons[1][4] = function() --function if the button is pressed
- print("Button 1 pressed")
- end
- draw()
- while true do
- local evt,b,x,y = os.pullEvent("mouse_click")
- for i,v in pairs(buttons) do
- if v[2] <= x and v[2] + #v[1] >= x and v[3] == y then
- v[4]()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement