Repository navigation
ComputerCraft
With CC: Tweaked installed, the reactor is a peripheral of type bhe_reactor. A computer can read everything the Control Console shows and press every button it has.
The integration only loads when CC: Tweaked is present. Without it the mod runs exactly the same.
The peripheral is on three blocks. Attach a computer or a wired modem to any of them:
| Block | Notes |
|---|---|
| Reactor Core | Always works. |
| Reactor Port | Any port in the ring. Ports link to their core when the reactor is checked (formed), so the reactor must be formed. |
| Control Console | Put the modem on the console wall's bottom-left block (as you face the screen). The console must be linked to a core within 32 blocks (consoleLinkRadius). |
local reactor = peripheral.find("bhe_reactor")
if not reactor then error("No reactor found") end
print(reactor.getState(), reactor.getRpm() .. " rpm")Every call runs on the server thread, so each call takes one game tick. If you need many values at once, use getStatus(), which returns them all in one table for a single tick.
If the peripheral isn't linked to a core (a port of an unformed reactor, an unlinked console), calls throw No Reactor Core linked. Check with isLinked() first.
| Method | Returns |
|---|---|
isLinked() |
boolean: whether a core is linked. Never throws. |
getState() |
string: "offline", "stable", "warning", "shutting_down", "disc_stall", "pre_meltdown", "meltdown_1", "meltdown_2", "ignition_fault" or "shutdown_fault"
|
isFormed() |
boolean |
getStability() |
number, 0–100 (%) |
getStress() |
number, 0–100 (%), the ring's stress |
getRpm() |
number. Negative means spinning backwards. |
getOffset() |
number: the stabilizers' current angle, in degrees |
getTargetOffset() |
number: the angle they're turning toward (1° per second) |
getMaxOffset() |
number: the largest allowed offset (maxOffset, 15) |
getLaserPower() |
number, 0–100 (%) |
getEnergy() |
number: RF in the core's buffer |
getEnergyCapacity() |
number: the buffer's size (1,000,000,000) |
getOutput() |
number: RF/t made last tick |
getMass() |
number: total mass in the four stabilizers |
getStabilizerMasses() |
table: {north = n, east = n, south = n, west = n}
|
getTimer() |
number: seconds left on the current countdown (stall, fault, pre-meltdown, meltdown), 0 if there isn't one |
getFault() |
string or nil: "stabilizer_desync", "mass_flash", "cracked_lens", "singularity_rebound"
|
getFaultSides() |
table of sides the fault hit, e.g. {"north", "west"}
|
isFaultFixed() |
boolean: the fault is fixed and RESET can be pressed |
getBreakers() |
table: {north = bool, ...}, which Breaker Panels are overcharged |
getResonance() |
table: {center = rpm, width = rpm either side, efficiency = 0–100}
|
getWobble() |
number, −100–100. Negative leans toward the north-west. At ±100 the disc stalls. |
getAxialTrim() |
number, −10–10 |
isAxialFormed() |
boolean: both axial stabilizers are built (spin can make power) |
getUnpoweredStabilizers() |
number: stabilizers the core's power couldn't run last tick (0 while not running); each drags stability toward 0 |
isLanceFormed() |
boolean: a Venting Lance stands over the core |
isVentArmed() |
boolean: the vent is armed, so a second vent() within 5 seconds fires it |
getStatus() |
table with all of the above (keys: state, formed, stability, stress, rpm, offset, targetOffset, laserPower, energy, energyCapacity, output, mass, stabilizerMasses, timer, fault, faultSides, faultFixed, breakers, resonance, wobble, axialTrim, axialFormed, unpoweredStabilizers, lanceFormed, ventArmed) |
What the numbers mean, and how they move, is on the Reactor Calculations page.
The buttons behave exactly like pressing them on the console. Each returns the message a player would have seen, or nil if there wasn't one, so you can print it or check it.
| Method | Does |
|---|---|
ignite() |
IGNITE |
shutdown() |
SHUTDOWN |
scram() |
SCRAM. Above 90% of the safe spin this stalls the disc. |
jumpStart() |
JUMP: restarts a stalled disc once every breaker is overcharged. Pressing it too early costs 5 seconds of the stall timer. |
reset() |
RESET after fixing a fault (the same button as JUMP) |
vent() |
VENT: the first call arms the lance, a second call within 5 seconds fires it |
These return true, or false if the reactor can't be adjusted right now (it isn't running steadily):
| Method | Range |
|---|---|
setTargetOffset(degrees) |
−15…15 (clamped to maxOffset) |
setLaserPower(percent) |
0…100 |
setAxialTrim(trim) |
−10…10. Negative pushes toward the north-west. |
There's no way to overcharge the Breaker Panels or fix faults from a computer: someone still has to go to the stabilizers.
This keeps the disc inside the resonance band, holds the wobble near 0, and SCRAMs before things get out of hand. Start the reactor yourself first.
local reactor = peripheral.find("bhe_reactor") or error("No reactor")
local function clamp(v, lo, hi) return math.max(lo, math.min(hi, v)) end
while true do
local s = reactor.getStatus()
if s.state == "stable" or s.state == "warning" then
-- Spin: push up below the band, brake above it, coast inside it.
local band = s.resonance
local rpm = math.abs(s.rpm)
if rpm < band.center - band.width / 2 then
reactor.setTargetOffset(2)
elseif rpm > band.center + band.width / 2 then
reactor.setTargetOffset(-1)
else
reactor.setTargetOffset(0)
end
-- Wobble: trim against the lean (negative wobble leans north-west, positive trim pushes back).
reactor.setAxialTrim(clamp(math.floor(-s.wobble / 5 + 0.5), -10, 10))
-- Safety: get out while it's still safe to.
if s.stability < 30 or s.stress > 70 then
print("Unsafe, scramming: " .. tostring(reactor.scram()))
end
elseif s.state == "disc_stall" then
print("Disc stall: overcharge every breaker, then JUMP. " .. s.timer .. " s left")
elseif s.fault then
print("Fault: " .. s.fault .. " on " .. table.concat(s.faultSides, ", ") .. ". " .. s.timer .. " s left")
end
sleep(1)
endThings to tune:
- Offset steps. At 2° the disc gains 20 rpm per second. The stabilizers turn only 1° per second, so a big change of target takes a while to land.
- The band moves. About once a minute it jumps 300–600 rpm, so a controller that keeps up with it gains the most.
-
Mass.
getStabilizerMasses()shows a stabilizer running low before it stalls the disc. Uneven mass also makes the disc wobble harder.
Without a computer, a comparator against any Reactor Port reads the core's stability as a signal of 0–15. See Mod Interactions.