91 lines
2.8 KiB
Lua
91 lines
2.8 KiB
Lua
-- user options
|
|
local options = {
|
|
compact = true,
|
|
channels = 10,
|
|
timeout = 15,
|
|
unit = 'FE'
|
|
}
|
|
|
|
|
|
-- set system seed
|
|
math.randomseed(os.time())
|
|
|
|
-- system options/components
|
|
local system = {}
|
|
|
|
-- initialize client library
|
|
dofile('inputClient.lua')
|
|
|
|
-- initialize components
|
|
wait_for_components(options, system, 'BiggerReactors_Reactor', 'Bigger Reactor')
|
|
|
|
|
|
-- generate induction matrix values
|
|
function generate_message(buffer)
|
|
-- read induction matrix values
|
|
local a_raw = system.main.active()
|
|
local p_raw = system.main.battery().producedLastTick()
|
|
local s_raw = system.main.battery().stored()
|
|
local m_raw = system.main.battery().capacity()
|
|
local f_raw = system.main.fuelTank().fuel()
|
|
local c_raw = system.main.fuelTank().capacity()
|
|
local ft_raw = system.main.fuelTemperature()
|
|
local ct_raw = system.main.casingTemperature()
|
|
|
|
-- format and align reactor status and production
|
|
message_aligned(buffer, 'Status...:', a_raw and 'ACTIVE' or 'OFFLINE', system.width)
|
|
message_aligned(buffer, 'Producing:', format_energy(options, p_raw, true), system.width)
|
|
|
|
-- format and align reactor internal battery
|
|
message(buffer, '\n')
|
|
message_aligned(buffer, 'Stored...:', format_energy(options, s_raw), system.width)
|
|
message_aligned(buffer, 'Capacity.:', format_energy(options, m_raw), system.width)
|
|
|
|
-- format and align fuel fill
|
|
message(buffer, '\n')
|
|
message_aligned(buffer, 'Fuel.....:', format_liquid(options, f_raw), system.width)
|
|
message_aligned(buffer, 'Capacity.:', format_liquid(options, c_raw), system.width)
|
|
|
|
-- format and align temperatures
|
|
message(buffer, '\n')
|
|
message_aligned(buffer, 'Fuel Temp:', format_temp(options, ft_raw), system.width)
|
|
message_aligned(buffer, 'Case Temp:', format_temp(options, ct_raw), system.width)
|
|
end
|
|
|
|
function send_info()
|
|
-- buffer for messages
|
|
local buffer = {}
|
|
-- generate messages in buffer
|
|
generate_message(buffer)
|
|
-- transmit messages in form of buffer
|
|
transmit_messages(options, system, buffer)
|
|
end
|
|
|
|
function event_listener()
|
|
while true do
|
|
local _, _, senderChannel, _, message, _ = os.pullEvent('modem_message')
|
|
|
|
-- respond to corresponding message only
|
|
if senderChannel == system.channel and message == 'print' then
|
|
-- send message main display message
|
|
send_info()
|
|
end
|
|
end
|
|
end
|
|
|
|
-- main program
|
|
function main()
|
|
-- permanent runtime
|
|
while true do
|
|
-- reset terminal
|
|
term.clear()
|
|
-- run while all components are detected
|
|
while scan_components('BiggerReactors_Reactor').success and (not system.timeout) do
|
|
event_listener()
|
|
end
|
|
-- rescan components
|
|
wait_for_components(options, system, 'BiggerReactors_Reactor', 'Bigger Reactor')
|
|
end
|
|
end
|
|
main()
|