Comments (1)
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
Functions
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.- Variables belonging to the local node are obtained by simply typing their name.
- To get variables from ancestors, use
##$...$
instead.
regexp(pattern,string)
- run regexp expression on a string - sin, cos, tan, log10, ln, log2, expE, exp10, mod, exp, sec, csc, sqrt, curt, root, log - math functions
getKey(...)
:- 2 inputs: name, index - get a single key by index
- 1 input: name - get all keys by name
- 1 input: key - get key's value
- no inputs - get all keys under all names
getKeyValue(...)
: LikegetKey(...)
, but gets values, not the keys themselves.setKey(...)
:- 3 inputs: key name, index, value - set given key at the given index to the given value
- 2 inputs: key, value: sets given a key to a given value
- 2 inputs: keys, value: sets all given keys to a single value
- 2 inputs: keys, values: sets keys to the corresponding values
- 2 inputs: key name, values: sets keys under given name to the corresponding values
- 2 inputs: key name, value: sets keys under given name to a single value
- If you want to set multiple keys to a list, use
setKeyDuplicate
function
setKeyDuplicate(...)
:- 2 inputs: key name, value: sets keys under given name to a single value
- 2 inputs: keys, value: sets all given keys to a single value
call(func, inputs)
: calls a function with given list of inputsgetKey(...)
:- 2 inputs: name, index - get a single key by index
- 1 input: name - get all keys by name
- 1 input: key - get key's value
- no inputs - get all keys under all names
getNodeValue(...)
: LikegetNode(...)
, but gets values, not the nodes themselves.setNode(...)
:- 3 inputs: node name, index, value - set given node at the given index to the given value
- 2 inputs: node, value: sets given a node to a given value
- 2 inputs: nodes, value: sets all given nodes to a single value
- 2 inputs: nodes, values: sets nodes to the corresponding values
- 2 inputs: node name, values: sets nodes under given name to the corresponding values
- 2 inputs: node name, value: sets nodes under given name to a single value
- If you want to set multiple nodes to a list, use
setKeyDuplicate
function
setNodeDuplicate(...)
:- 2 inputs: node name, value: sets nodes under given name to a single value
- 2 inputs: nodes, value: sets all given nodes to a single value
Setter prefixes
'$' as a modifier - creates a temporary variable
'$$' as a modifier - creates a long-term variable, but it is removed after all scripts finish.
Basic data types
String, node, key, number, boolean, list, anonymous function
Advanced data types
Achieved through specialized functions.
Operators
- + adddition
- - substraction
- * multiplication
- / division
- ^ exponent
- | OR
- ! NOT
- & AND
- \ XOR
- !| NOR
- !& NAND
- !\ XNOR
- = equal
- > more
- < less
- <= !> not more
- >= !< not less
- <> != not equal
Grouping
- () parentheses
- <% ... %> code sections (they do not start a new node).
- [[...]] - list
Why double brackets?
Double symbols are much rarer in the text - to say text explicitly, use quotation marks.
Where?
It will need a new file format - which distinguishes it from simpler patches.
Suggestions for file extension:
- mm - from 'module manager'
- akp - from 'advanced kerbal patch'
- kscript - from 'kerbal script'
- kpscript - from 'kerbal patch script'
Why?
- KSP API is too complex for beginners
- Existing capabilities are insufficient for extremely advanced users
How?
Existing patches should not be called 'scripts' - they will be more advanced form of data.
Constructs
- Define function:
FUNCTIONDEF[...] <%...%>
. Place inputs within square brackets, and in double curly brackets place code. TheFUNCTIONDEF
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. - Define anonymous function:
FUNCTIONANONYM[...] <%...%>
. Place inputs within square brackets, and in double curly brackets place code. TheFUNCTIONANONYM
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]) <%...%>
orforeach($x = 0;#key) <%...%>
and - runs an action for every node or keyif(cond) <%...%> elseif(cond2) <%...%>} else <%...%>}
- conditional statementfornode(node) <%...%>
- run given code for a given node- `try <%...%> catch($exc) <%...%> - if first block throws an error or exception, call second block
'-' with text
"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
from modulemanager.
Related Issues (20)
- Feature request: @descripion ^= : $:#localization_xys : HOT 2
- [Bug] Patches can't be applied to parts with spaces in name HOT 1
- Heya.
- Patching Thread: Crash when :LAST[x] pass found and [x] is not a valid pass HOT 1
- ENHANCEMENT: Informative Log Labeling HOT 2
- :NEEDS[sub/directory] doesn't seem to be functioning HOT 4
- ModuleManager.log filepath HOT 7
- [Question] How do I rename a node? HOT 6
- when kerbalx.com was crashed, I can't click any button HOT 1
- [Bug] Index operator has no effect when used in conjunction with `:HAS` clause on a node
- 4.2.0 With RP-1 install has errors
- Module Manager stuck "waiting for patching to finish" HOT 1
- KSP load longer even with Saved ModuleManager's Caches when load compare to ModuleManager while generating Caches HOT 1
- sorry - missclick :) HOT 2
- ModuleManager seems to be unable to parse a value (see more below)
- MM should report an error for missing operators in HAS nodes
- Identify arrays with elements seperated by \tab
- Patching stuffs in-game without reloading the entire database or restarting? HOT 1
- Deleting the last key by negative index does not work; deleting keys by value deletes all of them HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from modulemanager.