Skip to content

Integration


Header

Introduction

You can also use Computer Craft: Tweaked to control your reactor and turbines! For that, some knowledge in LUA or even in CC:Tweaked would be great!

You can use any Reactor Casing as peripheral, as long as the reactor has been assembled once before!




Peripheral

Peripheral Name

thorium_reactor

Example

local reactor = peripheral.find("thorium_reactor")


Example Script

Computer Example Script

Show Script
startup.lua
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
reactor = peripheral.find("thorium_reactor")
monitor = peripheral.find("monitor")

monitor.clear()

monitor.setCursorPos(15,1)
monitor.write("Turbine")
monitor.setCursorPos(1,2)
monitor.write("Turbines: " .. reactor.getTurbineCount())

offset = 3
for i=reactor.getTurbineCount() - 1,0,-1 do
    monitor.setCursorPos(1,offset)
    monitor.write("Turbine #" .. i)
    monitor.setCursorPos(20,offset)
    monitor.write("x:" .. reactor.getTurbinePosition(i).x .. " y:" .. reactor.getTurbinePosition(i).y .. " z:" .. reactor.getTurbinePosition(i).z)
    monitor.setCursorPos(20,offset + 1)
    monitor.write(tostring(reactor.isTurbineActive(i) and "Active" or "Inactive"))
    monitor.setCursorPos(30,offset + 1)
    monitor.write(tostring(reactor.isTurbineAssembled(i) and "Assembled" or "Incomplete"))
    monitor.setCursorPos(20,offset + 2)
    monitor.write(string.format("%.1f", reactor.getTurbineGeneration(i)) .. "FE/t")
    monitor.setCursorPos(20,offset + 3)
    monitor.write(string.format("%.1f", reactor.getTurbineSpeed(i)) .. "RPM")
    monitor.setCursorPos(30,offset + 3)
    monitor.write(string.format("%.1f", reactor.getTurbineHeight(i)) .. "B")
    monitor.setCursorPos(20,offset + 4)
    monitor.write(tostring(reactor.getTurbineCurrentFlow(i)) .. " / " .. tostring(reactor.getTurbineTargetFlow(i)) .. "mB/t")
    offset = offset + 5
end

offset = offset + 1
monitor.setCursorPos(15,offset)
monitor.write("Reactor")
monitor.setCursorPos(1,offset + 1)
monitor.write(reactor.isAssembled() and "Assembled" or "Incomplete")
monitor.setCursorPos(30,offset + 1)
monitor.write(string.upper(reactor.getReactorState()))
monitor.setCursorPos(1,offset + 2)
monitor.write("Temperature: " .. string.format("%.1f", reactor.getReactorCurrentTemperature()) .. " / " .. string.format("%.1f", reactor.getReactorTargetTemperature()) .. "°C")
monitor.setCursorPos(1,offset + 3) 
monitor.write("Molten Salt: " .. tostring(reactor.getReactorFluidAmountIn()) .. " / " .. tostring(reactor.getReactorFluidCapacityIn()) .. "mB")
monitor.setCursorPos(1,offset + 4) 
monitor.write("Heated Molten Salt: " .. tostring(reactor.getReactorFluidAmountOut()) .. " / " .. tostring(reactor.getReactorFluidCapacityOut()) .. "mB")

Functions

isAssembled()

Description

Returns true or false whether the reactor is assembled or not!

Method
isAssembled() -> boolean
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Assembled? " .. tostring(reactor.isAssembled()))

getReactorState()

Description

Returns the current operating mode of the reactor as a string.

Method
getReactorState() -> string

return: "starting", "running", "stop"
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Currently in " .. tostring(reactor.getReactorState() .. " mode!"))

setReactorState()

Description

Set the reactor operating state! When an invalid mode is passed, the reactor will use "stop" as default.

Method
setReactorState(string mode)

mode: "starting", "running", "stop"
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

reactor.setReactorState("starting")

getReactorFluidAmountOut()

Description

Returns the amount of heated molten salt in the reactor tank!

Method
getReactorFluidAmountOut() -> Integer
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Heated Molten Salt: " .. tostring(reactor.getReactorFluidAmountOut()) .. " mB")

