Doomsday Script reference
This article describes the Doomsday Script language and its role in the Doomsday 2 architecture.
As a scripting language, Doomsday Script serves in many roles, including user interface and menu functionality, configuration (cf. traditional cvars), high-level game logic (cf. Hexen ACS; XG), and game data definitions.
Doomsday Script is not a compiled language and thus is not intended for high-performance or time-critical tasks. Game plugins written in native code should be used for processing-intensive functionality.
def exampleFunc(a) if a return "It is true!" else return "Nay, it is false." end end print exampleFunc(True)
The syntax of the language is heavily influenced by Ruby and Python, with a few notable differences:
- The amount of indentation whitespace has no meaning. Compounds are explicitly closed with end (Keyword).
- A colon (:) always indicates a single-line compound that does not need to be closed:
def func2(): return 'World'
- "Objects" are classless and called records. They correspond native de::Record instances:
record myrec myrec.newMember = 100
- There are no non-modifiable tuples, just arrays:
array = [1, 2, 3, 4] array = 100 # array is now [1, 100, 3, 4]
- There are a couple of special assignment operators. Global assignment (
:=) will assign into variables in parent scopes if no local variable with the given name is found. Weak assignment (
?=) will only assign a value if a variable has not yet been created.
|deserialize (Function)||reconstruct data from an array of bytes|
|dictkeys (Function)||returns the keys of a dictionary as an array|
|dictvalues (Function)||returns the values of a dictionary as an array|
|dir (Function)||returns the variable names of a namespace as an array|
|eval (Function)||parses and executes argument as a script, returns result|
|File (Function)||returns a Core.File object|
|floor (Function)||rounds a number down to an integer|
|globals (Function)||returns the global namespace as a record|
|len (Function)||determines the length/size of the argument|
|locals (Function)||returns the local namespace as a record|
|members (Function)||returns the members of a record as a dictionary|
|Number (Function)||converts argument to a number value|
|Record (Function)||duplicates a record or creates an empty one|
|serialize (Function)||serializes data into an array of bytes|
|subrecords (Function)||returns the subrecords of a record as a dictionary|
|Text (Function)||converts argument to a text string|
|Time (Function)||converts argument to a time|
|timedelta (Function)||calculates difference between two times (as seconds)|
|typeof (Function)||returns type of value as a text string|
- Basic expressions
- Operator expressions
- Statements and compounds
- Script return value
Standard library modules
The Doomsday Script Standard Library consists of a collection of native built-in modules and script modules.
- App (Module): application core (native)
- appconfig (Module): application configuration variables (imported by Config)
- Config (Module): configuration variables (special persistent namespace)
- Core (Module): built-in classes and core language functionality
- Defs (Module): definitions read from DED files
- DisplayMode (Module): information about display modes (native)
- gui (Module): routines related to the graphical user interface
- Input (Module): input subsystem (native)
- Math (Module): math routines (native)
- recutil (Module): routines for manipulating records
- SavedSession (Module): routines for manipulating savegames (native)
- Version (Module): version information (native)