updated fission to lib changes
This commit is contained in:
parent
fce7f6bbb2
commit
484c42c4a4
|
@ -1,89 +1,46 @@
|
|||
-- user options
|
||||
local options = {
|
||||
port = 'fissionReactorLogicAdapter',
|
||||
name = 'Fission Reactor',
|
||||
compact = true,
|
||||
channels = 10,
|
||||
timeout = 15
|
||||
}
|
||||
|
||||
|
||||
-- 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, 'fissionReactorLogicAdapter', 'Fission Reactor')
|
||||
|
||||
|
||||
-- generate induction matrix values
|
||||
function generate_message(buffer)
|
||||
-- read induction matrix values
|
||||
local a_raw = system.main.getStatus()
|
||||
local d_raw = system.main.getDamagePercent()
|
||||
local w_raw = system.main.getWasteFilledPercentage()
|
||||
local h_raw = system.main.getHeatedCoolantFilledPercentage()
|
||||
local f_raw = system.main.getFuelFilledPercentage()
|
||||
local c_raw = system.main.getCoolantFilledPercentage()
|
||||
local t_raw = system.main.getTemperature()
|
||||
local r_raw = system.main.getActualBurnRate()
|
||||
-- generate print responsee message
|
||||
function generate_message(width, component, buffer)
|
||||
-- read fission values
|
||||
local a_raw = component.getStatus()
|
||||
local d_raw = component.getDamagePercent()
|
||||
local w_raw = component.getWasteFilledPercentage()
|
||||
local h_raw = component.getHeatedCoolantFilledPercentage()
|
||||
local f_raw = component.getFuelFilledPercentage()
|
||||
local c_raw = component.getCoolantFilledPercentage()
|
||||
local t_raw = component.getTemperature()
|
||||
local r_raw = component.getActualBurnRate()
|
||||
|
||||
-- format and align reactor status
|
||||
message_aligned(buffer, 'Status....:', a_raw and 'ACTIVE' or 'OFFLINE', system.width)
|
||||
message_aligned(buffer, 'Damage....:', format_percent(options, d_raw, false), system.width)
|
||||
message_aligned(buffer, 'Status....:', a_raw and 'ACTIVE' or 'OFFLINE', width)
|
||||
message_aligned(buffer, 'Damage....:', format_percent(options, d_raw, false), width)
|
||||
|
||||
-- format and align reactor internal battery
|
||||
message(buffer, '\n')
|
||||
message_aligned(buffer, 'Waste.....:', format_percent(options, w_raw), system.width)
|
||||
message_aligned(buffer, 'Heated....:', format_percent(options, h_raw), system.width)
|
||||
|
||||
message_aligned(buffer, 'Waste.....:', format_percent(options, w_raw), width)
|
||||
message_aligned(buffer, 'Heated....:', format_percent(options, h_raw), width)
|
||||
|
||||
-- format and align fuel fill
|
||||
message(buffer, '\n')
|
||||
message_aligned(buffer, 'Fuel......:', format_percent(options, f_raw), system.width)
|
||||
message_aligned(buffer, 'Coolant...:', format_percent(options, c_raw), system.width)
|
||||
|
||||
message_aligned(buffer, 'Fuel......:', format_percent(options, f_raw), width)
|
||||
message_aligned(buffer, 'Coolant...:', format_percent(options, c_raw), width)
|
||||
|
||||
-- format and align temperature and burnrate
|
||||
message(buffer, '\n')
|
||||
message_aligned(buffer, 'Reactor T.:', format_temp(options, t_raw), system.width)
|
||||
message_aligned(buffer, 'Burnrate..:', format_liquid(options, r_raw, true), system.width)
|
||||
message_aligned(buffer, 'Reactor T.:', format_temp(options, t_raw), width)
|
||||
message_aligned(buffer, 'Burnrate..:', format_liquid(options, r_raw, true), 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('fissionReactorLogicAdapter').success and (not system.timeout) do
|
||||
event_listener()
|
||||
end
|
||||
-- rescan components
|
||||
wait_for_components(options, system, 'fissionReactorLogicAdapter', 'Fission Reactor')
|
||||
end
|
||||
end
|
||||
main()
|
||||
-- initialize client library
|
||||
dofile('inputClient.lua')
|
||||
run_client(options, {
|
||||
print = generate_message
|
||||
})
|
Loading…
Reference in New Issue
Block a user