Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // By Selim
- // Uses Computronics Colorful Lamps with ComputerCraft
- peripheralType = "colorful"
- monitor = peripheral.find("monitor")
- periph = peripheral.getNames()
- running = true
- function mysplit(inputstr, sep)
- if sep == nil then
- sep = "%s"
- end
- local t={} ; i=1
- for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
- t[i] = str
- i = i + 1
- end
- return t
- end
- l = 1
- lamps = {}
- for i = 1, #periph do
- type = mysplit(periph[i], "_")
- if type[1] == peripheralType then
- lamps[l] = peripheral.wrap(periph[i])
- l = l + 1
- end
- end
- while running do
- monitor.setTextScale(2)
- monitor.print("What lamp color?")
- in = read()
- color = tonumber(in)
- if type(color) == "number" then
- for i = 1, #lamps do
- lamps[i].setLampColor(color)
- end
- elseif in == "exit" then
- running = false
- else
- print("Invalid entry")
- sleep(2)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement