add writing to config files when the terminate event is received.
This commit is contained in:
21
main.lua
21
main.lua
@@ -633,12 +633,7 @@ function Init()
|
||||
local configFile = io.open(Config.ConfigPath, "r")
|
||||
if configFile then
|
||||
local configContent = configFile:read("*all")
|
||||
local configChunk, err = load(configContent)
|
||||
if configChunk then
|
||||
Config = configChunk()
|
||||
else
|
||||
print("Error loading config string: "..err)
|
||||
end
|
||||
Config = stringToTable(configContent)
|
||||
configFile:close()
|
||||
else
|
||||
print("Could not open the config file")
|
||||
@@ -779,7 +774,21 @@ function Main()
|
||||
|
||||
-- Add a small delay to avoid overloading the system
|
||||
os.sleep(0.1)
|
||||
|
||||
local event = os.pullEventRaw("terminate")
|
||||
if event == "terminate" then print("Terminate Event Received") break end
|
||||
|
||||
end
|
||||
|
||||
print("Writing to thruster config file.")
|
||||
local thrusterConfigFile = fs.open(Config.thrusterConfigPath, "w+")
|
||||
thrusterConfigFile.write(tableToString(Thrusters))
|
||||
thrusterConfigFile.close()
|
||||
|
||||
print("Writing to config file")
|
||||
local configFile = fs.open(Config.ConfigPath, "w+")
|
||||
configFile.write(tableToString(Config))
|
||||
configFile.close()
|
||||
end
|
||||
|
||||
-- Run the main function when the script starts
|
||||
|
||||
Reference in New Issue
Block a user