I am pretty new to this, so apologies if my terminology is not accurate or if this question is just plain stupid, I’m trying to learn as I go.
I have been working on making a system that spawns objects (trees, rocks, bushes, etc) with randomized settings.
I figured out I can organize my settings in two different ways.
The first way is just storing all settings for each object in a single dictionary. This was hard to read so I added a comment line that helps me know where to reference. (for the sake of this example, I am only using one object and many of the values are simply placeholders)
objects = {
-- ["Object"] = {[1]name,[2]type,[3]model,[4]size,[5]rotation,[6]HMin,[7]HMax,[8]AMin,[9]AMax,[10]ColorA1,[11]ColorA2,[12]ColorA3,[13]ColorA4,[14]ColorB1,[15]ColorB2
["PineTree"] = {"Pine Tree","Tree",objj.Tree_Pine,"currently unused",math.random(0,360),0,0,0,0,"Earth green","Sea green","Dark green","Parsley green","Brown1","Brown2"},
}
The other way is to put each individual setting ‘one level deeper’ (not sure terminology here)
objects = {
["PineTree"] = {
["Name"] = "Pine Tree",
["Type"] = "Tree",
["Model"] = objj.Tree_Pine,
["Size"] = "currently unused",
["Rotation"] = math.random(0,360),
["HMin"] = 0,
["HMax"] = 0,
["AMin"] = 0,
["AMax"] = 0,
["ColorsA"] = {"Earth green", "Sea green", "Dark green", "Parsley green"},
["ColorsB"] = {"Brown1", "Brown2"},
},
}
which is way easier to read/edit. I even have all the random colors options yet another level deep for even easier organization.
So, aside from the 2nd option being easier to read/edit as a developer, is there much of a difference between them? If so, what? Is there any reason to organize like option 1? Does the 1st option access values any faster or something?.. I dunno…
Any discussion is appreciated!
Edit: I would like to add, if it is relevant, that these settings are not going to be changed once they have been ‘perfected’ so the visibility/readability factor is not that important in the long run.
Also, there could be tens-of-thousands of objects that all spawn on server start, so if option 1 is indeed faster, I would rather have performance over human-readability in the long run.