Open Monniasza opened 4 years ago
Strings must be now explicitly stated either by single or double quotation marks, otherwise, they will be treated as variables, which might cause errors.
To create a new key, you must place '+' or '$' before the setter
All other existing syntax will be preserved
getVar(variable)
- get a variable, starting heregetVarRoot(variable)
- get a variable by the name, starting from root
or key correspondingly. The first parameter is optional and is used to track the number of calls. ##$...$
instead.
regexp(pattern,string)
- run regexp expression on a stringgetKey(...)
:
getKeyValue(...)
: Like getKey(...)
, but gets values, not the keys themselves.setKey(...)
:
setKeyDuplicate
functionsetKeyDuplicate(...)
:
call(func, inputs)
: calls a function with given list of inputsgetKey(...)
:
getNodeValue(...)
: Like getNode(...)
, but gets values, not the nodes themselves.setNode(...)
:
setKeyDuplicate
functionsetNodeDuplicate(...)
:
'$' as a modifier - creates a temporary variable '$$' as a modifier - creates a long-term variable, but it is removed after all scripts finish.
String, node, key, number, boolean, list, anonymous function
Achieved through specialized functions.
Double symbols are much rarer in the text - to say text explicitly, use quotation marks.
It will need a new file format - which distinguishes it from simpler patches. Suggestions for file extension:
Existing patches should not be called 'scripts' - they will be more advanced form of data.
FUNCTIONDEF[...] <%...%>
. Place inputs within square brackets, and in double curly brackets place code. The FUNCTIONDEF
is a reserved name in this programming language (but not in CFG files). The first input names the function, following ones are input variable names.FUNCTIONANONYM[...] <%...%>
. Place inputs within square brackets, and in double curly brackets place code. The FUNCTIONANONYM
is a reserved name in this programming language (but not in CFG files).for($x = 0; #$x# < 10; @x += 1)
- a 'for' loopforeach($x = 0;@NODE[y]) <%...%>
or foreach($x = 0;#key) <%...%>
and - runs an action for every node or key if(cond) <%...%> elseif(cond2) <%...%>} else <%...%>}
- conditional statementfornode(node) <%...%>
- run given code for a given node"qwertyuiop" - 3
= "qwertyu"
3 - "qwertyuiop"
= "rtyuiop"
3 - "qwertyuiop" - 3
= "rtyu"
Remove the last instance: "anobnoa" -< "no" = "anoba" Remove last instance "anobnoa" >- "no" = "abnoa" Remove first instance "anobnoa" - "no" = "aba" Remove all instances
This suggestion presents a new programming language for use in KSP.