There are many scripts commonly found in QL configs, and quite some of them use complex vstrs. Complex vstrs are often ugly, repetitive, unreadable and unmanageable. This makes it easy by using a first file where common scripts are abstracted in easy to use macros. This file is then preparsed to produce a .cfg you can use in QL.
Preparser? Macro?
A preparser is a program that will read a file(your config), do some changes then output a new file(your parsed config) with the changes done. The file is then supposed to be read by another program(Quake Live). In ASCII art:
Your config ----(preparser)----> Your preparsed config ---->(QL)
A macro is a concept used by some preparser programs. Defining a macro means saying "Okay, from now on, every time you see X, replace it with Y". Of course, it gets a bit more complex, but that's the basic thing.
When a parser uses the concept of macros, we call it a macro processor.
More on wikipedia.
Why use that?
Because often you see patterns that are in every config out there: For example, if you play more than one mode, say CTF and TDM, you'd have binds for each of them, but you don't want to have them use twice the number of keys. So you use some vstr magic to make a couple buttons to switch through your two set of binds. That takes effort, isn't pretty, discourages people. With this set of macros you could just do:
bind F9 toggle_configs((
{CTF},{
bind a say_team INC HIGH
...
}),({TDM},{
bind a say_team RUSH QUAD
...
}))
And you would be done with it :) Same goes for the streamer, the movie maker, which would want to keep a "Playing" config, a "Streaming" and/or a "Video" config.
How to edit my config
Basically, paste the contents of the attached file at the beginning of your config, and put .m4 at the end of the file name(To mark it needs to be preprocessed).
Edit the very beginning of the stuff you just pasted(it's explained), then keep your config intact only placing macros as shown in the examples from the
Macro reference section. {} are used for quoting. Unmatched { or }s are likely to break the whole thing. if you really want to have them in your config, double them like this: {{ blabla }}.
How to preparse my config
Grab
m4 from gnuwin32(First link in the Download section).
Open a console and type
C:/full/path/to/m4.exe C:/full/path/to/input.file >C:/full/path/to/output.file
ou usually want to have what was described as
Your config as input file and
Your preparsed config as output file. You can probably drag and drop files from the explorer to get their full path.
Be sure to backup your config first!
If you're on OSX, first install
GNU m4 from darwinports. On Linux install it from your package manager if you haven't done so yet.
Open a terminal and type
m4 /path/to/input.file >/path/to/output.file
You usually want to have what was described as
Your config as input file and
Your preparsed config as output file. You can probably drag and drop files from Finder/your file manager to get their full path.
Be sure to backup your config first!
Other notes
- Consider this beta-quality.
- QL should be able to save/restore properly a config generated with this(as long as you don't use exec in it) as long as you don't put a cvar_restart in it. (To clear unused cvars go to
Game settings on the website and click
Reset all my settings)
- Configs generated with this will have some parts seriously mangled, meaning editing it will be a difficult thing. So please, please, please,
keep your non-preparsed config in a safe place.
- Make sure to use proper "" quotations in your bind and set line, especially if they are inside a toggle_configs.
Macro reference
echo
Sends a message to yourself
bind a echo Hello world!
Most other macros already use this one to provide feedback.
wrap_message(command)
Runs the given message along with a message
bind a wrap_msg({spec fc})
wrap_confirm(command[, command[, ...]])
Wraps each command into a command which will prompt you for a confirmation (press the key again). Also provides a vstr to reset them.
wrap_confirm({vote yes}, {vote no}, {ragequit}...)
bind F1 vstr vote_yes_c
bind F10 vstr ragequit_c
...
bind F12 vstr confirm_reset // Resets all confirm prompts you triggered
The vstr name is the command name with anything else than letters and numbers converted to underlines(_) with _c at the end.
toggle_configs( (name, config)[, (name, config)[, ...]])
Makes a toggle bind to cycle though multiple configs.
bind a toggle_configs(
({Normal},{
set cg_railStyle 1
set cg_lightningStyle 5
...
}),
({Quality},{
set cg_railStyle 2
set cg_lightningStyle 1
...
)
Pretty much any config should work, special cases are handled. First given config will be run when the config is loaded. However, this can only be used once.
toggle(setting)
toggle(setting, value, value[, ...])
Toggles a cvar between multiple values.
bind a toggle({cl_demorecordmessage})
bind b toggle({r_texturemode},
{GL_NEAREST}, {GL_LINEAR_MIPMAP_NEAREST},
{GL_LINEAR_MIPMAP_LINEAR})
It defaults to use 0 and 1 if no values are given. First value will be set when the config is loaded, so if you don't give values default on-load value will be 0.
Known issues
- toggle_config is very slow when being preprocessed.
- command splitting is suboptimal, as I don't know the maximum vstr length.
Example config
Mine
(If you have one you wanna put as example here, tell me :))
Changelog
Sat Feb 27
- Initial release