Guest User

Untitled

a guest
Jan 15th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. --[Menu Commands]]---
  2.  
  3. local function hey()
  4. print("hi")
  5. end
  6.  
  7. local function hi()
  8. print("Awesome")
  9. end
  10.  
  11. --[[Menu Table]]--
  12.  
  13. buttons = {
  14. [1] = {buttonType = 1, buttonX = 1, buttonY = 1, command = hey},
  15. [2] = {buttonType = 1, buttonX = 2, buttonY = 2, command = hi},
  16. [3] = {buttonType = 2, buttonX = 3, buttonY = 3, command = hey}
  17. }
  18.  
  19. --[[Menu Functions]]--
  20.  
  21. function button(table)
  22. while true do
  23. event, p1, p2, p3 = os.pullEvent()
  24. for k,v in ipairs(table) do
  25. if table[k].buttonType == p3 then
  26. if table[k].buttonX == p1 and table[k].buttonY == p2 then
  27. table[k].command()
  28. end
  29. end
  30. end
  31. end
  32. end
  33.  
  34. --[[Main Program]]--
  35.  
  36. term.clear()
  37. term.setCursorPos(1,1)
  38. write("#")
  39. term.setCursorPos(2,2)
  40. write("@")
  41. term.setCursorPos(1,3)
  42. button(buttons)
Add Comment
Please, Sign In to add comment