Dungeon Souls Editor Quick Onboarding Modules Items Sprites Functions Steam Workshop Contact

Premise

The purpose of the Quick Onboarding is to explain the highest amount of concepts, with the highest detail, in the shortest possible manner. This is done by using similar concepts related to other programming languages (such as Java, C++, GML etc.). Therefore, we recommend reading the remainder of this page only if you have experience in coding, or you've done the tutorial about creating your first module.

In this page, syntax of the language will be explained, as well as any important concepts of the language.

Syntax

The syntax of DSML is similar to the syntax displayed in Java, C++ and GML. It shares similarities to GML in regards to the fact that type declaration is implicit, which means variables do not require to have a type to be declared. In DSML, variables are declared from the moment a value is first assigned to them. However, like GML, keep in mind that accessing a variable that has not been declared (i.e. initialized with a value) will result in an error.

The following example is a valid variable declaration:

a=5;
sum=5+a;

However, the following example will produce an unknown variable error:

...
sum=5+a;

Similar to Java and C++, each statement ends with a semicolon (;). A statement can be composed of mathematical operations or function calls, such as:

loremIpsum=generateLoremIpsum(); #Function call assignment

a=5+2+8/3*8*2; #Mathematical assignment

a=5+getPlayerAttribute("hp");

On the topic of functions, currently, DSML function calls only support passing either variables or values as arguments, meaning that the following statement produces statement produces an error:

a=sum(getPlayerAttribute("resist"),getPlayerAttribute("defense"))

But, the following statement is valid:

b=getPlayerAttribute("resist");
c=getPlayerAttribute("defense");
a=sum(b,c);

Finally, keep in mind that, similar to GML, despite the fact that types are implicitly declared, type cast errors still apply, which means that the following statement produces an unsupported addition error:

text="Hello World!";
value=5;
a=value+text;

Mathematical Operators

DSML's mathematical operators can be applied to any given value, whether it's a real number, string, variable or result of a function call. The following table describes the available operators, as well as their effects:

Operator Name Description
+ Addition In the mathematical expression a+b, adds the value of b to a, generating a new value equivalent to a+b. Both values must be of the same type.
Can be applied to:
  • Numbers (2+2)
  • Strings ("2"+"2")
- Subtraction In the mathematical expression a-b, subtracts the value of b to a, generating a new value equivalent to a-b.
* Multiplication In the mathematical expression a*b, multiplies the value of b to a, generating a new value equivalent to a*b.
/ Division In the mathematical expression a/b, divides a by the value of b , generating a new value equivalent to a/b. Divisions performed are always real divisions (and not integer division).

Statements

DSML currently supports the following statements:

Statement Name Statement Syntax Description
If Statement if (condition) { expressions;} Executes a block of code in case the result of the conditional test is true.
Else If Statement if (condition) { ... } else if (conditionB) {...} If a preceed if fails, another condition is checked. If the condition is true, the corresponding block of code is executed.
Else Statement if (condition) {...} else {...} If the preceeding if fails, the block of code that follows else is executed. Effectively the same as performing the following statement: if (condition!=1).
While Statement while (condition) {...} Executes the code that is located after the condition, as long as the conditional test is true.
For Statement for (assignment;condition;codeBlock) {...} Executes the code that is located after the statement, as long as the conditional test is true. At the start of the cycle, an assignment statement is executed, if it exists. At the end of each iteration, the code contained in codeBlock is executed.

More statements are planned to be implemented in future versions of the modding language.

Comparison Operators

DSML supports the following comparison operators:

Comparison Name Comparison Symbol Description
Equal == In the comparison expression a==b, condition is true if a is equal to b.
Not Equal != In the comparison expression a!=b, condition is true if a is not equal to b.
Greater Than > In the comparison expression a>b, condition is true if a is greater than b.
Less Than < In the comparison expression a<b, condition is true if a is less than b.
Greater Than Or Equal >= In the comparison expression a>=b, condition is true if a is greater than or equal to b.
Less Than Or Equal <= In the comparison expression a<=b, condition is true if a is less than or equal to b.

Conditional Operators

DSML supports the following conditional operators:

Conditional Name Conditional Symbol Description
And && In the condition expression a && b, condition is true if both a and b are true.
Or || In the condition expression a || b, condition is true if either a or b is true.

Special Characters

DSML supports the following special characters:

Special Character Name Special Character Symbol Description
New Line # Represents a new line of text. The operator is equivalent to the \n special character of languages like Java and C.
Note: The character choice has to do with Dungeon Souls' base engine (Game Maker Studio 1.4).

Values

DSML currently supports the following constant values:

Value Name Value Syntax Description
Real Value Any Number [regex: [0-9]+(\.[0-9]+)?] It's interpreted by the engine as a real number.
String Any text that starts and ends with quotes "..." It's interpreted by the engine as text.

More values are planned to be implemented in the future, such as booleans.