Ulysses
General => Developers Corner => Topic started by: JamminR on February 24, 2008, 09:06:05 AM
-
Hi fellow lua developers.
Is there a reasonably easy way to grab a table of existing convars matching a string?
Example, I want to make a table of all convars matching "sbox_". I want this to be dynamic in case the server my function will be running on has non-standard sbox settings (such as Wire or other mods that might use sbox_ variables)
In game console, I can type "find sbox_" and a list of all matching sbox convars will be returned.
Is there a way in Lua to get that list? Though I'd expect it would be table, string would be fine and I'll turn it into a table.
-
I wanted to do this for a long time as well... :)
The easiest/'best' way would be to override the make convar function.
-
How would over riding 'make' return a list of unknown variables matching "blah"??
I want a lua equivalent of "find blah", returned in a table/string.
-
You keep all the lua-registered convars somewhere you can search.
-
"cvarlist sbox" ?
Edit: oh, building a table from these results...
-
You keep all the lua-registered convars somewhere you can search.
I'm totally lost.
The convars I want aren't lua registered I don't think.
Some are Gmod hard coded sbox_max_blah variables set in server.cfg (or just from console.)
Does Garry use Lua to register those?
I don't want to have to overwrite any game lua functions if I can help it.
"cvarlist sbox" ?
Edit: oh, building a table from these results...
That is a console command, isn't it? I could run 'find sbox_' too. Does me no good if I can't store the results in some way.
Even a multiline \n string could be turned into a table.
-
sbox_* is registered with lua.