Advertisement
Pixxel124

CC click test

Mar 16th, 2023 (edited)
803
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.90 KB | None | 0 0
  1. closeBounds = {
  2.    ["xMin"] = 1,
  3.    ["xMax"] = 5,
  4.    ["yMin"] = 1,
  5.    ["yMax"] = 1
  6. }
  7.  
  8. function checkPos(x,y,bounds)
  9.    if x >= bounds.xMin and x <= bounds.xMax and y >= bounds.yMin and y <= bounds.yMax then
  10.       return true
  11.    else
  12.       return false
  13.    end
  14. end
  15.  
  16. function display()
  17.    term.clear()
  18.    term.setCursorPos(1,1)
  19.    print("close")
  20.    term.setCursorPos(1,3)
  21.    print("1")
  22.    term.setCursorPos(3,3)
  23.    print("2")
  24. end
  25.  
  26. function clickMenu()
  27.    display()
  28.    while true do
  29.       local event, button, x, y = os.pullEvent( "mouse_click" )
  30.  
  31.       if checkPos(x,y,closeBounds) then
  32.          return
  33.       elseif x == 1 and y == 3 then
  34.          picked = 1
  35.          term.setCursorPos(1,5)
  36.          print("picked " .. picked)
  37.       elseif x == 3 and y == 3 then
  38.          picked = 2
  39.          term.setCursorPos(1,5)
  40.          print("picked " .. picked)
  41.       end
  42.    end
  43. end
  44.  
  45. clickMenu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement