9551

Untitled

Jun 12th, 2021 (edited)
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.70 KB | None | 0 0
  1. ---light switcher by elektrobom1---
  2.  
  3. local l = require("CLamp")
  4. local arg = {...}
  5. local per = peripheral.getNames()
  6. local num = 1
  7. local max = 0
  8. local tpos = {term.getCursorPos()}
  9.  
  10. for i = 1, #per do
  11.     if peripheral.getType(per[i]) == "colorful_lamp" then
  12.         max = max + 1
  13.     end
  14. end
  15.  
  16. for i = 1, #per do
  17.     if peripheral.getType(per[i]) == "colorful_lamp" then
  18.         term.setCursorPos(tpos[1], tpos[2]-1)
  19.         print("setting lamp: " .. num .. "/" .. max .. " to: " .. "R:" .. arg[1] .. " G:" .. arg[2] .. " B:" .. arg[3])
  20.         peripheral.call(per[i], "setLampColor", l.rgb(tonumber(arg[1]), tonumber(arg[2]), tonumber(arg[3])))
  21.         num = num + 1
  22.     end
  23. end
  24. print("finished")
  25.  
Add Comment
Please, Sign In to add comment