Skip to content
WhyIsEvery4thYearAlwaysBad edited this page Apr 3, 2021 · 43 revisions

NOTE:

  • Syntax can change at any time since the standard syntax is still uncertain.
  • How the captions display will vary based on your HUD display.
  • Titles should be written as though you are writing captions.

Comment

/* ... */ makes a block comment. // makes an inline comment.

Example:

/*
This command menu is unfinished. Don't compile yet.
*/
// TODO: Remove unicode support.

Bind

A bind is a command or string of commands that executes when a key is pressed. (More Info)
In the CMG Language, a bind is a command string that is displayed as its title, and bound to a number key.

Syntax: BIND <title : string> <command string : string> |

Example: BIND "{Meme Bind}" "say Random Crit jokes are overrated." |

Display in command menu:

"1. {Meme Bind}" in source captions.
*1 key is pressed*
Output:

"Random Crit jokes are overrated" in chat.

The number key bound is determined by the bind's placement in a command menu. For example in the command menu:

"warnings" {
	BIND "Sniper!" "say_team Sniper Ahead!" |
	BIND "Sticky Trap!" "say_team Sticky Trap Ahead!" |
	BIND "Flank!" "say_team Sniper Incoming Flank!" |
}

The bind titled "Sniper!" will be bound to the 1 key, since it appears first.
The bind titled "Sticky Trap!" will be bound to 2.
The bind titled "Flank!" will be bound to 3.

You can use prefix a bind, toggle bind, or command menu with NOFORMAT to display with only the bind title, instead of using the format KV. You can also use NOEXIT to prevent the bind from exiting, but it will not work on command menus because they do not exit menus by default. If a NOEXIT keyword was used on a command menu, the compiler will default to an error.

e.g

NOFORMAT "<I>Credits<I>" {
        NOFORMAT TOGGLE BIND "<—————————— Do you know the way to town sir?<cr>" "" "Do you know the way to town sir? ——————————><cr>" "" |
        NOFORMAT NOEXIT BIND "——————————> Created By ME! <——————————<cr>" "" |
        NOFORMAT TOGGLE BIND "<—————————— Yeah it's back the way you came.<cr>" "" "Yeah it's back the way you came. ——————————><cr>" "" |
}

Result in game:

<—————————— Do you know the way to town sir?
——————————> Created By ME! <——————————
<—————————— Yeah it's back the way you came.

Toggle Bind

Syntax: TOGGLE BIND <title : string> <command string : string> <title : string> <command string : string> ... |

A toggle bind is a bind with multiple states of command strings that are ran by activating the bind a certain amount of times. Each time a toggle bind is ran it changes its current command string to the next state until it modulates back to its first state. The first 2 strings are always the first state.

Example:

TOGGLE BIND "Debug Full" "debug=on" "Debug Minimal" "debug=minimal" "Debug Off" "debug=off"  |

Result in-game:
1. Debug Full *hits 1*
*executes "debug=on"*
1. Debug Minimal *hits 1*
*executes "debug=minimal"*
1. Debug Off *hits 1*
*executes "debug=off"*
*cycles back to Debug Full*

Command Menu

Syntax: <title : string> { ... }

A command menu (or cmenu/CMenu for short) is a collection of binds and toggle binds. You can insert a command menu into parent command menus, or run "exec $cmenu_<unformatted title>"
NOTE: In the files, a command menu uses an unformatted title which:

  • Has caption tags, punctuation, and non-ascii characters removed.
  • Is all lower case.
  • All spaces ( ) are replaced with underscores (_).

For instance, the command menu titled "Callouts" will use "callouts" internally in the command menu vpk. If you were to open this command menu, you'd need to call exec $cmenu_callouts.

Example:

"<B>Comp Callouts<B>" {
	BIND "ENEMY PUSHING" "say_team **ENEMY PUSHING**" |
	BIND "ENEMY SPY" "say_team *ENEMY SPY ROUND HERE*" |
}

*executes $cmenu_comp_callouts*
Result in game:
1. ENEMY PUSHING <newline>2. ENEMY SPY

To exit the menu, select an option, or run cmenu.exitmenu.

Key Value

Key-Values (KVs) are the program's main way of configuration. They can only be assigned.

Syntax: <key : identifier> = <value : string> Example: resetkeys = "bind 1 quickbuild_1; bind 2 quickbuild_2; bind 3 quickbuild_3; bind 4 quickbuild_4"

Key Values used by the generator:

  • resetkeys - Command-String that runs after selecting a bind. Default value is "bind 1 slot1; bind 2 slot2; bind 3 slot3; bind 4 slot4; bind 5 slot5; bind 6 slot6; bind 7 slot7; bind 8 slot8; bind 9 slot9; bind 0 slot10".
  • predisplay_time - cc_predisplay_time is set after exiting menu. Key Value determines the cvar value. Default value is "0.25".
  • linger_time - cc_linger_time is set after exiting menu. Key Value determines the cvar value. Default value is "0".
  • format - Sets formatting for titles of binds and command menus. Default value is "$(nkey). $(str)". All "$(nkey)" strings will be replaced with the bind/command menu's resulting number key, and all "$(str)" strings will be replaced with the bind/command menu's actual title.
  • consolemode - If set to true, then use the console to display binds instead of captions. Default value is "false".

Sidenote: If the format KV is surrounded in <B> or <I> tags, you will have to append a space to the end of the string for the <cr> tag to work.

Legacy KVs:

  • #cvm.boldbydefault - If set to true, will bold all command menus with <B>. As a result, <B> in titles will unbolden the selected characters. Note that the number key prepended will not be effected by this trick. Default value is "false".
  • #cvm.italicizedbydefault - If set to true, will italicize all entries with <I>. As a result, <I> in titles will unitalicize the selected characters. Note that the number key prepended will not be effected by this trick. Default value is "false".
  • #cvm.defaultcolor - Color tag that is inserted into every caption. Note that the number key prepended will not be effected by any tags. Default value is "".

Clone this wiki locally