Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function find_energy_cube()
- local cube_names = {"Ultimate Energy Cube", "Elite Energy Cube", "Advanced Energy Cube", "Basic Energy Cube"}
- local cube = nil
- for cube_name in cube_names do
- cube = peripheral.find(cube_name)
- if cube != nil then
- break
- end
- end
- return cube
- end
- local cube = find_energy_cube()
- if cube == nil then
- print("No energy cube found!")
- exit()
- end
- local threshold_percent = 90
- local max_energy = cube.getMaxEnergy()
- local stored_energy = max_energy
- local stored_percent = stored_energy/max_energy
- local cable_side = "bottom"
- local color_separator = colors.red
- while true do
- -- Update values
- stored_energy = max_energy
- stored_percent = stored_energy/max_energy
- -- Change state accordingly
- if stored_percent > threshold_percent then
- redstone.setBundledOutput(cable_side, color_separator)
- else
- redstone.setBundledOutput(cable_side, 0)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement