Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local lightPeriphNames = {}
- local lightPeriphs = {}
- local black = 0
- local white = 0xFFFFFF
- local gray = 0xBBBBBB
- local yellow = 0xFFFF00
- local blue = 0x0000FF
- function getPeripherals(type)
- for _, name in pairs(peripheral.getNames()) do
- if peripheral.getType(name) == type then
- table.insert(lightPeriphNames, name)
- end
- end
- end
- function initLightPeriphs()
- for i = 1, #lightPeriphNames do
- lightPeriphs[i] = peripheral.wrap(lightPeriphNames[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 allColor(color)
- for i = 1, #lightPeriphs do
- light(i, color)
- 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
- function main()
- getPeripherals("cofh_thermalexpansion_lamp")
- initLightPeriphs()
- math.randomseed( os.time() )
- local t = 0
- local rnd = 0
- allColor(blue)
- while (true) do
- if (os.time() - 1) > t then
- t = os.time()
- rnd = math.random(1,4)
- end
- if rnd == 1 then
- allColor(blue)
- sleep(5)
- elseif rnd == 2 then
- allColor(yellow)
- sleep(5)
- elseif rnd == 3 then
- local max = math.random(1, 20)
- for i = 1, max do
- allColor(yellow)
- sleep(0.5)
- allColor(blue)
- sleep(0.5)
- end
- elseif rnd == 4 then
- end
- sleep(0.2)
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement