Power & Electrical System
Overview
The Power section of the cee API manages electrical power, voltage levels, current limits, and device states across pins and networks in CC: Computer Energetics.
Calling Conventions / Prefixes
Power utility functions and measurements are accessed through the global cee namespace:
local volts = cee.getVoltage(1)
cee.setMainBreaker(true)
API Reference Table
| Method Signature | Arguments & Types | Description |
|---|---|---|
cee.getVoltage(pin) |
pin (number) |
Returns the average voltage on a pin over the last second. |
cee.getCurrent(pin) |
pin (number) |
Returns total current flowing through the pin. |
cee.getPower(pin) |
pin (number) |
Returns real power in watts on the pin. |
cee.getApparentPower(pin) |
pin (number) |
Returns VA (volt-amps) on the pin. |
cee.getReactivePower(pin) |
pin (number) |
Returns VAR (volt-amps reactive) on the pin. |
cee.getPowerFactor(pin) |
pin (number) |
Returns the power factor on the pin (-1 to 1). |
cee.getFrequency(pin) |
pin (number) |
Returns frequency in Hz of the pin's AC wave. |
cee.getPhase(pin) |
pin (number) |
Returns phase offset in degrees. |
cee.getMainBreaker() |
None | Returns whether the computer's main power gate/breaker is up. |
cee.setMainBreaker(bool) |
bool (boolean) |
Trips or resets the main breaker. |
cee.getBreakerReason() |
None | Returns why the breaker tripped, as a string table. |
Lua Code Examples
Example 1: Checking Pin Voltage and Power
local pin = 1
local v = cee.getVoltage(pin)
local w = cee.getPower(pin)
print("Pin " .. pin .. " Voltage: " .. v .. "V, Power: " .. w .. "W")
Example 2: Managing Main Breaker State
if not cee.getMainBreaker() then
print("Breaker tripped! Reason:", textutils.serialise(cee.getBreakerReason()))
print("Attempting to reset breaker...")
cee.setMainBreaker(true)
end