Posted 23 December 2015 - 10:43 PM
Thats the program finally done now. Big thanks to Lupus590, zguystudios and Dragon53535 for helping me out.
This program is designed to make any connected colorful lamps from the computronics mod flash in random colours.
Make sure you connect all the colorful lamps you are going to use to the computer using wired modems.
This program is designed to make any connected colorful lamps from the computronics mod flash in random colours.
Make sure you connect all the colorful lamps you are going to use to the computer using wired modems.
pastebin get bJ0j2NYT lights
print("|WolfOS| Christmas Light Controller")
local tbl = {} -- Declare tbl as a table to store lamps in
--#Find and automatically wrap lights.
for a,v in pairs(peripheral.getNames()) do -- Start loop
if (peripheral.getType(v) == "colorful_lamp" ) then -- If lights are detected then continue
tbl[#tbl + 1] = peripheral.wrap(v) -- Add lamps to table
end
end
while true do -- Start loop
local color = math.random(0,32767) -- Chooses a random colour
local random = math.random(1,#tbl) -- Select a lamp at random
tbl[random].setLampColor(color) -- Set selected lamp to random colour
print("Lamp " .. random .. " changed to color " .. color) -- Print selected lamp and colour it has been changed to
sleep(0.5) -- Wait half a second then change the next lamp
end