getReactorFluidCapacityOut()

Description

Returns the capacity of the reactor output tank! (Heated Molten Salt)

Method
getReactorFluidCapacityOut() -> Integer
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Capacity Out: " .. tostring(reactor.getReactorFluidCapacityOut()) .. " mB")

getReactorFluidAmountIn()

Description

Returns the amount of molten salt in the reactor tank!

Method
getReactorFluidAmountIn() -> Integer
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Molten Salt: " .. tostring(reactor.getReactorFluidAmountIn()) .. " mB")

getReactorFluidCapacityIn()

Description

Returns the capacity of the reactor input tank! (Molten Salt)

Method
getReactorFluidCapacityIn() -> Integer
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Capacity In: " .. tostring(reactor.getReactorFluidCapacityIn()) .. " mB")

getReactorCapacity()

Description

Returns the total capacity of the reactor!

Method
getReactorCapacity() -> Integer
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Capacity: " .. tostring(reactor.getReactorCapacity()) .. " mB")

getReactorCurrentLoadSet()

Description

Returns the value of current fueled uranium in percent!

Method
getReactorCurrentLoadSet() -> Float
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Uranium Fuel: " .. tostring(reactor.getReactorCurrentLoadSet()) .. "%")

getReactorTargetLoadSet()

Description

Returns the set/wanted uranium fuel fill level in percent!

Method
getReactorTargetLoadSet() -> Float
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Uranium Fuel: " .. tostring(reactor.getReactorTargetLoadSet()) .. "%")

setReactorTargetLoadSet()

Description

Set the wanted uranium fuel fill level in percent!

Method
setReactorTargetLoadSet(Integer rate)

rate: 0 - 100
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

reactor.setReactorTargetLoadSet(100)

getReactorStatusPercent()

Description

Returns the current health rate of the reactor in percent!

Method
getReactorStatusPercent() -> Float
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Health: " .. tostring(reactor.getReactorStatusPercent()) .. "%")

getReactorContainmentPercent()

Description

Returns the current containment rate of the reactor in percent!

Method
getReactorContainmentPercent() -> Float
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Health: " .. tostring(reactor.getReactorContainmentPercent()) .. "%")

getReactorRadiation()

Description

Returns the current escaping radiation of the reactor in µSv!

Method
getReactorRadiation() -> Float
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Radiation: " .. tostring(reactor.getReactorRadiation()) .. "uSv")

isReactorScrammed()

Description

Returns whether the reactor is scrammed or not!

Method
isReactorScrammed() -> boolean
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Scrammed? " .. tostring(reactor.isReactorScrammed()))

setReactorScrammed()

Description

Set the reactor operating state! When an invalid mode is passed, the reactor will use "stop" as default.

Method
setReactorScrammed(boolean state)

state: true, false
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

reactor.setReactorScrammed(true)

getReactorRunningSince()

Description

Returns the time the reactor has run until last startup! Format: 5 seconds = 5 seconds * 20 ticks = 100

Method
getReactorRunningSince() -> Long
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Time lasted: " .. tostring(reactor.getReactorRunningSince() / 20))

getReactorCurrentTemperature()

Description

Returns the reactors current temperature in degree Celsius!

Method
getReactorCurrentTemperature() -> Float
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Current Temp: " .. tostring(reactor.getReactorCurrentTemperature()) .. "°C")

getReactorTargetTemperature()

Description

Returns the reactors target temperature in degree Celsius!

Method
getReactorTargetTemperature() -> Float
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Target Temp: " .. tostring(reactor.getReactorTargetTemperature()) .. "°C")

getReactorNotification()

Description

Returns the current notification of the reactor! For example when the reactor gets scrammed!

Method
getReactorNotification() -> String
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Warning: " .. reactor.getReactorNotification())

getReactorLoad()

Description

Returns the load of the reactor!

Method
getReactorLoad() -> Float
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Warning: " .. toString(reactor.getReactorLoad()))

getFuelRodStatus()

Description

Returns the fuel level of the given fuel rod in percent!

