Advertisement
ccraftersanonmoose

wall lamp button control

Mar 16th, 2023 (edited)
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.82 KB | Gaming | 0 0
  1. -- Script to control a wall lamp
  2. -- written by craftersanonmoose
  3. -- version history
  4. -- version 0.1
  5. -- button control
  6. --------------------------------------------
  7.  
  8. os.loadAPI("button")
  9. mon = peripheral.wrap("monitor_8")
  10. mon.clear()
  11.  
  12. -- change name of these as needed
  13. ri = peripheral.wrap("redstoneIntegrator_1")
  14.  
  15.  
  16. function lightOn()
  17.     ri.setAnalogOutput("front", 15)
  18.     button.flash("Light")
  19. end
  20.  
  21. function lightOff()
  22.     ri.setAnalogOutput("front", 0)
  23.     button.flash("Light")
  24. end
  25.  
  26.  
  27. function fillTable()
  28.     button.setTable("On", lightOn, 2,8,3,5)
  29.     button.setTable("Off", lightOff, 10,16,3,5)
  30.     button.screen()
  31. end
  32.  
  33. function getClick()
  34.     event,side,x,y = os.pullEvent("monitor_touch")
  35.     button.checkxy(x,y)
  36. end
  37.  
  38. fillTable()
  39. button.heading("Light Control")
  40.  
  41. while true do
  42.     getClick()
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement