Ulysses

General => Developers Corner => Topic started by: JamminR on February 24, 2008, 09:06:05 AM

Title: Convar table?
Post 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.
Title: Re: Convar table?
Post by: Megiddo on February 24, 2008, 10:21:04 AM
I wanted to do this for a long time as well... :)

The easiest/'best' way would be to override the make convar function.
Title: Re: Convar table?
Post by: JamminR on February 24, 2008, 10:53:38 AM
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.
Title: Re: Convar table?
Post by: Megiddo on February 24, 2008, 11:44:51 AM
You keep all the lua-registered convars somewhere you can search.
Title: Re: Convar table?
Post by: Chironex on February 24, 2008, 01:17:12 PM
"cvarlist sbox" ?

Edit: oh, building a table from these results...
Title: Re: Convar table?
Post by: JamminR on February 24, 2008, 01:25:29 PM
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.
Title: Re: Convar table?
Post by: Megiddo on February 24, 2008, 02:34:30 PM
sbox_* is registered with lua.