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")
|
local configFile = io.open(Config.ConfigPath, "r")
|
||||||
if configFile then
|
if configFile then
|
||||||
local configContent = configFile:read("*all")
|
local configContent = configFile:read("*all")
|
||||||
local configChunk, err = load(configContent)
|
Config = stringToTable(configContent)
|
||||||
if configChunk then
|
|
||||||
Config = configChunk()
|
|
||||||
else
|
|
||||||
print("Error loading config string: "..err)
|
|
||||||
end
|
|
||||||
configFile:close()
|
configFile:close()
|
||||||
else
|
else
|
||||||
print("Could not open the config file")
|
print("Could not open the config file")
|
||||||
@@ -779,7 +774,21 @@ function Main()
|
|||||||
|
|
||||||
-- Add a small delay to avoid overloading the system
|
-- Add a small delay to avoid overloading the system
|
||||||
os.sleep(0.1)
|
os.sleep(0.1)
|
||||||
|
|
||||||
|
local event = os.pullEventRaw("terminate")
|
||||||
|
if event == "terminate" then print("Terminate Event Received") break end
|
||||||
|
|
||||||
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
|
end
|
||||||
|
|
||||||
-- Run the main function when the script starts
|
-- Run the main function when the script starts
|
||||||
|
|||||||
Reference in New Issue
Block a user