Wiki 9Minecraft Wiki 9Minecraft
Integrated Scripting Wiki › Guides › Write Your First Script to Calculate Average Power Consumption

Write Your First Script to Calculate Average Power Consumption

Setting Up the Script

Create a new script file in your Integrated Scripting environment. You'll need to access the power network data from your Integrated Dynamics setup. Scripts in this mod can read values from cables and devices connected to your network.

Reading and Computing Power Data

Use the scripting API to query power consumption values over time. The mod provides functions to:

  • Fetch instantaneous power draw from network cables
  • Store historical readings in a list or array
  • Calculate the average by summing values and dividing by sample count

You can set up a loop that samples power at regular intervals, storing each reading. After collecting enough data points, compute the mean to see your average consumption.

Displaying Results

Once calculated, output the result to a panel or display component. This gives you real-time visibility into your base's power usage patterns, helping you identify power-hungry systems and optimize your setup.