User Tools

Site Tools


This is an old revision of the document!

Doomsday Script reference guide

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, for instance managing engine configuration and controlling 3D model asset animation.

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!"
        return "Nay, it is false."
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.
  • 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[1] = 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.


Built-in types

  • Number
  • Text
  • Time
  • Array
  • Dictionary
  • Function
  • Record

Built-in constants

  • True
  • False
  • None
  • Pi

Built-in functions

Function Description
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

Feature walkthrough

Standard library modules

The Doomsday Script Standard Library consists of a collection of native built-in modules and script modules.

  • App: application core (native)
  • appconfig: application configuration variables (imported by Config)
  • Config: configuration variables (special persistent namespace)
  • Core: built-in classes and core language functionality
  • Defs: definitions read from DED files
  • DisplayMode: information about display modes (native)
  • gui: routines related to the graphical user interface
  • Input: input subsystem (native)
  • math: math routines (native)
  • recutil: routines for manipulating records
  • SavedSession: routines for manipulating savegames (native)
  • Version: version information (native)

Feature status

Doomsday Script is not yet fully utilized (as of 2.1). Upcoming uses include:

  • Backend of the console prompt, console variables and commands.
  • Manipulating level data and game objects.


script/reference.1573974958.txt.gz · Last modified: 2019-11-17 09:15 by skyjake