@@ -16,6 +16,31 @@ keeps the usage of command blocks to a minimum.
1616There is a C compiler that compiles to this assembly language,
1717read more [ here] ( https://github.com/simon816/Command-Block-Assembly/blob/master/README_C.md ) .
1818
19+ As shown in the [ fibonacci sequence example] ( https://github.com/simon816/Command-Block-Assembly/blob/master/examples/fib.c ) ,
20+ it's just like writing normal C code.
21+
22+ ``` c
23+ #include < stdio.h>
24+
25+ int x;
26+ int y;
27+ int old_x;
28+ int counter;
29+
30+ void main () {
31+ x = 0;
32+ y = 1;
33+ counter = 1;
34+ do {
35+ printf ("fib(%d) = %d", counter++, x);
36+ sync;
37+ old_x = x;
38+ x = y;
39+ y += old_x;
40+ } while(x >= 0);
41+ }
42+ ```
43+
1944# The Assembly Language
2045
2146It is a simple language with instructions similar to that of x86.
@@ -105,6 +130,17 @@ main:
105130| PRINT| arg1, [ ...args] | Outputs arguments to chat for all players (` @a ` selector)|
106131| CMD| bare words| Runs the given command|
107132| TEST| bare words| Runs the given command, skipping the next line if the command failed|
133+ | EXECAS| label, sel_type, sel_pairs| Runs the function defined in ` label ` using ` /execute as ` if the selector matches|
134+ | EXECASN| label, sel_type, sel_pairs| Same as EXECAS except runs if it does _ not_ match the selector|
135+ | EXECAT| label, sel_type, sel_pairs| Runs the function defined in ` label ` using ` /execute at ` if the selector matches|
136+ | EXECATP| label, sel_type, sel_pairs| Runs the function defined in ` label ` using ` /execute positioned as ` if the selector matches|
137+ | EXECPOS| label, x, y, z| Runs the function defined in ` label ` using ` /execute positioned ` |
138+ | EXECALI| label, axes| Runs the function defined in ` label ` using ` /execute align ` |
139+ | EXECFACP| label, x, y, z| Runs the function defined in ` label ` using ` /execute facing ` |
140+ | EXECFAC| label, feature, sel_type, sel_pairs| Runs the function defined in ` label ` using ` /execute facing entity ` |
141+ | EXECROT| label, y, x| Runs the function defined in ` label ` using ` /execute rotated ` |
142+ | EXECROTE| label, sel_type, sel_pairs| Runs the function defined in ` label ` using ` /execute rotated as ` |
143+ | EXECANC| label, anchor| Runs the function defined in ` label ` using ` /execute anchored ` |
108144| PUSH|| Pushes stack register onto the stack, increments stack pointer|
109145| POP|| Pops stack into stack register, decrements stack pointer|
110146| SYNC|| Synchronises with the game tick. i.e. wait one tick before continuing|
@@ -161,6 +197,17 @@ into wherever the directive is.
161197"Include headers". Does not load any code from the file, but pulls in the symbol table (subroutines, constants).
162198Useful for using library code already running in the game. (i.e. library was loaded sometime beforehand).
163199
200+ #### ` #event_handler label event_name condition1=value1;condition2=value2;... `
201+
202+ Runs the subroutine with the given ` label ` whenever the named event is triggered and the conditions match.
203+ The following is an example where the function ` on_placed_stone ` will get invoked every time a player places
204+ a stone block.
205+
206+ ```
207+ #event_handler on_placed_stone minecraft:placed_block item.item=minecraft:stone
208+ on_placed_stone:
209+ ...
210+ ```
164211
165212## Memory locations
166213
@@ -183,9 +230,11 @@ The assembler is invoked by calling `main.py`.
183230
184231Command line parameters:
185232```
186- usage: main.py [-h] [--world-dir WORLD_DIR] [--namespace NAMESPACE]
233+ usage: main.py [-h] [--world-dir WORLD_DIR] [--as_zip] [-- namespace NAMESPACE]
187234 [--rem-existing] [--debug] [--stack STACK] [--arg ARG]
188235 [--jump JUMP] [--place-location PLACE_LOCATION] [--enable-sync]
236+ [--setup-on-load] [--spawn-location SPAWN_LOCATION]
237+ [--pack-description PACK_DESCRIPTION]
189238 file
190239
191240positional arguments:
@@ -195,6 +244,7 @@ optional arguments:
195244 -h, --help show this help message and exit
196245 --world-dir WORLD_DIR
197246 World Directory
247+ --as_zip Write datapack as zip file
198248 --namespace NAMESPACE
199249 Function namespace
200250 --rem-existing Remove existing functions in namespace
@@ -205,6 +255,11 @@ optional arguments:
205255 --place-location PLACE_LOCATION
206256 Location to place command blocks
207257 --enable-sync Enable SYNC opcode
258+ --setup-on-load Run setup on minecraft:load
259+ --spawn-location SPAWN_LOCATION
260+ Location to spawn hidden armor stand
261+ --pack-description PACK_DESCRIPTION
262+ Datapack description
208263```
209264
210265Notes:
0 commit comments