Updated PropertyBag code for alternative filenames
Around the 20th of June, alec5216 suggested or rather posted code to commit to manage an alternative filename, the technique was simple, it involved passing the filename when the PropertyBag was initialised. This could have been a good option UNTIL...
I suggested to a particular user that they could keep saving data to various files using propertyBag. Under the option that was available, it would mean having a variable for each of the filename, which is fine, at least one would know what they are dealing with and reduce errors. However, that is not the modular way to keep the code flexible. So I have added two functions to the code one that can be accessed by the users and one that is internally used by the PropertyBag class itself.
getFilePathFor(filename) -> this is an internal code that is used by the class and the user does not have to really bother with this
setFileNameTo (filename) -> this is the function that is important and used to change the filename at any time.
So here is how one would use it in their code
local prop = require("property") local propertyBag = prop:init() propertyBag:setFilenameTo("settings") --Properties created in memory propertyBag:setProperty("MyName", "Jayant C Varma") propertyBag:setProperty("MyCompany", "OZ Apps") propertyBag:setProperty("myURL", "www.oz-apps.com") --Now let us save this to the disk propertyBag:SaveToFile()
now this should save data to the file called settings than to defaults as it would have otherwise.
Hope this helps a lot of you that are using PropertyBag in your code. Would appreciate if you can drop me a line and tell me that you are using it in our code when you publish your game/app.