Flux Networks · Addon guide · Advanced
Flux Network x CC: Tweaked Guide: Monitoring Power Grids with ComputerCraft
Integrating Flux Networks with CC: Tweaked allows you to build an automated, centralized control room for your wireless power grid. By wrapping Flux blocks as ComputerCraft peripherals, you can write Lua scripts to monitor real-time energy transfer rates, render dynamic status bars on Advanced Monitors, and automatically trigger backup generators before a blackout occurs.
What you need
- An active Flux Network with at least one Flux Plug, one Flux Point, and a Flux Storage unit (Basic, Herculean, or Gargantuan)
- A Flux Controller or an extra Flux Storage block to serve as the data access point
- 1x Advanced Computer (from CC: Tweaked)
- 4x to 8x Advanced Monitors (for a multi-block visual dashboard)
- Wired Modems and Networking Cables (if placing the computer away from the Flux block or generators)
- Basic familiarity with the Lua terminal and editing files in ComputerCraft
Step by step
1Establish the Peripheral Connection
Place your Advanced Computer directly adjacent to a Flux Storage block or a Flux Controller that is already linked to your primary energy network. If your control room is far from your energy core, attach a Wired Modem to the Flux block, another to the Advanced Computer, and connect them using Networking Cable. Right-click the Wired Modem on the Flux block to activate it; its border will glow red and the chat will display the exact peripheral name (for example, flux_storage_0).
Tip: Using a Flux Storage block as your peripheral node is ideal because it exposes both local buffer metrics and network-wide statistics.
2Construct the Monitor Array
Place your Advanced Monitors adjacent to one another to form a single large rectangular screen next to your Advanced Computer. If the screen is not directly touching the computer, connect it to the same Networking Cable line using another Wired Modem. Ensure the monitors merge into one seamless screen.
Tip: A 3-wide by 2-high monitor array provides enough character space to display both numerical values and a horizontal progress bar without text wrapping.
3Verify Available Peripheral Methods
Open the Advanced Computer interface and type 'lua' to enter the interactive prompt. Wrap your Flux block by typing 'f = peripheral.find("flux_storage")' or by passing its specific side or network name into 'peripheral.wrap()'. Type 'textutils.tabulate(peripheral.getMethods(peripheral.getName(f)))' to print a list of all supported functions for your exact mod version.
Tip: Depending on your Minecraft version and whether you use an addon bridge like Advanced Peripherals, method names may appear as getEnergy(), getEnergyStored(), or getNetworkInfo(). Always check the live output from getMethods() first.
4Create the Monitoring Script
Exit the Lua prompt by pressing Ctrl+T, then type 'edit startup.lua' to create a script that runs automatically when the computer boots. At the top of your file, initialize both peripherals using 'local flux = peripheral.find("flux_storage")' and 'local mon = peripheral.find("monitor")'. Configure the monitor text scale using 'mon.setTextScale(1)' and clear the screen.
Tip: Naming the script startup.lua ensures that when the chunk reloads or the server restarts, your dashboard resumes monitoring without manual intervention.
5Fetch and Format Network Metrics
Inside a 'while true do' loop, query the Flux peripheral for its current stored energy and maximum capacity. Compute the fill percentage by dividing current energy by maximum capacity and multiplying by 100. Because Gargantuan Flux Storage units can hold massive energy values, divide raw numbers by 1,000,000 to display them cleanly as Mega-FE (MFE) or by 1,000 for kFE using 'string.format("%.2f", value)'.
Tip: Always add a 'sleep(1)' or 'sleep(2)' command at the end of your while loop so the script yields properly and does not crash with a 'Too long without yielding' error.
6Draw a Visual Energy Bar on the Monitor
Still inside your loop, clear the monitor and print your formatted text at the top using 'mon.setCursorPos(1, 1)' and 'mon.write()'. To draw a graphical progress bar on line 3, get the monitor width with 'local w, h = mon.getSize()'. Calculate how many character cells should be filled based on your energy percentage, then set the background color using 'mon.setBackgroundColor(colors.green)' and write spaces across that exact number of cells before resetting the background to black.
Tip: Make the bar color dynamic: use colors.green when above 50%, colors.yellow between 20% and 50%, and colors.red when below 20%.
7Automate Backup Generator Triggers
In the same loop, add a conditional check for your energy percentage. Write an if-statement that checks if the storage drops below 15 percent: 'if percent < 15 then rs.setOutput("back", true) elseif percent > 90 then rs.setOutput("back", false) end'. Run a redstone line from the back of the Advanced Computer to your backup generator's activation port or to a Flux Plug's redstone control mode.
Tip: Using a low threshold (15%) to turn on and a high threshold (90%) to turn off creates a hysteresis loop, preventing your backup generators from rapidly flickering on and off.
How it works
Flux Networks maintains a centralized data table for each wireless network, tracking total buffer capacity, real-time input from Flux Plugs, and real-time output through Flux Points. When CC: Tweaked is installed alongside Flux Networks, individual network blocks act as TileEntity bridges that expose this internal Java data to the ComputerCraft Lua environment.
When your script executes a peripheral call, ComputerCraft queries the connected Flux Storage or Flux Controller during that server tick and returns numbers or tables representing the network's state. Because Flux Networks itself handles cross-dimensional wireless syncing, your computer does not need to be wired to every generator or machine—wiring it to a single local Flux Storage block grants visibility over the entire multi-dimensional grid.
By pairing this data stream with ComputerCraft's redstone API, you create a closed-loop feedback system. Instead of burning fuel continuously, backup power plants remain dormant until the Lua script detects a net negative drain on the Flux Storage buffer, converting passive statistics into active grid management.
Common mistakes
- Querying an unlinked Flux block: If your Flux Storage or Flux Controller has not been assigned to an active network via its GUI, the peripheral methods will return zero or nil values and crash your division math.
- Forgetting to activate Wired Modems: Simply placing a Wired Modem against a Flux block does not connect it. You must right-click the modem until its ring turns red and its peripheral ID is printed in chat.
- Omitting the sleep() call in the main loop: An infinite while loop without a yield or sleep() statement will freeze the virtual machine and terminate your script after a few seconds.
- Integer display overflow on small monitors: Printing raw FE numbers from Herculean or Gargantuan Flux Storage units will run off the edge of the screen. Always scale your numbers into kFE, MFE, or GFE before rendering.
FAQ
Why does peripheral.find() return nil when connected to my Flux block?
Ensure the Flux block is directly touching the computer or connected via activated Wired Modems. In some modpack configurations, you may need an integration addon such as Advanced Peripherals or Plethora if native CC: Tweaked peripheral support is disabled or absent in that specific version of Flux Networks.
Can I monitor energy flowing across other dimensions?
Yes. Because Flux Networks synchronizes network stats globally, a single computer in the Overworld reading a local Flux Storage block can monitor energy being generated in the Nether or consumed in the End on that same network.
How do I keep the monitoring script running when I leave the base?
Open the GUI of the Flux Storage or Flux Controller connected to your computer and enable its built-in Chunk Loading option, or use a dedicated chunk loader so both the Flux block and the Advanced Computer remain loaded.
Can a computer bypass Flux Network password protection?
A computer interacts with the physical block placed in the world. Once an authorized player links a Flux Storage block to an encrypted network, the adjacent computer can read the stats from that block without needing to input the password in Lua.
By connecting an Advanced Computer to a Flux Storage block, you can transform raw wireless energy metrics into a live visual dashboard and an automated backup power controller.