Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local deviceName = "fluxnetworks:flux_plug_2" -- adapte avec le nom exact
- local plug = peripheral.wrap(deviceName)
- local monitor = peripheral.find("monitor")
- if not plug or not monitor then
- print("Périphérique ou écran non détecté")
- return
- end
- monitor.clear()
- monitor.setTextScale(1)
- local previousEnergy = plug.getEnergy()
- local delay = 5 -- secondes entre chaque mesure
- while true do
- local currentEnergy = plug.getEnergy()
- local capacity = plug.getEnergyCapacity()
- local energyChange = currentEnergy - previousEnergy
- previousEnergy = currentEnergy
- local consumption = -energyChange / delay -- consommation approximative (RF/s)
- monitor.clear()
- monitor.setCursorPos(1,1)
- monitor.write("Flux Plug Energy Monitor")
- monitor.setCursorPos(1,3)
- monitor.write(string.format("Energie: %d / %d RF", currentEnergy, capacity))
- monitor.setCursorPos(1,5)
- monitor.write(string.format("Consommation: %.2f RF/s", consumption))
- os.sleep(delay)
- end
Advertisement
Add Comment
Please, Sign In to add comment