Pivity

How to read/write from a txt file

Last read Never
#1

I need a config file, a way of storing data generated server side and a way of importing a list of words from a txt file.

Please help guys I have no idea how to do this, wiki was no help.

#3

Did you even bother to read the second line he wrote? lmao

#4

I understood the second line as if he was not able to find the wiki pages for his problem, then I didn't understand it correctly, sorry about that.

Friendly x 1
#5

I already had found the wiki page but I do not know how to use it.

#6
-- DATA TO STORE
local myServerData = {
    URL = "https://www.gmodstore.com/",
    Language = "EN",
    SomeInt = 5
}


-- WRITING DATA
local jsonString = util.TableToJSON( myServerData, true )   -- https://wiki.facepunch.com/gmod/util.TableToJSON
file.Write( "my_server_data.json", jsonString )             -- https://wiki.facepunch.com/gmod/file.Write


-- READING DATA
local fileContent = file.Read( "my_server_data.json", "DATA" ) -- https://wiki.facepunch.com/gmod/file.Read
local myTable = util.JSONToTable( fileContent )             -- https://wiki.facepunch.com/gmod/util.JSONToTable
Agree x 2Winner x 1Friendly x 1
Users viewing this thread
Nobody