You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Crafty-Codes edited this page May 6, 2023
·
5 revisions
Read from data file
localfile= {} -- Create a variable in which it will be stored-- Here we are loading the file with the path, the mode "t" (Only text chunks.) and out variable in which we will load the configlocalf,err=loadfile("path/to/file", "t", file) -- load the fileiffthenf() -- run the chunk-- now file should now contain our dataprint(file.variable) -- tableelseprint(err)
end
Write to data file
-- config_writer-- file: the file to write in-- name: name of the whole module-- config: the config modulefunctionconfig_writer(file, name, config)
-- Write start of config file:write(name.." = {\n")
-- Go through all config fieldsforkey, valueinpairs(config) dofile:write(key.."=" .."\"" ..value.."\"" ..",\n")
end-- End the configfile:write("}\n")
end