How do I improve this settings module?


Alright so, this is a very simple set of code;

  1. what could I do to organize this code a bit more?
  2. what word could I use to replace the word Variables in Settings.Variables?
local Settings = {}

Settings.Variables = {
	Toggles = {
	},
	Variables = {
	},
	Values = {
	},
}

Settings.Bans = {
	["Name of Banned User,'Preferably a Username" ] = {
	}
}

Settings.Admins = {
	["Ranks"] = {
	},
	["Groups"] = {
	}
}
return Settings

There isn’t much more you can do to make the code much better, mostly just subjective formatting changes like so:

-- My method:
local Settings = {
    Variables = {
        Toggles = {
        },
        Variables = {
        },
        Values = {
        },
    }

    Bans = {
        ["Name of Banned User,'Preferably a Username" ] = {
        }
    }

    Admins = {
        ["Ranks"] = {
        },
        ["Groups"] = {
        }
     }
}


return Settings

-- Another persons method (I forgot their name):

return {
    Variables = {
        Toggles = {
        },
        Variables = {
        },
        Values = {
        },
    }

    Bans = {
        ["Name of Banned User,'Preferably a Username" ] = {
        }
    }

    Admins = {
        ["Ranks"] = {
        },
        ["Groups"] = {
        }
   }
}

I personally don’t see why you would change the name of the Variables table inside the settings, if it holds variables, then the name works. I also usually call modules like these “configs”, which function as a better way of storing values and variables than the actual Configuration instance.

The reason I want the change the title Variables is because it’s being used twice, in the settings table variables and then inside there’s another table called variables. Also, I’ve experienced issues while trying to have variables inside the modules main table… hence why I work around that.

1 Like

You could rename it to MasterVariables or Tables.

EDIT:

I saw it, I know the frustration of people not reading your edit, though I don’t really know what you mean by that, like just having variables inside you main tables like so:

local e = {
    local f = "f"
}

return e

If that is the case, just remove the local and it should work.

1 Like