Author Topic: Convar table?  (Read 4620 times)

0 Members and 1 Guest are viewing this topic.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Convar table?
« 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.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Convar table?
« Reply #1 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.
Experiencing God's grace one day at a time.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Convar table?
« Reply #2 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.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Convar table?
« Reply #3 on: February 24, 2008, 11:44:51 AM »
You keep all the lua-registered convars somewhere you can search.
Experiencing God's grace one day at a time.

Offline Chironex

  • Full Member
  • ***
  • Posts: 197
  • Karma: 11
  • Formerly known as Kyzer
Re: Convar table?
« Reply #4 on: February 24, 2008, 01:17:12 PM »
"cvarlist sbox" ?

Edit: oh, building a table from these results...
« Last Edit: February 24, 2008, 01:18:43 PM by Kyzer »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Convar table?
« Reply #5 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.
« Last Edit: February 24, 2008, 01:28:26 PM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Convar table?
« Reply #6 on: February 24, 2008, 02:34:30 PM »
sbox_* is registered with lua.
Experiencing God's grace one day at a time.