• How does the file. library works?
    4 replies, posted
Yes, a noob question. I think.. Right now im trying to give a new Addon several changeable settings. And i would like to save those settings in a txt file in data, so they dont get resetted everytime you restart GMod. I know that file.Write makes a file, file.exists checks if it exsist etc.. The main problem im having is: How do i add more things to the file, and how can i use seperate parts of that file to use them as settings? For example i have one addon that makes a txt file that contains true true true false true true true 720 One of my Addons already uses one file that contains 0/1, and i can use that in a if statement. But when it comes to addin a second setting (without making a second txt file) im already out...i watched some tutorials and the gmod wiki and tryd to figure it out, but nothing really shows how to save several settings in one file, or even checking several parts in a file. Like, file.Read returns the WHOLE file..not just one of the settings in there. So if anyone can explain it, or give me a link to a tutorial/documentation that explains that that would be awesome
Store settings in a table and use util.TableToJSON
so putting stuff in a table would be this? file.Write("Settings.txt", "SettingsTable = {}") file.Append("Settings.txt", SettingsTable[2]) or how would i create/edit a table?
A file is simply a string. If you go the util.TableToJSON/util.JSONToTable route you'll have to write and read from the whole file to change any part of the table, there's no way to pick and choose. If you want to go the way of how you did it in the first post ("truetruetruefalsetruetruetrue720") you'll have to create your own method of getting each part from the string.
well the example i showed was from a other addon. And its a gmodstore addon which i had access too while i was staff of a server. Which im not anymore. So i cant look at the way anymore
Sorry, you need to Log In to post a reply to this thread.