Lucrecio

Turn On lamps

Apr 16th, 2022
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. ---- Basic stuff ----
  2. term.redirect(peripheral.wrap("top"))
  3. local monitor = peripheral.wrap("top")
  4. monitor.clear()
  5. monitor.setCursorPos(1,1)
  6. monitor.setBackgroundColor(colors.black)
  7. monitor.setTextSize(0.5)
  8.  
  9. -- Setting up modem --
  10. local modem = peripheral.wrap("back")
  11. local event , side, channel , replychannel , message, distance
  12.  
  13. -- Setting button --
  14.  
  15. paintutils.drawFilledBox(3,3,13,8,colors.white)
  16. term.blit("Switch","ffffff","000000")
  17.  
  18.  
  19. ---- General functions ----
  20.  
  21. function between ( value , lowest , highest )
  22.  
  23. if value >= lowest and value <= highest then
  24. booly= true
  25. else
  26. booly= false
  27. end
  28. return booly
  29. end
  30.  
  31. -- Switch light --
  32.  
  33. switchlight()
  34. local bool = true
  35. modem.transmit(10,11,bool)
  36. end
  37.  
  38. -- Setting variables --
  39.  
  40.  
  41. ---- Open Main Menu first time (important) ----
  42.  
  43. -- "While true" start --
  44. while true do
  45. --Monitor touch event--
  46. local event, side, x, y = os.pullEvent(monitor_touch)
  47.  
  48.  
  49.  
  50. -- Example menu button & Back button--
  51. if side=="top" and between(x,3,13) and between(y,3,8) then
  52. switchlight()
  53. end
  54.  
  55.  
  56. end
Advertisement
Add Comment
Please, Sign In to add comment