Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function FindAndEnableAirGens(onOrOff)
- local sides = peripheral.getNames()
- print("Found " .. tostring(table.getn(sides)) .. " peripherals")
- local airgenNum = 0
- for _, side in pairs(sides) do
- if peripheral.getType(side) == "warpdriveAirGenerator" then
- local p = peripheral.wrap(side)
- if p.isInterfaced() then
- airgenNum = airgenNum + 1
- p.enable(onOrOff)
- local eA, eF, units = p.getEnergyStatus()
- if (eA * 100 / eF) < 50 then
- local x, y, z = p.getLocalPosition()
- print("Airgen at " .. tostring(x) .. "; " .. tostring(y) .. "; " .. tostring(z) .. " has poor power supply")
- end
- else
- print("Found uninterfaced airgen " .. tostring(side))
- end
- end
- end
- print("Set enabled to " .. tostring(onOrOff) .. " for " .. tostring(airgenNum) .. " airgens")
- end
- term.clear()
- term.setCursorPos(1,1)
- while true do
- print("E to enable, D to disable, Q to quit")
- local event, key = os.pullEvent("key")
- if key == keys.e then
- FindAndEnableAirGens(true)
- elseif key == keys.d then
- FindAndEnableAirGens(false)
- elseif key == keys.q then
- return
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement