This is an old revision of the document!
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:
def func2(): return 'World'
record myrec myrec.newMember = 100
array = [1, 2, 3, 4] array = 100 # array is now [1, 100, 3, 4]
:=) 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|
The Doomsday Script Standard Library consists of a collection of native built-in modules and script modules.