Method
getFuelRodStatus(Integer index) -> Float

index: 0 - 80

getFuelRodStatusMap()

Description

Returns the fuel level of the given fuel rod in percent in a lua table!

Method
getFuelRodStatusMap() -> Table: Int, Int
Example
example.lua
1
2
3
4
5
local reactor = peripheral.find("thorium_reactor")

for k, v in pairs(reactor.getFuelRodStatusMap()) do
    print("Fuel #: " .. k .. " has " .. v .. "% fuel")
end
Added In

ThoriumReactors version 0.2b


getDepletedFuelRodStatus()

Description

Returns the depleted fuel level of the given fuel rod in percent!

Method
getDepletedFuelRodStatus(Integer index) -> Float

index: 0 - 80
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Depletion #55: " .. toString(reactor.getDepletedFuelRodStatus(55)) .. "%")

getDepletedFuelRodStatusMap()

Description

Returns the depleted fuel level of the given fuel rod in percent in a lua table!

Method
getDepletedFuelRodStatusMap() -> Table: Int, Int
Example
example.lua
1
2
3
4
5
local reactor = peripheral.find("thorium_reactor")

for k, v in pairs(reactor.getDepletedFuelRodStatusMap()) do
    print("Fuel #: " .. k .. " has " .. v .. "% depleted fuel")
end
Added In

ThoriumReactors version 0.2b


getCurrentControlRodStatus()

Description

Returns the current control rod insert value in percent!

Method
getCurrentControlRodStatus(Integer index) -> Float

index: 0 - 63
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Control #55: " .. toString(reactor.getCurrentControlRodStatus(70)) .. "%")

getCurrentControlRodStatusMap()

Description

Returns the depleted fuel level of the given fuel rod in percent in a lua table!

Method
getCurrentControlRodStatusMap() -> Table: Int, Int
Example
example.lua
1
2
3
4
5
local reactor = peripheral.find("thorium_reactor")

for k, v in pairs(reactor.getCurrentControlRodStatusMap()) do
    print("Rod #: " .. k .. " is " .. v .. "% inserted")
end
Added In

ThoriumReactors version 0.2b


getTargetControlRodStatus()

Description

Returns the target control rod insert value in percent!

Method
getTargetControlRodStatus(Integer index) -> Float

index: 0 - 63
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Control #70: " .. toString(reactor.getTargetControlRodStatus(70)) .. "%")

getTargetControlRodStatusMap()

Description

Returns the depleted fuel level of the given fuel rod in percent in a lua table!

Method
getTargetControlRodStatusMap() -> Table: Int, Int
Example
example.lua
1
2
3
4
5
local reactor = peripheral.find("thorium_reactor")

for k, v in pairs(reactor.getTargetControlRodStatusMap()) do
    print("Rod #: " .. k .. " will be " .. v .. "% inserted")
end
Added In

ThoriumReactors version 0.2b


setTargetControlRodStatus()

Description

Sets the target control rod insert value!

Method
setTargetControlRodStatus(Integer index, Integer value)

index: 0 - 63
value: 0 - 100
Example
example.lua
1
2
3
4
local reactor = peripheral.find("thorium_reactor")

-- Sets target control rod insert to 59% on rod #10
reactor.setTargetControlRodStatus(10, 59)

isTurbineActive()

Description

Returns true or false whether the turbine with the id is active.

Method
isTurbineActive(Integer index) -> boolean

index: 0 - ?
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Turbine on? " .. tostring(reactor.isTurbineActive(0)))

setTurbineActive()

Description

Sets the activation state of a turbine.

Method
setTurbineActive(Integer index, Boolean state)

index: 0 - ?
state: true - false
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

reactor.setTurbineActive(0,true)

isTurbineCoilsEngaged()

Description

Returns true or false whether the turbine coils are engaged or not.

Method
isTurbineCoilsEngaged(Integer index) -> boolean

index: 0 - ?
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Coils engaged? " .. tostring(reactor.isTurbineCoilsEngaged(0)))

setTurbineCoilsEngaged()

Description

Sets the coil engage state of a turbine.

