Skip to content

Commit 3bedffc

Browse files
committed
Add fib.ir example and update argument documentation
1 parent 09c77f6 commit 3bedffc

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

examples/fib.ir

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
preamble {
2+
$all_players = selector a
3+
}
4+
5+
function main {
6+
preamble {
7+
$x = define i32
8+
$y = define i32
9+
$old_x = define i32
10+
$counter = define i32
11+
extern
12+
}
13+
14+
entry:
15+
$x = 0
16+
$y = 1
17+
$counter = 1
18+
branch :loop
19+
20+
loop:
21+
$msg = text
22+
text_append $msg, "fib("
23+
text_append $msg, $counter
24+
text_append $msg, ") = "
25+
text_append $msg, $x
26+
text_send $msg, $all_players
27+
set_command_block :post_tick
28+
29+
post_tick:
30+
clear_command_block
31+
$counter += 1
32+
$old_x = $x
33+
$x = $y
34+
$y += $old_x
35+
rangebr $x, 0, NULL, :loop, :end
36+
37+
end:
38+
ret
39+
}

ir_main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ def main(args):
4545

4646
if __name__ == '__main__':
4747
parser = argparse.ArgumentParser()
48-
parser.add_argument('file', help="ASM File", type=argparse.FileType('r'))
48+
parser.add_argument('file', help="Command IR File", type=argparse.FileType('r'))
4949
parser.add_argument('--world-dir', help="World Directory")
5050
parser.add_argument('--as-zip', action='store_true', help="Write datapack as zip file")
5151
parser.add_argument('--namespace', help="Function namespace", default='ir_generated')
5252
parser.add_argument('--rem-existing', help="Remove existing functions in namespace",
5353
action='store_true')
5454
parser.add_argument('--debug', action='store_true', help="Enable debug output")
55-
parser.add_argument('--dump-ir', action='store_true', help="Dump CMD IR output")
55+
parser.add_argument('--dump-ir', action='store_true', help="Dump Command IR output")
5656
parser.add_argument('--gen-cleanup', action='store_true', help="Generate cleanup function")
5757
parser.add_argument('--place-location', help="Location to place command blocks", required=True)
5858
parser.add_argument('--spawn-location', default='~ ~2 ~',

0 commit comments

Comments
 (0)