Guest User

MainInterface

a guest
Mar 16th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.74 KB | None | 0 0
  1. local buttons = {}
  2.  
  3. local function createButton(name,startX,endX,startY,endY, offset, color)
  4.   buttons[name] = {["startX"] = startX, ["endx"] = endX, ["startY"] = startY, ["endY"] = endY}
  5.   term.setCursorPos(startX, startY)
  6.   paintutils.drawFilledBox(startX-offset, startY-offset, endX+offset, endY+offset, color)
  7.   print(name)
  8. end
  9.  
  10. local function check(x,y)
  11.   for key, value in pairs(buttons) do
  12.         if value["startX"] <= x and value["endX"] >= x and value["startY"] >= y and value["endY"] <= y then
  13.           return key
  14.         end
  15.   end
  16. end
  17.  
  18. createButton("Reboot", 5, 10, 5, 10, 0, colors.green)
  19.  
  20. local event, button, x, y = os.pullEvent("mouse_click")
  21. local clicked = check(x,y)
  22. if clicked == "Reboot" then
  23. os.reboot()
  24. end
Advertisement
Add Comment
Please, Sign In to add comment