Method
setTurbineCoilsEngaged(Integer index, Boolean state)

index: 0 - ?
state: true - false
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

reactor.setTurbineCoilsEngaged(0,true)

copyConfigurationToAllTurbines()

Description

Copy the settings from the given turbine to all others.

Method
copyConfigurationToAllTurbines(Integer index)

index: 0 - ?
Example
example.lua
1
2
3
4
local reactor = peripheral.find("thorium_reactor")

-- copies all settings from turbine 0 to all other saved!
reactor.copyConfigurationToAllTurbines(0)

isTurbineAssembled()

Description

Returns true or false whether the turbine is assembled or not.

Method
isTurbineAssembled(Integer index) -> boolean

index: 0 - ?
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Assembled? " .. tostring(reactor.isTurbineAssembled(0)))

getTurbineHeight()

Description

Returns the total height of the turbine.

Method
getTurbineHeight(Integer index) -> Integer

index: 0 - ?
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Height: " .. tostring(reactor.getTurbineHeight(0)))

getTurbineCurrentFlow()

Description

Returns the actual flow rate of the turbine.

Method
getTurbineCurrentFlow(Integer index) -> Integer

index: 0 - ?
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Flow rate: " .. tostring(reactor.getTurbineCurrentFlow(0)) "mB/t")

getTurbineTargetFlow()

Description

Returns the target flow rate of the turbine.

Method
getTurbineTargetFlow(Integer index) -> Integer

index: 0 - ?
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Flow rate: " .. tostring(reactor.getTurbineTargetFlow(0)) .. "mB/t")

setTurbineTargetFlow()

Description

Sets the target flow rate of the turbine.

Method
setTurbineTargetFlow(Integer index, Integer flowrate)

index: 0 - ?
index: 0 - 2500
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

reactor.setTurbineTargetFlow(0,2000)

getTurbineGeneration()

Description

Returns the target flow rate of the turbine.

Method
getTurbineGeneration(Integer index) -> Float

index: 0 - ?
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Gen: " .. tostring(reactor.getTurbineGeneration(0)) .. " FE/t")

getTurbineSpeed()

Description

Returns the current turbine speed of the turbine.

Method
getTurbineSpeed(Integer index) -> Float

index: 0 - ?
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Speed: " .. tostring(reactor.getTurbineSpeed(0)) .. " RPM")

getTurbineEnergyModifier()

Description

Returns the current turbine speed of the turbine.

Method
getTurbineEnergyModifier(Integer index) -> Float

index: 0 - ?
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Energy Modifier: " .. tostring(reactor.getTurbineEnergyModifier(0)) .. "x")

getTurbinePosition()

Description

Returns the turbines position in a table.

Method
getTurbinePosition(Integer index) -> Table

Table:
{
    "x": -127,
    "y": 80,
    "z": 322
}

index: 0 - ?
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Position: x:" .. reactor.getTurbinePosition(0).x .. " y:" .. reactor.getTurbinePosition(0).y .. " z:" .. reactor.getTurbinePosition(0).z)

getTurbinePositionString()

Description

Returns the turbines position in a string.

Method
getTurbinePosition(Integer index) -> String

index: 0 - ?
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Position: " + getTurbinePositionString())

getTurbinePositions()

Description

Returns all turbines positions in a table.

Method
getTurbinePositions(Integer index) -> Table

Table:
{
    {
        "x": -127,
        "y": 80,
        "z": 322
        "turbineId": 0
    },
    {
        "x": -127,
        "y": 80,
        "z": 322
        "turbineId": 1
    }
}

index: 0 - ?
Example
example.lua
1
2
3
4
5
6
7
local reactor = peripheral.find("thorium_reactor")

local positions = reactor.getTurbinePositions(0)

for k, v in pairs(positions) do
    print(v.x .. " " .. v.y .. " " .. v.z .. " " .. v.turbineId)
end

getTurbineCount()

Description

Returns the amount of all turbines.

Method
getTurbineCount() -> Integer
Example
example.lua
1
2
3
local reactor = peripheral.find("thorium_reactor")

print("Turbines: " + reactor.getTurbineCount())