Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mon = peripheral.wrap("top")
- local t = {text = "help", ymin = 1, ymax = 6, xmin = 8, xmax = 30, txCol = colours.black, bgCol = colours.lime}
- function writeButton(_table)
- for i,v in pairs(_table) do
- ytxt = (v.ymin + v.ymax) / 2
- xtxt = (v.xmin + v.xmax) / 2 - string.len(v.text)
- mon.setCursorPos(xtxt, ytxt)
- mon.write(v.text)
- mon.setTextColour(v.txCol)
- mon.setBackgroundColour(v.bgCol)
- end
- end
- function isValidClick(_table, mx, my)
- for i, v in pairs(_table) do
- if mx <= v.xmax and mx >= v.xmin and my <= v.ymax and my >= v.ymin then
- f = v.text
- end
- return false
- end
- end
- writeButton(t)
- while true do
- event, but, x, y = os.pullEvent("monitorTouch")
- isValidClick(t, x, y)
- if f == help then
- mon.print('hellp')
- end
- end
Add Comment
Please, Sign In to add comment