Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("lightList")
- local lightIDs = lightList.getLightIDs()
- local lightPeriphs = {}
- local black = 0
- local white = 0xFFFFFF
- local gray = 0xBBBBBB
- local redstoneSide = "top"
- function initLightPeriphs()
- for i = 1, #lightIDs do
- lightPeriphs[i] = peripheral.wrap("glowstone_illuminator_"..lightIDs[i])
- if lightPeriphs[i] == nil then
- print("Missing Light: " .. lightIDS[i])
- end
- end
- end
- function light(i, color)
- if i >= 1 and i <= #lightPeriphs then
- if (lightPeriphs[i] ~= nil) then
- lightPeriphs[i].setColor(color)
- else
- print("Light ID: " .. i .. " is null")
- end
- end
- end
- function allBlack()
- for i = 1, #lightIDs do
- light(i, black)
- end
- end
- function allWhite()
- for i = 1, #lightIDs do
- light(i, white)
- end
- end
- function LightChaser(offSet, whiteLightWidth, GreyLightWidth, blackLightWidth)
- currIndex = -50 + offSet
- while currIndex <= #lightIDs do
- for a = 1, whiteLightWidth do
- currIndex = currIndex + 1
- light(currIndex, white)
- end
- for b = 1, GreyLightWidth do
- currIndex = currIndex + 1
- light(currIndex, gray)
- end
- for c = 1, blackLightWidth do
- currIndex = currIndex + 1
- light(currIndex, black)
- end
- end
- end
- function lightChaserHelper(repeatNumber, sleepAmt, offSet, whiteLightWidth, GreyLightWidth, blackLightWidth)
- for i = 1, repeatNumber do
- LightChaser(i+offSet, whiteLightWidth, GreyLightWidth, blackLightWidth)
- sleep(sleepAmt)
- end
- end
- function lightToggle(toggleTimes, sleepAmt)
- for i = 1, toggleTimes do
- allBlack()
- sleep(sleepAmt)
- allWhite()
- sleep(sleepAmt)
- end
- end
- initLightPeriphs()
- function main()
- allBlack()
- while true do
- r,s = os.pullEvent()
- if r == "redstone" then
- v = redstone.getBundledInput(redstoneSide)
- print("V: " .. v)
- if v == 0 then
- allBlack()
- elseif v == 1 then
- allWhite()
- elseif v == 2 then
- lightChaserHelper(10, 0.2, 0, 5, 1, 7)
- elseif v == 3 then
- lightChaserHelper(10, 0.4 0, 3, 1, 5)
- elseif v == 4 then
- lightChaserHelper(10, 0.4 0, 2, 1, 3)
- elseif v == 5 then
- lightToggle(5, 0.25)
- elseif v == 6 then
- allBlack()
- local flag = true
- while flag do
- r2,s2 = os.pullEvent()
- if r == "redstone" then
- v2 = redstone.getBundledInput(redstoneSide)
- if v2 == 1 then
- allWhite()
- elseif v2 == 2 then
- allBlack()
- elseif v2 == 3 then
- flag = false
- end
- end
- end
- end
- end
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement