This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
WolfyXK's profile picture

Computronics Christmas Tree Lights

Started by WolfyXK, 23 December 2015 - 09:43 PM
WolfyXK #1
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.

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
DannySMc #2
Posted 25 December 2015 - 12:19 AM
Nice, very festive! :D/>
WolfyXK #3
Posted 25 December 2015 - 01:15 AM
You can see the factory that the christmas tree is housed in if anyone is interested :)/>

http://www.computercraft.info/forums2/index.php?/topic/25472-merry-christmas-from-my-cc-controlled-factory/