WriteConfig
The WriteConfig function writes a configuration table to a file in the configs directory where the Ghost executable file is. The configuration files in the Ghost system are heavily encrypted, ensuring the safety and integrity of the data. It can not be read in plain text nor can it be scanned by another process.
Parameters
fileName: The name of the configuration file to write. The file will be located in theconfigsdirectory within thescriptsfolder.configTable: A table containing the configuration data to be written.
Example Usage in Lua
Here is an example of how to use the WriteConfig function in Lua, including reading a configuration file, modifying it, and writing it back to disk:
local api = ...
-- Function to read, modify, and write a configuration file
function ModifyAndWriteConfig(fileName)
-- Read the existing configuration file
local configTable = api.ReadConfig(fileName)
if configTable then
-- Print the original configuration
print("Original configuration:")
for key, value in pairs(configTable) do
print(key, value)
end
-- Modify the configuration table
configTable.newKey1 = "newValue1"
configTable.newKey2 = "newValue2"
-- Write the modified configuration back to disk
api.WriteConfig(fileName, configTable)
print("Modified configuration written to: " .. fileName)
else
print("Failed to read config file: " .. fileName)
end
end
-- Example usage: Modify and write the contents of "exampleConfig.ghost"
ModifyAndWriteConfig("exampleConfig.ghost")