Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local lamps = {}
- for _, n in pairs(peripheral.getNames()) do
- local num = tonumber(n:match "colorful_lamp_(%d+)")
- if num then lamps[num] = peripheral.wrap(n) end
- end
- local numlamps = #lamps
- local cell = peripheral.find "rftoolspower:cell3"
- local function get_level()
- return cell.getRFStored() / cell.getRFCapacity()
- end
- while true do
- local lvl = get_level()
- local on_color = 31744
- local off_color = 0
- if lvl > 0.2 then
- on_color = 32736
- end
- if lvl > 0.5 then
- on_color = 992
- end
- for index, periph in pairs(lamps) do
- local place = index / numlamps
- if place < lvl then
- periph.setLampColor(on_color)
- else
- periph.setLampColor(off_color)
- end
- end
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement