-
Notifications
You must be signed in to change notification settings - Fork 7
Call of Duty scripting language syntax
This document describes the Call of Duty scripting language syntax.
There are two types of comments. Comments work anywhere except inside strings. Block comment will separate two elements in a similar manner to a whitespace (meaning that the safe substitution for a comment is a whitespace).
// this is a single line comment
/* this comment
can span
across
multiple lines
*/
A file can contain in any order function definitions, #using_animtree statements and function definitions inside a developer comment block (each function has to be inside its own developer comment block).
Functions can be defined in following way.
myfun()
{
// your code here
}
myfun2(arg1, arg2, arg3)
{
}
myfun3 ( arg1 , arg2 , arg3 ) { }
Function name and argument names must follow the basic identifier format.
Third example demonstrates possible positions where whitespace may be included.
Identifiers are sequences of ASCII code points 65-90 (A-Z), 97-122 (a-z), 48-57 (0-9) and 95 (_). Identifiers can not be equal to reserved keywords and may not start with a number.
Following keywords are reserved and may not be used as identifiers (case sensitive)
- break
- case
- continue
- default
- else
- endon
- false
- for
- game
- if
- level
- notify
- return
- self
- switch
- thread
- true
- undefined
- wait
- waittill
- while
Additional keywords were added
- breakpoint
- waittillframeend
Developer comments use syntax /# ... #/
and the code is being used from those if the developer
cvar has a nonzero value. The comments can be wrapped around single function definitions or code inside function definitions. Developer comments may not contain a wait statement. Functions that have been defined inside developer comments cannot be referenced in code that is not inside a developer comment.
Since Call of Duty 2 function definitions can be wrapped around multiple function definitions.