Not finished, just only a draft. Please give any comment to pca006132. Email: john.lck40@gmail.com
Will be ignored by the compiler.
Note that these comments cannot be placed at the same line of the command.
//Single line comment
/*
multiline comment
*/
Organizing commands. Just indicate the start of a module, and commands after it need 1 more level of indentation. Also, users can only compile commands of a specific module.
Syntax: #module (module name)
#module example
/say this is the first command
/say this is the second
/say this is not the command of module 'example'
Label a command block, and get the coordinate of the labeled command block by using JavaScript/native function later.
Syntax: #label (name)
Note that there cannot be more than 1 command block having the same label.
If really needed, please use marker entity.
#label test
/say test
/say the coordinate of test is: ${GetCoordinateFromLabel('test')}
Default: auto chain command block.
Lines after a line of command, indented for 1 more level, will be concatenated together, and no space char will be added, the spaces at the end of the command will not be trimmed.
//Note that there is 1 space char after the '.' char.
icb:say this is a long example.
Really long.
//is equivalent to
icb:say this is a long example. Really long.
Can be used together, one after another (Note that the one after will overwrite the properties before):
//An auto, impulse command block
icb:1:say test
//An not auto, impulse command block
1:icb:say test2
0:r:say ${1}
//is equivalent to
0:say $${1}
For commands after a line of pure prefixes, and indented for 1 more level, those commands are considered using those prefixes.
?:
/say this is a conditional command block
/say this is also a conditional command block
Start a new chain.
Syntax: @chain (x,y,z) (orientation) [wrap-(wrap count)-(wrap orientation)]
For orientation, +/- x/y/z are used, such as +x, -y etc.
@chain 1,2,3 +x wrap-10-+z
Summon marker at the next command block. Will use invisble, long lasting area_effect_cloud as marker.
Syntax: @mark (name) [tag1],[tag2]...
@mark test tag1,tag2,tag3,tag4
Bind the stats of the next command block to a score of an entity/fake player.
Syntax: @stat <stat to bind> <entity/fake player name> <objective>
@stat SuccessCount @e[name=test,c=1] dummy
Use a sign to mark the next command block. For the nbt part, only write the line you need to change, others are set by default: TextN:"{\"text\":\"\"}"
Syntax: @sign {NBT}
@sign {Text1:"{\"text\":\"test\"}"}
Commands that run when the OOC is importing. (Before the placement of command blocks)
Syntax: @init (commad)
@init say Import started
Commands that run when the OOC finish importing. (At last)
Syntax: @last (command)
@last say finish!
Users can include scripts, functions and variables can be used during generation.
So that users can seperate data and commands, increase readability and can change commands easier.
For declaring variables and functions, or register PCC commands.
Will be the first to run, before scripts in the document.
Syntax: #include <(URL)>
#include <www.example.com/script.js>
Start: #script
End: #end script
Note: Should only occur once only.
#script
/*
js script here(function/variable declaration, register PCC commands.)
*/
const TEST = 1;
#end script
JavaScript functions and variables can be called during generation. There are three ways to call JavaScript during generation, depends on whether you want to:
+ generate a sequence of commands
+ replace a part of the command
+ run PCC command. (PCC commands can be registered through scripts)
Like preprocessing, the function will be executed right after scripts are included, and the result would be inserted directly to the document (Will not change the original file.). The generated commands can contain PCC commands, prefixes etc. There should be no command block data to access when generating the sequence of commands.
Syntax: #run (expression)
Example:
#script
function f(x) {
results = [];
for (var i = 0; i < x; i++)
results.push('/say ' + i.toString());
return results.join('\n');
}
#end script
#run f(3)
Generated Commands would be:
/say 0
/say 1
/say 2
For runing javascript/calling constant in commands, use ${code}
. Putting another $ char before the $ to escape it. The returned value will be replaced in that part of the command(Calling the toString()
for non-string results). To prevent too many escaping, you can use raw command. (See the prefix section above)
This is executed just before the command joining. (At last.)
Such that the coordinates of the command blocks are known.
This can also be used in PCC commands. However, if there are any errors, the compiler will be stopped and prompt the user, make sure the data exist before calling the PCC command. (For example, if you need a command block coordinate in a@chain
command, make sure that the@chain
command is placed after the command block, or you will get an error.)
Example:
#script
function f() {
//return something like "x y z"
return CurrentCommandBlock.coordinate.join(' ');
}
#end script
/say This is at ${f()}
Suppose the command block is at 1, 2, 3. The generated commands would be:
/say this is at 1 2 3
PCC commands are executed when parsing the commands. PCC commands can start new chain, add command blocks, run commands during initiation etc. As it is executed when parsing commands, it can only access to data parsed before it.
Syntax: @(function name) (string after it would be the parameter 1)
Note that the parameter 1 will be processed, to replace those
$$
and${}
Example:
#script
function doNothing(x) {
console.log(x);
}
#end script
@doNothing say test
Result(console):
'say test'