User Tools

Site Tools


script

Table of Contents

Scripting

Doomsday 2 has a built-in scripting language that is used internally for various tasks.

Overview

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.

Example:

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.
  • 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.
2017-03-13 14:25

Index

script.txt · Last modified: 2018-12-15 20:59 by skyjake