Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
-- Assign the monitor to the 'monitor' variable (assuming it's connected on the right) local monitor = peripheral.wrap("right") local redstoneSide = "back" -- Define the redstone side where the signal will be output local updateRate = 1 -- Set the text scale on the monitor monitor.setTextScale(0.8) -- Function to find an IC2 energy storage block local function findIC2Storage() local storageTypes = { "batbox", "cesu", "mfe", "mfsu" } for _, storageType in ipairs(storageTypes) do local storage = peripheral.find(storageType) if storage then return storage, storageType:upper() end end return nil, nil end -- Function to format EU values local function formatEU(energy) if energy >= 1000000 then return string.format("%.1f M EU", energy / 1000000) elseif energy >= 1000 then return string.format("%.1f k EU", energy / 1000) else return string.format("%.0f EU", energy) end end local storage, storageType = findIC2Storage() -- Track last stored value for rate/direction local lastStored = { amount = 0, name = "Unknown" } local function displayStorageInfo() if not storage then print("IC2 storage block not found.") return end -- Get current stored energy and maximum capacity local maxEnergy = storage.getCapacity() local currentEnergy = storage.getStored() local filledPercentage = (currentEnergy / maxEnergy) * 100 -- Calculate change in energy since last update local change = currentEnergy - lastStored.amount local direction = "stable" local directionVerb = "stable" if change > 0 then direction = "increasing" directionVerb = "fill" elseif change < 0 then direction = "decreasing" directionVerb = "empty" end -- Output redstone signal based on energy level if filledPercentage < 25 then redstone.setOutput(redstoneSide, true) elseif filledPercentage > 75 then redstone.setOutput(redstoneSide, false) end -- Update last known stored amount lastStored.amount = currentEnergy lastStored.name = storageType -- Clear monitor screen monitor.clear() monitor.setCursorPos(1, 1) -- Display info monitor.write(string.format("Showing Data For [%s]", storageType)) monitor.setCursorPos(1, 2) monitor.write(string.format("Capacity : %s", formatEU(maxEnergy))) monitor.setCursorPos(1, 3) monitor.write(string.format("Stored : %s", formatEU(currentEnergy))) monitor.setCursorPos(1, 4) if filledPercentage < 25 then monitor.setTextColour(colours.red) end monitor.write(string.format("Filled : %.2f%%", filledPercentage)) monitor.setTextColour(colours.white) monitor.setCursorPos(1, 5) monitor.write(string.format("Direction: %s by %.0f EU", direction, math.abs(change))) end -- Main loop while true do displayStorageInfo() os.sleep(updateRate) end
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)