Guest User

tet

a guest
Dec 17th, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.69 KB | None | 0 0
  1. os.loadAPI("button")
  2. buttons = {}
  3. --putting buttons into a table
  4. table.insert(buttons, button.cButton(1,5,1,4))
  5. table.insert(buttons, button.cButton(1,5,5,8))
  6.  
  7.  
  8.  
  9. -- drawing the buttons
  10. function dBox(x,y)
  11.   for i = 1, y do
  12.     for z = 1, x-1 do
  13.       term.write(" ")
  14.     end
  15.     print(" ")
  16.   end
  17. end
  18.  
  19. term.clear()
  20. term.setBackgroundColor(colors.blue)
  21. term.setCursorPos(1,1)
  22. dBox(5,4)
  23. term.setCursorPos(1,5)
  24. term.setBackgroundColor(colors.orange)
  25. dBox(5,4)
  26.  
  27.  
  28.  
  29. -- part of example
  30. _,_,x,y = os.pullEvent()
  31. but = button.check(buttons,x,y)
  32.  
  33. if but == 1 then
  34.   term.setCursorPos(15, 10)
  35.   print("hi")
  36. elseif but == 2 then
  37.   term.setCursorPos(15, 10)
  38.   print("button2")
  39. end
Advertisement
Add Comment
Please, Sign In to add comment