created bigger reactor script
This commit is contained in:
parent
f1676e251e
commit
d4bf4ba533
83
biggerReactor.lua
Normal file
83
biggerReactor.lua
Normal file
|
@ -0,0 +1,83 @@
|
|||
-- 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 b_raw = system.main.battery()
|
||||
local f_raw = system.main.fuelTank()
|
||||
local c_raw = system.main.coolantTank()
|
||||
local ft_raw = system.main.fuelTemperature()
|
||||
local ct_raw = system.main.casingTemperature()
|
||||
|
||||
-- format and align reactor status and internal battery
|
||||
message_aligned(buffer, 'Status...:', a_raw, system.width)
|
||||
message_aligned(buffer, 'Battery..:', b_raw, system.width)
|
||||
|
||||
-- format and align fuel and coolant fill
|
||||
message(buffer, '\n')
|
||||
message_aligned(buffer, 'Fuel.....:', f_raw, system.width)
|
||||
message_aligned(buffer, 'Coolant..:', c_raw, system.width)
|
||||
|
||||
-- format and align temperatures
|
||||
message(buffer, '\n')
|
||||
message_aligned(buffer, 'Fuel Temp:', ft_raw, system.width)
|
||||
message_aligned(buffer, 'Case Temp:', 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()
|
Loading…
Reference in New Issue
Block a user