Advertisement
Guest User

rainbow.lua

a guest
Dec 11th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.66 KB | None | 0 0
  1. local component = require("component")
  2. local sides = require("sides")
  3. local rs = component.redstone
  4. local event = require("event")
  5.  
  6.  
  7. local goodColors = {[0]=1,2,3,4,5,6,9,10,11,13,14}
  8.  
  9. local c = 0
  10. local running = true
  11.  
  12. local colorSet = {[0]=2, 14, 1, 4, 13, 5, 3, 9, 11, 10}
  13.  
  14. local nextColor = 0
  15.  
  16. while running do
  17.  
  18.   local eventID = event.pull(.1, "key_down")
  19.   if (eventID) then
  20.     running = false;
  21.     break
  22.   end
  23.  
  24.   if (c > #colorSet) then
  25.     c = 0
  26.   end
  27.  
  28.   nextColor = colorSet[c]
  29.  
  30.   rs.setOutput(sides.left, nextColor)
  31.   rs.setOutput(sides.right, nextColor)
  32.   rs.setOutput(sides.front, nextColor)
  33.   rs.setOutput(sides.back, nextColor)
  34.  
  35.   c = c + 1
  36.   os.sleep(1)
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement