Failip420

touch.lua

Dec 28th, 2020 (edited)
868
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.66 KB | None | 0 0
  1. os.loadAPI("api/ButtonAPI.lua")
  2. m = peripheral.find("monitor")
  3. txt = "On"
  4. tx2 = "Off"
  5. textcolor = colors.white
  6. textbgcolor = colors.lime
  7.  
  8. term.clear()
  9.  
  10. function func1(text)
  11.     print("On")
  12. end
  13.  
  14. function func2(text)
  15.     print("Off")
  16. end
  17.  
  18. function Draw()
  19.     ButtonAPI.New(math.floor(w/2), 1, txt, func1, m, textcolor, textbgcolor)
  20.     ButtonAPI.New(math.floor(w/2), 2, tx2, func2, m, textcolor, textbgcolor)
  21. end
  22.  
  23. if m then
  24.     m.clear()
  25.     term.setCursorPos(1, 1)
  26.     print("Running Touch")
  27.     w,h = m.getSize()
  28.     while true do
  29.         Draw()
  30.     end
  31. else
  32.     term.clear()
  33.     term.setCursorPos(1,1)
  34.     print("No Monitors Found!")
  35. end
Add Comment
Please, Sign In to add comment