Expressions - Pararock/QSPSaveEditor GitHub Wiki
Expression - a set of constants, variables, functions related to various operations. When writing expressions you can use parentheses.
- &
- OR
- AND
- OBJ, NO
- =, <, >, !, <>, <=, >=, =<, =>
- +, -
- MOD
- *, /
- +, - (unary)
PS: Expressions in parentheses have the highest priority.
-
($Expression1 & $Expression2)
- union operation string expressions. -
#Expression1 OR #Expression2
- operation "or". If at least one of the adjacent expression is true, the whole expression is true. -
#Expression1 AND #Expression2
- operation "and". If both are standing next to the expression is true, the whole expression is true. -
#Expression1 MOD #Expression2
- operation of calculating the remainder of the division. -
OBJ $Expression
- true if the backpack is the subject of$Expression
. ??? -
NO #Expression
- negation. True, if the#Expression
is false, and vice versa. -
Expression1 = Expression2
- true if the values of adjacent expressions are equal. -
Expression1 < Expression2
- true if the value of the expression on the left is less than the right expression. -
Expression1 > Expression2
- true if the expression value is greater than the value on the left to the right expression. -
Expression1 ! Expression2
orExpression1 <> Expression2
- true if the values of adjacent expressions are not equal. -
Expression1 <= Expression2
orExpression1 => Expression2
- true if the value of the expression on the left is less than or equal to the right expression. -
Expression 1 >= Expression2
orExpression1 => Expression2
- true if the value of the expression on the left is greater than or equal to the right expression. -
#Expression1 [Operation] #Expression2
Operation can be any basic math operator (+ , - , *, /). Example:#Expression1 + #Expression2
-
+ #Expression
or- #Expression]
- Unary plus / minus. They are located in front of the numerical expression and change the sign of the value of the expression (in the case of "-").
The QSP variable / array element can contain two values: text and numeric at the same time.
When using the text value of a variable, the name start with the symbol "$" $Player_Name"
. To use the integer value, use the variable name.
a = 5 & $a = 'apple'
$a
a
In this last example, a
hold the integer value 5 and $a
hold the string apple.
An integer variable is written directly with a number (eg, 4535). QSP supports only whole numbers. Floating point numbers (fractions) are not supported.
Boolean value are stored as integer. 0 is considered false
and and all the others integer values are considered true. However, it is strongly recommended to use -1 as true
.
Text must be in quotes. Quotes can be either single quotes (') or double quotation marks. (") Two consecutive quotation marks are used to insert a quote inside text.
*PL 'Byte Soft''s QSP'
*PL "Byte Soft's ""QSP"""
The following lines will be shown on screen.
Byte Soft's QSP
Byte Soft's "QSP"
It is possible to write text on multiple lines. The line break and indentation will be kept. Examples:
'This text
It will be located at
multiple lines'
$A = 'And this
text
also'
a = 2 & act 'Multiline
name ': gt 'next'
You can use the operator + and the operator & to concatenate string together. Example
*PL 'The ' + 'door ' + 'is closed.'
*PL ('The ' & 'door ' & 'is closed.')
Will both print the string The door is closed.
on the screen.
Any combination of constants, variables, functions. When calculating the value of the expression engine (if possible) converts data types automatically.
In the string constants in the basic description of the locations and names of basic actions it is possible to embed the values of expressions. These "sub-expression" must be between double angle brackets: "<<" and ">>", before and after which there can be any text, including such "sub-expression." For example, instead of the operator pl 'i='+str(i) You can write pl 'i=<>'
More examples: numberOfGoblins = 5 'You are surrounded by <> goblins!' pl 'Your name is <<$PlayerName>>, you are in a <<$curloc>>.'
Examples of the use of nested "subexpressions":
i = 6 & j = 6
pl val('<<val("<<i>>")>><<j>>')
pl val('<<str(val("<<i>>"))>>')
will produce the result
56
5
Since "subexpressions" calculated in string constants, in order to calculate the embedded "subexpressions" requires the presence of the embedded string constant.