Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local buttons = {}
- local function createButton(name,startX,endX,startY,endY, offset, color)
- buttons[name] = {["startX"] = startX, ["endx"] = endX, ["startY"] = startY, ["endY"] = endY}
- term.setCursorPos(startX, startY)
- paintutils.drawFilledBox(startX-offset, startY-offset, endX+offset, endY+offset, color)
- print(name)
- end
- local function check(x,y)
- for key, value in pairs(buttons) do
- if value["startX"] <= x and value["endX"] >= x and value["startY"] >= y and value["endY"] <= y then
- return key
- end
- end
- end
- createButton("Reboot", 5, 10, 5, 10, 0, colors.green)
- local event, button, x, y = os.pullEvent("mouse_click")
- local clicked = check(x,y)
- if clicked == "Reboot" then
- os.reboot()
- end
Advertisement
Add Comment
Please, Sign In to add comment