redscript-mc 1.2.26 → 1.2.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (243) hide show
  1. package/README.md +78 -9
  2. package/README.zh.md +72 -4
  3. package/dist/__tests__/cli.test.js +13 -13
  4. package/dist/__tests__/optimizer-advanced.test.js +4 -4
  5. package/dist/__tests__/stdlib-advanced.test.js +114 -0
  6. package/dist/__tests__/stdlib-bigint.test.d.ts +7 -0
  7. package/dist/__tests__/stdlib-bigint.test.js +428 -0
  8. package/dist/cli.js +13 -5
  9. package/dist/codegen/mcfunction/index.d.ts +4 -0
  10. package/dist/codegen/mcfunction/index.js +9 -4
  11. package/dist/compile.d.ts +4 -0
  12. package/dist/compile.js +9 -1
  13. package/dist/data/arena/function/__load.mcfunction +6 -0
  14. package/dist/data/arena/function/__tick.mcfunction +2 -0
  15. package/dist/data/arena/function/announce_leaders/else_1.mcfunction +3 -0
  16. package/dist/data/arena/function/announce_leaders/foreach_0/merge_2.mcfunction +1 -0
  17. package/dist/data/arena/function/announce_leaders/foreach_0/then_0.mcfunction +3 -0
  18. package/dist/data/arena/function/announce_leaders/foreach_0.mcfunction +7 -0
  19. package/dist/data/arena/function/announce_leaders/foreach_1/merge_2.mcfunction +1 -0
  20. package/dist/data/arena/function/announce_leaders/foreach_1/then_0.mcfunction +4 -0
  21. package/dist/data/arena/function/announce_leaders/foreach_1.mcfunction +6 -0
  22. package/dist/data/arena/function/announce_leaders/merge_2.mcfunction +1 -0
  23. package/dist/data/arena/function/announce_leaders/then_0.mcfunction +4 -0
  24. package/dist/data/arena/function/announce_leaders.mcfunction +6 -0
  25. package/dist/data/arena/function/arena_tick/merge_2.mcfunction +1 -0
  26. package/dist/data/arena/function/arena_tick/then_0.mcfunction +4 -0
  27. package/dist/data/arena/function/arena_tick.mcfunction +11 -0
  28. package/dist/data/counter/function/__load.mcfunction +5 -0
  29. package/dist/data/counter/function/__tick.mcfunction +2 -0
  30. package/dist/data/counter/function/counter_tick/merge_2.mcfunction +1 -0
  31. package/dist/data/counter/function/counter_tick/then_0.mcfunction +3 -0
  32. package/dist/data/counter/function/counter_tick.mcfunction +11 -0
  33. package/dist/data/gcd2/function/__load.mcfunction +3 -0
  34. package/dist/data/gcd2/function/abs/merge_2.mcfunction +3 -0
  35. package/dist/data/gcd2/function/abs/then_0.mcfunction +5 -0
  36. package/dist/data/gcd2/function/abs.mcfunction +7 -0
  37. package/dist/data/gcd2/function/gcd/loop_body_1.mcfunction +7 -0
  38. package/dist/data/gcd2/function/gcd/loop_check_0.mcfunction +5 -0
  39. package/dist/data/gcd2/function/gcd/loop_exit_2.mcfunction +3 -0
  40. package/dist/data/gcd2/function/gcd.mcfunction +14 -0
  41. package/dist/data/gcd3/function/__load.mcfunction +3 -0
  42. package/dist/data/gcd3/function/abs/merge_2.mcfunction +3 -0
  43. package/dist/data/gcd3/function/abs/then_0.mcfunction +5 -0
  44. package/dist/data/gcd3/function/abs.mcfunction +7 -0
  45. package/dist/data/gcd3/function/gcd/loop_body_1.mcfunction +7 -0
  46. package/dist/data/gcd3/function/gcd/loop_check_0.mcfunction +5 -0
  47. package/dist/data/gcd3/function/gcd/loop_exit_2.mcfunction +3 -0
  48. package/dist/data/gcd3/function/gcd.mcfunction +14 -0
  49. package/dist/data/gcd3/function/test.mcfunction +7 -0
  50. package/dist/data/gcd3nm/function/__load.mcfunction +3 -0
  51. package/dist/data/gcd3nm/function/abs/merge_2.mcfunction +3 -0
  52. package/dist/data/gcd3nm/function/abs/then_0.mcfunction +5 -0
  53. package/dist/data/gcd3nm/function/abs.mcfunction +7 -0
  54. package/dist/data/gcd3nm/function/gcd/loop_body_1.mcfunction +7 -0
  55. package/dist/data/gcd3nm/function/gcd/loop_check_0.mcfunction +5 -0
  56. package/dist/data/gcd3nm/function/gcd/loop_exit_2.mcfunction +3 -0
  57. package/dist/data/gcd3nm/function/gcd.mcfunction +14 -0
  58. package/dist/data/gcd3nm/function/test.mcfunction +7 -0
  59. package/dist/data/gcd_test/function/__load.mcfunction +3 -0
  60. package/dist/data/gcd_test/function/abs/merge_2.mcfunction +3 -0
  61. package/dist/data/gcd_test/function/abs/then_0.mcfunction +5 -0
  62. package/dist/data/gcd_test/function/abs.mcfunction +7 -0
  63. package/dist/data/gcd_test/function/gcd/loop_body_1.mcfunction +7 -0
  64. package/dist/data/gcd_test/function/gcd/loop_check_0.mcfunction +5 -0
  65. package/dist/data/gcd_test/function/gcd/loop_exit_2.mcfunction +3 -0
  66. package/dist/data/gcd_test/function/gcd.mcfunction +14 -0
  67. package/dist/data/isqrttest/function/__load.mcfunction +6 -0
  68. package/dist/data/isqrttest/function/isqrt/loop_body_4.mcfunction +12 -0
  69. package/dist/data/isqrttest/function/isqrt/loop_check_3.mcfunction +5 -0
  70. package/dist/data/isqrttest/function/isqrt/loop_exit_5.mcfunction +3 -0
  71. package/dist/data/isqrttest/function/isqrt/merge_2.mcfunction +4 -0
  72. package/dist/data/isqrttest/function/isqrt/merge_8.mcfunction +6 -0
  73. package/dist/data/isqrttest/function/isqrt/then_0.mcfunction +3 -0
  74. package/dist/data/isqrttest/function/isqrt/then_6.mcfunction +3 -0
  75. package/dist/data/isqrttest/function/isqrt.mcfunction +7 -0
  76. package/dist/data/isqrttest/function/test.mcfunction +6 -0
  77. package/dist/data/mathtest/function/__load.mcfunction +3 -0
  78. package/dist/data/mathtest/function/abs/merge_2.mcfunction +3 -0
  79. package/dist/data/mathtest/function/abs/then_0.mcfunction +5 -0
  80. package/dist/data/mathtest/function/abs.mcfunction +6 -0
  81. package/dist/data/mathtest/function/test.mcfunction +5 -0
  82. package/dist/data/minecraft/tags/function/load.json +5 -0
  83. package/dist/data/minecraft/tags/function/tick.json +5 -0
  84. package/dist/data/mypack/function/__load.mcfunction +13 -0
  85. package/dist/data/mypack/function/_atan_init.mcfunction +2 -0
  86. package/dist/data/mypack/function/abs/merge_2.mcfunction +3 -0
  87. package/dist/data/mypack/function/abs/then_0.mcfunction +5 -0
  88. package/dist/data/mypack/function/abs.mcfunction +6 -0
  89. package/dist/data/mypack/function/atan2_fixed/__sgi_1.mcfunction +2 -0
  90. package/dist/data/mypack/function/atan2_fixed/else_34.mcfunction +3 -0
  91. package/dist/data/mypack/function/atan2_fixed/loop_body_31.mcfunction +19 -0
  92. package/dist/data/mypack/function/atan2_fixed/loop_check_30.mcfunction +5 -0
  93. package/dist/data/mypack/function/atan2_fixed/loop_exit_32.mcfunction +6 -0
  94. package/dist/data/mypack/function/atan2_fixed/merge_11.mcfunction +6 -0
  95. package/dist/data/mypack/function/atan2_fixed/merge_14.mcfunction +3 -0
  96. package/dist/data/mypack/function/atan2_fixed/merge_17.mcfunction +6 -0
  97. package/dist/data/mypack/function/atan2_fixed/merge_2.mcfunction +5 -0
  98. package/dist/data/mypack/function/atan2_fixed/merge_20.mcfunction +5 -0
  99. package/dist/data/mypack/function/atan2_fixed/merge_23.mcfunction +5 -0
  100. package/dist/data/mypack/function/atan2_fixed/merge_26.mcfunction +6 -0
  101. package/dist/data/mypack/function/atan2_fixed/merge_29.mcfunction +4 -0
  102. package/dist/data/mypack/function/atan2_fixed/merge_38.mcfunction +5 -0
  103. package/dist/data/mypack/function/atan2_fixed/merge_41.mcfunction +5 -0
  104. package/dist/data/mypack/function/atan2_fixed/merge_44.mcfunction +5 -0
  105. package/dist/data/mypack/function/atan2_fixed/merge_47.mcfunction +5 -0
  106. package/dist/data/mypack/function/atan2_fixed/merge_5.mcfunction +5 -0
  107. package/dist/data/mypack/function/atan2_fixed/merge_8.mcfunction +3 -0
  108. package/dist/data/mypack/function/atan2_fixed/then_0.mcfunction +5 -0
  109. package/dist/data/mypack/function/atan2_fixed/then_12.mcfunction +3 -0
  110. package/dist/data/mypack/function/atan2_fixed/then_15.mcfunction +5 -0
  111. package/dist/data/mypack/function/atan2_fixed/then_18.mcfunction +5 -0
  112. package/dist/data/mypack/function/atan2_fixed/then_21.mcfunction +3 -0
  113. package/dist/data/mypack/function/atan2_fixed/then_24.mcfunction +3 -0
  114. package/dist/data/mypack/function/atan2_fixed/then_27.mcfunction +6 -0
  115. package/dist/data/mypack/function/atan2_fixed/then_3.mcfunction +3 -0
  116. package/dist/data/mypack/function/atan2_fixed/then_33.mcfunction +5 -0
  117. package/dist/data/mypack/function/atan2_fixed/then_36.mcfunction +5 -0
  118. package/dist/data/mypack/function/atan2_fixed/then_39.mcfunction +5 -0
  119. package/dist/data/mypack/function/atan2_fixed/then_42.mcfunction +3 -0
  120. package/dist/data/mypack/function/atan2_fixed/then_45.mcfunction +5 -0
  121. package/dist/data/mypack/function/atan2_fixed/then_6.mcfunction +3 -0
  122. package/dist/data/mypack/function/atan2_fixed/then_9.mcfunction +5 -0
  123. package/dist/data/mypack/function/atan2_fixed.mcfunction +7 -0
  124. package/dist/data/mypack/function/my_game.mcfunction +10 -0
  125. package/dist/data/quiz/function/__load.mcfunction +16 -0
  126. package/dist/data/quiz/function/__tick.mcfunction +6 -0
  127. package/dist/data/quiz/function/__trigger_quiz_a_dispatch.mcfunction +4 -0
  128. package/dist/data/quiz/function/__trigger_quiz_b_dispatch.mcfunction +4 -0
  129. package/dist/data/quiz/function/__trigger_quiz_c_dispatch.mcfunction +4 -0
  130. package/dist/data/quiz/function/__trigger_quiz_start_dispatch.mcfunction +4 -0
  131. package/dist/data/quiz/function/answer_a.mcfunction +4 -0
  132. package/dist/data/quiz/function/answer_b.mcfunction +4 -0
  133. package/dist/data/quiz/function/answer_c.mcfunction +4 -0
  134. package/dist/data/quiz/function/ask_question/else_1.mcfunction +5 -0
  135. package/dist/data/quiz/function/ask_question/else_4.mcfunction +5 -0
  136. package/dist/data/quiz/function/ask_question/else_7.mcfunction +4 -0
  137. package/dist/data/quiz/function/ask_question/merge_2.mcfunction +1 -0
  138. package/dist/data/quiz/function/ask_question/merge_5.mcfunction +2 -0
  139. package/dist/data/quiz/function/ask_question/merge_8.mcfunction +2 -0
  140. package/dist/data/quiz/function/ask_question/then_0.mcfunction +4 -0
  141. package/dist/data/quiz/function/ask_question/then_3.mcfunction +4 -0
  142. package/dist/data/quiz/function/ask_question/then_6.mcfunction +4 -0
  143. package/dist/data/quiz/function/ask_question.mcfunction +7 -0
  144. package/dist/data/quiz/function/finish_quiz.mcfunction +6 -0
  145. package/dist/data/quiz/function/handle_answer/else_1.mcfunction +5 -0
  146. package/dist/data/quiz/function/handle_answer/else_10.mcfunction +3 -0
  147. package/dist/data/quiz/function/handle_answer/else_16.mcfunction +3 -0
  148. package/dist/data/quiz/function/handle_answer/else_4.mcfunction +3 -0
  149. package/dist/data/quiz/function/handle_answer/else_7.mcfunction +5 -0
  150. package/dist/data/quiz/function/handle_answer/merge_11.mcfunction +2 -0
  151. package/dist/data/quiz/function/handle_answer/merge_14.mcfunction +2 -0
  152. package/dist/data/quiz/function/handle_answer/merge_17.mcfunction +2 -0
  153. package/dist/data/quiz/function/handle_answer/merge_2.mcfunction +8 -0
  154. package/dist/data/quiz/function/handle_answer/merge_5.mcfunction +2 -0
  155. package/dist/data/quiz/function/handle_answer/merge_8.mcfunction +2 -0
  156. package/dist/data/quiz/function/handle_answer/then_0.mcfunction +5 -0
  157. package/dist/data/quiz/function/handle_answer/then_12.mcfunction +5 -0
  158. package/dist/data/quiz/function/handle_answer/then_15.mcfunction +6 -0
  159. package/dist/data/quiz/function/handle_answer/then_3.mcfunction +6 -0
  160. package/dist/data/quiz/function/handle_answer/then_6.mcfunction +5 -0
  161. package/dist/data/quiz/function/handle_answer/then_9.mcfunction +6 -0
  162. package/dist/data/quiz/function/handle_answer.mcfunction +11 -0
  163. package/dist/data/quiz/function/start_quiz.mcfunction +5 -0
  164. package/dist/data/reqtest/function/__load.mcfunction +4 -0
  165. package/dist/data/reqtest/function/_table_init.mcfunction +2 -0
  166. package/dist/data/reqtest/function/no_trig.mcfunction +3 -0
  167. package/dist/data/reqtest/function/use_table.mcfunction +4 -0
  168. package/dist/data/reqtest2/function/__load.mcfunction +3 -0
  169. package/dist/data/reqtest2/function/no_trig.mcfunction +3 -0
  170. package/dist/data/runtime/function/__load.mcfunction +5 -0
  171. package/dist/data/runtime/function/__tick.mcfunction +2 -0
  172. package/dist/data/runtime/function/counter_tick/then_0.mcfunction +3 -0
  173. package/dist/data/runtime/function/counter_tick.mcfunction +13 -0
  174. package/dist/data/shop/function/__load.mcfunction +7 -0
  175. package/dist/data/shop/function/__tick.mcfunction +3 -0
  176. package/dist/data/shop/function/__trigger_shop_buy_dispatch.mcfunction +4 -0
  177. package/dist/data/shop/function/complete_purchase/else_1.mcfunction +5 -0
  178. package/dist/data/shop/function/complete_purchase/else_4.mcfunction +5 -0
  179. package/dist/data/shop/function/complete_purchase/else_7.mcfunction +3 -0
  180. package/dist/data/shop/function/complete_purchase/merge_2.mcfunction +2 -0
  181. package/dist/data/shop/function/complete_purchase/merge_5.mcfunction +2 -0
  182. package/dist/data/shop/function/complete_purchase/merge_8.mcfunction +2 -0
  183. package/dist/data/shop/function/complete_purchase/then_0.mcfunction +4 -0
  184. package/dist/data/shop/function/complete_purchase/then_3.mcfunction +4 -0
  185. package/dist/data/shop/function/complete_purchase/then_6.mcfunction +4 -0
  186. package/dist/data/shop/function/complete_purchase.mcfunction +7 -0
  187. package/dist/data/shop/function/handle_shop_trigger.mcfunction +3 -0
  188. package/dist/data/swap_test/function/__load.mcfunction +3 -0
  189. package/dist/data/swap_test/function/gcd_old/loop_body_1.mcfunction +7 -0
  190. package/dist/data/swap_test/function/gcd_old/loop_check_0.mcfunction +5 -0
  191. package/dist/data/swap_test/function/gcd_old/loop_exit_2.mcfunction +3 -0
  192. package/dist/data/swap_test/function/gcd_old.mcfunction +8 -0
  193. package/dist/data/turret/function/__load.mcfunction +5 -0
  194. package/dist/data/turret/function/__tick.mcfunction +4 -0
  195. package/dist/data/turret/function/__trigger_deploy_turret_dispatch.mcfunction +4 -0
  196. package/dist/data/turret/function/deploy_turret.mcfunction +8 -0
  197. package/dist/data/turret/function/turret_tick/at_1.mcfunction +2 -0
  198. package/dist/data/turret/function/turret_tick/foreach_0.mcfunction +2 -0
  199. package/dist/data/turret/function/turret_tick/foreach_2.mcfunction +2 -0
  200. package/dist/data/turret/function/turret_tick/tick_body.mcfunction +3 -0
  201. package/dist/data/turret/function/turret_tick/tick_skip.mcfunction +1 -0
  202. package/dist/data/turret/function/turret_tick.mcfunction +5 -0
  203. package/dist/gcd2.map.json +15 -0
  204. package/dist/gcd3.map.json +17 -0
  205. package/dist/gcd_test.map.json +15 -0
  206. package/dist/index.d.ts +4 -0
  207. package/dist/index.js +11 -6
  208. package/dist/isqrttest.map.json +15 -0
  209. package/dist/lowering/index.d.ts +3 -0
  210. package/dist/lowering/index.js +161 -64
  211. package/dist/mathtest.map.json +6 -0
  212. package/dist/mypack.map.json +27 -0
  213. package/dist/optimizer/commands.d.ts +1 -0
  214. package/dist/optimizer/commands.js +18 -11
  215. package/dist/optimizer/structure.d.ts +1 -0
  216. package/dist/optimizer/structure.js +6 -1
  217. package/dist/pack.mcmeta +6 -0
  218. package/dist/reqtest.map.json +4 -0
  219. package/dist/reqtest2.map.json +4 -0
  220. package/dist/runtime/index.js +26 -5
  221. package/dist/runtime.map.json +7 -0
  222. package/dist/swap_test.map.json +14 -0
  223. package/editors/vscode/package-lock.json +3 -3
  224. package/editors/vscode/package.json +1 -1
  225. package/examples/math-showcase.mcrs +146 -0
  226. package/examples/readme-demo.mcrs +92 -0
  227. package/examples/showcase.mcrs +505 -0
  228. package/package.json +1 -1
  229. package/src/__tests__/cli.test.ts +13 -13
  230. package/src/__tests__/optimizer-advanced.test.ts +4 -4
  231. package/src/__tests__/stdlib-advanced.test.ts +120 -0
  232. package/src/__tests__/stdlib-bigint.test.ts +427 -0
  233. package/src/cli.ts +14 -5
  234. package/src/codegen/mcfunction/index.ts +14 -5
  235. package/src/compile.ts +15 -2
  236. package/src/index.ts +17 -7
  237. package/src/lowering/index.ts +165 -63
  238. package/src/optimizer/commands.ts +18 -12
  239. package/src/optimizer/structure.ts +6 -2
  240. package/src/runtime/index.ts +27 -5
  241. package/src/stdlib/advanced.mcrs +81 -0
  242. package/src/stdlib/bigint.mcrs +205 -0
  243. package/src/stdlib/math.mcrs +19 -6
@@ -0,0 +1,11 @@
1
+ # block: entry
2
+ execute store result score $t0 rs run scoreboard players get arena ticks
3
+ scoreboard players operation $t1 rs = $t0 rs
4
+ scoreboard players operation $t1 rs += $const_1 rs
5
+ execute store result score arena ticks run scoreboard players get $t2 rs
6
+ scoreboard players operation $t3 rs = $t1 rs
7
+ scoreboard players operation $t3 rs %= $const_200 rs
8
+ scoreboard players set $t4 rs 0
9
+ execute if score $t3 rs = $const_0 rs run scoreboard players set $t4 rs 1
10
+ execute if score $t4 rs matches 1.. run function arena:arena_tick/then_0
11
+ execute if score $t4 rs matches ..0 run function arena:arena_tick/merge_2
@@ -0,0 +1,5 @@
1
+ # RedScript runtime init
2
+ scoreboard objectives add rs dummy
3
+ scoreboard players set $const_1 rs 1
4
+ scoreboard players set $const_100 rs 100
5
+ scoreboard players set $const_0 rs 0
@@ -0,0 +1,2 @@
1
+ # RedScript tick dispatcher
2
+ function counter:counter_tick
@@ -0,0 +1 @@
1
+ # block: merge_2
@@ -0,0 +1,3 @@
1
+ # block: then_0
2
+ say Counter reached another 100 ticks
3
+ function counter:counter_tick/merge_2
@@ -0,0 +1,11 @@
1
+ # block: entry
2
+ execute store result score $t0 rs run scoreboard players get counter ticks
3
+ scoreboard players operation $t1 rs = $t0 rs
4
+ scoreboard players operation $t1 rs += $const_1 rs
5
+ execute store result score counter ticks run scoreboard players get $t2 rs
6
+ scoreboard players operation $t3 rs = $t1 rs
7
+ scoreboard players operation $t3 rs %= $const_100 rs
8
+ scoreboard players set $t4 rs 0
9
+ execute if score $t3 rs = $const_0 rs run scoreboard players set $t4 rs 1
10
+ execute if score $t4 rs matches 1.. run function counter:counter_tick/then_0
11
+ execute if score $t4 rs matches ..0 run function counter:counter_tick/merge_2
@@ -0,0 +1,3 @@
1
+ # RedScript runtime init
2
+ scoreboard objectives add rs dummy
3
+ scoreboard players set $a rs 0
@@ -0,0 +1,3 @@
1
+ # block: merge_2
2
+ scoreboard players operation $h rs = $b rs
3
+ return run scoreboard players get $b rs
@@ -0,0 +1,5 @@
1
+ # block: then_0
2
+ scoreboard players set $f rs 0
3
+ scoreboard players operation $f rs -= $b rs
4
+ scoreboard players operation $h rs = $f rs
5
+ return run scoreboard players get $f rs
@@ -0,0 +1,7 @@
1
+ # block: entry
2
+ scoreboard players operation $b rs = $c rs
3
+ scoreboard players operation $b rs = $d rs
4
+ scoreboard players set $e rs 0
5
+ execute if score $d rs < $a rs run scoreboard players set $e rs 1
6
+ execute if score $e rs matches 1.. run function gcd2:abs/then_0
7
+ execute if score $e rs matches ..0 run function gcd2:abs/merge_2
@@ -0,0 +1,7 @@
1
+ # block: loop_body_1
2
+ scoreboard players operation $r rs = $b rs
3
+ scoreboard players operation $r rs %= $p rs
4
+ scoreboard players operation $s rs = $r rs
5
+ scoreboard players operation $b rs = $p rs
6
+ scoreboard players operation $p rs = $r rs
7
+ function gcd2:gcd/loop_check_0
@@ -0,0 +1,5 @@
1
+ # block: loop_check_0
2
+ scoreboard players set $q rs 0
3
+ execute if score $p rs > $a rs run scoreboard players set $q rs 1
4
+ execute if score $q rs matches 1.. run function gcd2:gcd/loop_body_1
5
+ execute if score $q rs matches ..0 run function gcd2:gcd/loop_exit_2
@@ -0,0 +1,3 @@
1
+ # block: loop_exit_2
2
+ scoreboard players operation $h rs = $b rs
3
+ return run scoreboard players get $b rs
@@ -0,0 +1,14 @@
1
+ # block: entry
2
+ scoreboard players operation $i rs = $c rs
3
+ scoreboard players operation $j rs = $k rs
4
+ scoreboard players operation $i rs = $d rs
5
+ scoreboard players operation $j rs = $l rs
6
+ scoreboard players operation $m rs = $d rs
7
+ function gcd2:abs
8
+ scoreboard players operation $n rs = $g rs
9
+ scoreboard players operation $b rs = $n rs
10
+ scoreboard players operation $m rs = $l rs
11
+ function gcd2:abs
12
+ scoreboard players operation $o rs = $g rs
13
+ scoreboard players operation $p rs = $o rs
14
+ function gcd2:gcd/loop_check_0
@@ -0,0 +1,3 @@
1
+ # RedScript runtime init
2
+ scoreboard objectives add rs dummy
3
+ scoreboard players set $a rs 0
@@ -0,0 +1,3 @@
1
+ # block: merge_2
2
+ scoreboard players operation $h rs = $b rs
3
+ return run scoreboard players get $b rs
@@ -0,0 +1,5 @@
1
+ # block: then_0
2
+ scoreboard players set $f rs 0
3
+ scoreboard players operation $f rs -= $b rs
4
+ scoreboard players operation $h rs = $f rs
5
+ return run scoreboard players get $f rs
@@ -0,0 +1,7 @@
1
+ # block: entry
2
+ scoreboard players operation $b rs = $c rs
3
+ scoreboard players operation $b rs = $d rs
4
+ scoreboard players set $e rs 0
5
+ execute if score $d rs < $a rs run scoreboard players set $e rs 1
6
+ execute if score $e rs matches 1.. run function gcd3:abs/then_0
7
+ execute if score $e rs matches ..0 run function gcd3:abs/merge_2
@@ -0,0 +1,7 @@
1
+ # block: loop_body_1
2
+ scoreboard players operation $r rs = $b rs
3
+ scoreboard players operation $r rs %= $p rs
4
+ scoreboard players operation $s rs = $r rs
5
+ scoreboard players operation $b rs = $p rs
6
+ scoreboard players operation $p rs = $r rs
7
+ function gcd3:gcd/loop_check_0
@@ -0,0 +1,5 @@
1
+ # block: loop_check_0
2
+ scoreboard players set $q rs 0
3
+ execute if score $p rs > $a rs run scoreboard players set $q rs 1
4
+ execute if score $q rs matches 1.. run function gcd3:gcd/loop_body_1
5
+ execute if score $q rs matches ..0 run function gcd3:gcd/loop_exit_2
@@ -0,0 +1,3 @@
1
+ # block: loop_exit_2
2
+ scoreboard players operation $h rs = $b rs
3
+ return run scoreboard players get $b rs
@@ -0,0 +1,14 @@
1
+ # block: entry
2
+ scoreboard players operation $i rs = $c rs
3
+ scoreboard players operation $j rs = $k rs
4
+ scoreboard players operation $i rs = $d rs
5
+ scoreboard players operation $j rs = $l rs
6
+ scoreboard players operation $m rs = $d rs
7
+ function gcd3:abs
8
+ scoreboard players operation $n rs = $g rs
9
+ scoreboard players operation $b rs = $n rs
10
+ scoreboard players operation $m rs = $l rs
11
+ function gcd3:abs
12
+ scoreboard players operation $o rs = $g rs
13
+ scoreboard players operation $p rs = $o rs
14
+ function gcd3:gcd/loop_check_0
@@ -0,0 +1,7 @@
1
+ # block: entry
2
+ scoreboard players set $m rs 12
3
+ scoreboard players set $t rs 8
4
+ function gcd3:gcd
5
+ scoreboard players operation $u rs = $g rs
6
+ scoreboard players operation $v rs = $u rs
7
+ execute store result score out gcd3.r run scoreboard players get $result rs
@@ -0,0 +1,3 @@
1
+ # RedScript runtime init
2
+ scoreboard objectives add rs dummy
3
+ scoreboard players set $const_0 rs 0
@@ -0,0 +1,3 @@
1
+ # block: merge_2
2
+ scoreboard players operation $ret rs = $x rs
3
+ return run scoreboard players get $x rs
@@ -0,0 +1,5 @@
1
+ # block: then_0
2
+ scoreboard players set $_1 rs 0
3
+ scoreboard players operation $_1 rs -= $x rs
4
+ scoreboard players operation $ret rs = $_1 rs
5
+ return run scoreboard players get $_1 rs
@@ -0,0 +1,7 @@
1
+ # block: entry
2
+ scoreboard players operation $x rs = $p0 rs
3
+ scoreboard players operation $x rs = $p0 rs
4
+ scoreboard players set $_0 rs 0
5
+ execute if score $p0 rs < $const_0 rs run scoreboard players set $_0 rs 1
6
+ execute if score $_0 rs matches 1.. run function gcd3nm:abs/then_0
7
+ execute if score $_0 rs matches ..0 run function gcd3nm:abs/merge_2
@@ -0,0 +1,7 @@
1
+ # block: loop_body_1
2
+ scoreboard players operation $_5 rs = $x rs
3
+ scoreboard players operation $_5 rs %= $y rs
4
+ scoreboard players operation $r rs = $_5 rs
5
+ scoreboard players operation $x rs = $y rs
6
+ scoreboard players operation $y rs = $_5 rs
7
+ function gcd3nm:gcd/loop_check_0
@@ -0,0 +1,5 @@
1
+ # block: loop_check_0
2
+ scoreboard players set $_4 rs 0
3
+ execute if score $y rs > $const_0 rs run scoreboard players set $_4 rs 1
4
+ execute if score $_4 rs matches 1.. run function gcd3nm:gcd/loop_body_1
5
+ execute if score $_4 rs matches ..0 run function gcd3nm:gcd/loop_exit_2
@@ -0,0 +1,3 @@
1
+ # block: loop_exit_2
2
+ scoreboard players operation $ret rs = $x rs
3
+ return run scoreboard players get $x rs
@@ -0,0 +1,14 @@
1
+ # block: entry
2
+ scoreboard players operation $a rs = $p0 rs
3
+ scoreboard players operation $b rs = $p1 rs
4
+ scoreboard players operation $a rs = $p0 rs
5
+ scoreboard players operation $b rs = $p1 rs
6
+ scoreboard players operation $p0 rs = $p0 rs
7
+ function gcd3nm:abs
8
+ scoreboard players operation $_2 rs = $ret rs
9
+ scoreboard players operation $x rs = $_2 rs
10
+ scoreboard players operation $p0 rs = $p1 rs
11
+ function gcd3nm:abs
12
+ scoreboard players operation $_3 rs = $ret rs
13
+ scoreboard players operation $y rs = $_3 rs
14
+ function gcd3nm:gcd/loop_check_0
@@ -0,0 +1,7 @@
1
+ # block: entry
2
+ scoreboard players set $p0 rs 12
3
+ scoreboard players set $p1 rs 8
4
+ function gcd3nm:gcd
5
+ scoreboard players operation $_6 rs = $ret rs
6
+ scoreboard players operation $result rs = $_6 rs
7
+ execute store result score out gcd3nm.r run scoreboard players get $result rs
@@ -0,0 +1,3 @@
1
+ # RedScript runtime init
2
+ scoreboard objectives add rs dummy
3
+ scoreboard players set $a rs 0
@@ -0,0 +1,3 @@
1
+ # block: merge_2
2
+ scoreboard players operation $q rs = $k rs
3
+ return run scoreboard players get $k rs
@@ -0,0 +1,5 @@
1
+ # block: then_0
2
+ scoreboard players set $s rs 0
3
+ scoreboard players operation $s rs -= $k rs
4
+ scoreboard players operation $q rs = $s rs
5
+ return run scoreboard players get $s rs
@@ -0,0 +1,7 @@
1
+ # block: entry
2
+ scoreboard players operation $k rs = $c rs
3
+ scoreboard players operation $k rs = $f rs
4
+ scoreboard players set $r rs 0
5
+ execute if score $f rs < $a rs run scoreboard players set $r rs 1
6
+ execute if score $r rs matches 1.. run function gcd_test:abs/then_0
7
+ execute if score $r rs matches ..0 run function gcd_test:abs/merge_2
@@ -0,0 +1,7 @@
1
+ # block: loop_body_1
2
+ scoreboard players operation $o rs = $m rs
3
+ scoreboard players operation $p rs = $k rs
4
+ scoreboard players operation $p rs %= $m rs
5
+ scoreboard players operation $m rs = $p rs
6
+ scoreboard players operation $k rs = $m rs
7
+ function gcd_test:gcd/loop_check_0
@@ -0,0 +1,5 @@
1
+ # block: loop_check_0
2
+ scoreboard players set $n rs 0
3
+ execute if score $m rs > $a rs run scoreboard players set $n rs 1
4
+ execute if score $n rs matches 1.. run function gcd_test:gcd/loop_body_1
5
+ execute if score $n rs matches ..0 run function gcd_test:gcd/loop_exit_2
@@ -0,0 +1,3 @@
1
+ # block: loop_exit_2
2
+ scoreboard players operation $q rs = $k rs
3
+ return run scoreboard players get $k rs
@@ -0,0 +1,14 @@
1
+ # block: entry
2
+ scoreboard players operation $b rs = $c rs
3
+ scoreboard players operation $d rs = $e rs
4
+ scoreboard players operation $b rs = $f rs
5
+ scoreboard players operation $d rs = $g rs
6
+ scoreboard players operation $h rs = $f rs
7
+ function gcd_test:abs
8
+ scoreboard players operation $j rs = $i rs
9
+ scoreboard players operation $k rs = $j rs
10
+ scoreboard players operation $h rs = $g rs
11
+ function gcd_test:abs
12
+ scoreboard players operation $l rs = $i rs
13
+ scoreboard players operation $m rs = $l rs
14
+ function gcd_test:gcd/loop_check_0
@@ -0,0 +1,6 @@
1
+ # RedScript runtime init
2
+ scoreboard objectives add rs dummy
3
+ scoreboard players set $a rs 0
4
+ scoreboard players set $b rs 1
5
+ scoreboard players set $c rs 2
6
+ scoreboard players set $d rs 16
@@ -0,0 +1,12 @@
1
+ # block: loop_body_4
2
+ scoreboard players operation $m rs = $e rs
3
+ scoreboard players operation $m rs /= $k rs
4
+ scoreboard players operation $n rs = $k rs
5
+ scoreboard players operation $n rs += $m rs
6
+ scoreboard players operation $o rs = $n rs
7
+ scoreboard players operation $o rs /= $c rs
8
+ scoreboard players operation $p rs = $o rs
9
+ scoreboard players set $q rs 0
10
+ execute if score $o rs >= $k rs run scoreboard players set $q rs 1
11
+ execute if score $q rs matches 1.. run function isqrttest:isqrt/then_6
12
+ execute if score $q rs matches ..0 run function isqrttest:isqrt/merge_8
@@ -0,0 +1,5 @@
1
+ # block: loop_check_3
2
+ scoreboard players set $l rs 0
3
+ execute if score $j rs < $d rs run scoreboard players set $l rs 1
4
+ execute if score $l rs matches 1.. run function isqrttest:isqrt/loop_body_4
5
+ execute if score $l rs matches ..0 run function isqrttest:isqrt/loop_exit_5
@@ -0,0 +1,3 @@
1
+ # block: loop_exit_5
2
+ scoreboard players operation $j rs = $k rs
3
+ return run scoreboard players get $k rs
@@ -0,0 +1,4 @@
1
+ # block: merge_2
2
+ scoreboard players operation $k rs = $e rs
3
+ scoreboard players set $j rs 0
4
+ function isqrttest:isqrt/loop_check_3
@@ -0,0 +1,6 @@
1
+ # block: merge_8
2
+ scoreboard players operation $k rs = $p rs
3
+ scoreboard players operation $r rs = $j rs
4
+ scoreboard players operation $r rs += $b rs
5
+ scoreboard players operation $j rs = $r rs
6
+ function isqrttest:isqrt/loop_check_3
@@ -0,0 +1,3 @@
1
+ # block: then_0
2
+ scoreboard players set $j rs 0
3
+ return 0
@@ -0,0 +1,3 @@
1
+ # block: then_6
2
+ scoreboard players operation $j rs = $k rs
3
+ return run scoreboard players get $k rs
@@ -0,0 +1,7 @@
1
+ # block: entry
2
+ scoreboard players operation $e rs = $f rs
3
+ scoreboard players operation $e rs = $g rs
4
+ scoreboard players set $h rs 0
5
+ execute if score $g rs <= $a rs run scoreboard players set $h rs 1
6
+ execute if score $h rs matches 1.. run function isqrttest:isqrt/then_0
7
+ execute if score $h rs matches ..0 run function isqrttest:isqrt/merge_2
@@ -0,0 +1,6 @@
1
+ # block: entry
2
+ scoreboard players set $s rs 9
3
+ function isqrttest:isqrt
4
+ scoreboard players operation $t rs = $i rs
5
+ scoreboard players operation $u rs = $t rs
6
+ execute store result score out isqrttest.r run scoreboard players get $result rs
@@ -0,0 +1,3 @@
1
+ # RedScript runtime init
2
+ scoreboard objectives add rs dummy
3
+ scoreboard players set $a rs 0
@@ -0,0 +1,3 @@
1
+ # block: merge_2
2
+ scoreboard players operation $f rs = $b rs
3
+ return run scoreboard players get $b rs
@@ -0,0 +1,5 @@
1
+ # block: then_0
2
+ scoreboard players set $e rs 0
3
+ scoreboard players operation $e rs -= $b rs
4
+ scoreboard players operation $f rs = $e rs
5
+ return run scoreboard players get $e rs
@@ -0,0 +1,6 @@
1
+ # block: entry
2
+ scoreboard players operation $b rs = $c rs
3
+ scoreboard players set $d rs 0
4
+ execute if score $b rs < $a rs run scoreboard players set $d rs 1
5
+ execute if score $d rs matches 1.. run function mathtest:abs/then_0
6
+ execute if score $d rs matches ..0 run function mathtest:abs/merge_2
@@ -0,0 +1,5 @@
1
+ # block: entry
2
+ scoreboard players set $c rs 42
3
+ function mathtest:abs
4
+ scoreboard players operation $g rs = $f rs
5
+ execute store result score out mathtest.r run scoreboard players get $g rs
@@ -0,0 +1,5 @@
1
+ {
2
+ "values": [
3
+ "mypack:__load"
4
+ ]
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "values": [
3
+ "runtime:__tick"
4
+ ]
5
+ }
@@ -0,0 +1,13 @@
1
+ # RedScript runtime init
2
+ scoreboard objectives add rs dummy
3
+ scoreboard players set $a rs 0
4
+ scoreboard players set $b rs 1
5
+ scoreboard players set $c rs 2
6
+ scoreboard players set $d rs 45
7
+ scoreboard players set $e rs 90
8
+ scoreboard players set $f rs 180
9
+ scoreboard players set $g rs 270
10
+ scoreboard players set $h rs 360
11
+ scoreboard players set $i rs 1000
12
+ scoreboard players set $j rs 46340
13
+ function mypack:_atan_init
@@ -0,0 +1,2 @@
1
+ # block: entry
2
+ data modify storage math:tables tan set value [0, 17, 35, 52, 70, 87, 105, 123, 141, 158, 176, 194, 213, 231, 249, 268, 287, 306, 325, 344, 364, 384, 404, 424, 445, 466, 488, 510, 532, 554, 577, 601, 625, 649, 675, 700, 727, 754, 781, 810, 839, 869, 900, 933, 966, 1000]
@@ -0,0 +1,3 @@
1
+ # block: merge_2
2
+ scoreboard players operation $k rs = $o rs
3
+ return run scoreboard players get $o rs
@@ -0,0 +1,5 @@
1
+ # block: then_0
2
+ scoreboard players set $q rs 0
3
+ scoreboard players operation $q rs -= $o rs
4
+ scoreboard players operation $k rs = $q rs
5
+ return run scoreboard players get $q rs
@@ -0,0 +1,6 @@
1
+ # block: entry
2
+ scoreboard players operation $o rs = $n rs
3
+ scoreboard players set $p rs 0
4
+ execute if score $o rs < $a rs run scoreboard players set $p rs 1
5
+ execute if score $p rs matches 1.. run function mypack:abs/then_0
6
+ execute if score $p rs matches ..0 run function mypack:abs/merge_2
@@ -0,0 +1,2 @@
1
+ # block: entry
2
+ $r store result score $s rs run data get storage math:tables tan[$(__sgi_0)] 1
@@ -0,0 +1,3 @@
1
+ # block: else_34
2
+ scoreboard players operation $al rs = $ar rs
3
+ function mypack:atan2_fixed/loop_check_30
@@ -0,0 +1,19 @@
1
+ # block: loop_body_31
2
+ scoreboard players operation $ao rs = $al rs
3
+ scoreboard players operation $ao rs += $am rs
4
+ scoreboard players operation $ap rs = $ao rs
5
+ scoreboard players operation $ap rs += $b rs
6
+ scoreboard players operation $aq rs = $ap rs
7
+ scoreboard players operation $aq rs /= $c rs
8
+ scoreboard players operation $ar rs = $aq rs
9
+ execute store result storage rs:heap __sgi_0 int 1 run scoreboard players get $ar rs
10
+ function mypack:atan2_fixed/__sgi_1 with storage rs:heap
11
+ scoreboard players operation $as rs = $s rs
12
+ scoreboard players operation $at rs = $s rs
13
+ scoreboard players operation $at rs *= $aa rs
14
+ scoreboard players operation $au rs = $ad rs
15
+ scoreboard players operation $au rs *= $i rs
16
+ scoreboard players set $av rs 0
17
+ execute if score $at rs > $au rs run scoreboard players set $av rs 1
18
+ execute if score $av rs matches 1.. run function mypack:atan2_fixed/then_33
19
+ execute if score $av rs matches ..0 run function mypack:atan2_fixed/else_34
@@ -0,0 +1,5 @@
1
+ # block: loop_check_30
2
+ scoreboard players set $an rs 0
3
+ execute if score $al rs < $am rs run scoreboard players set $an rs 1
4
+ execute if score $an rs matches 1.. run function mypack:atan2_fixed/loop_body_31
5
+ execute if score $an rs matches ..0 run function mypack:atan2_fixed/loop_exit_32
@@ -0,0 +1,6 @@
1
+ # block: loop_exit_32
2
+ scoreboard players operation $ax rs = $al rs
3
+ scoreboard players set $ay rs 0
4
+ execute if score $ai rs = $b rs run scoreboard players set $ay rs 1
5
+ execute if score $ay rs matches 1.. run function mypack:atan2_fixed/then_36
6
+ execute if score $ay rs matches ..0 run function mypack:atan2_fixed/merge_38
@@ -0,0 +1,6 @@
1
+ # block: merge_11
2
+ scoreboard players operation $aa rs = $o rs
3
+ scoreboard players set $ab rs 0
4
+ execute if score $o rs < $a rs run scoreboard players set $ab rs 1
5
+ execute if score $ab rs matches 1.. run function mypack:atan2_fixed/then_15
6
+ execute if score $ab rs matches ..0 run function mypack:atan2_fixed/merge_17
@@ -0,0 +1,3 @@
1
+ # block: merge_14
2
+ scoreboard players set $k rs 180
3
+ return 180
@@ -0,0 +1,6 @@
1
+ # block: merge_17
2
+ scoreboard players operation $ad rs = $u rs
3
+ scoreboard players set $ae rs 0
4
+ execute if score $u rs < $a rs run scoreboard players set $ae rs 1
5
+ execute if score $ae rs matches 1.. run function mypack:atan2_fixed/then_18
6
+ execute if score $ae rs matches ..0 run function mypack:atan2_fixed/merge_20
@@ -0,0 +1,5 @@
1
+ # block: merge_2
2
+ scoreboard players set $y rs 0
3
+ execute if score $u rs = $a rs run scoreboard players set $y rs 1
4
+ execute if score $y rs matches 1.. run function mypack:atan2_fixed/then_9
5
+ execute if score $y rs matches ..0 run function mypack:atan2_fixed/merge_11
@@ -0,0 +1,5 @@
1
+ # block: merge_20
2
+ scoreboard players set $ag rs 0
3
+ execute if score $aa rs > $j rs run scoreboard players set $ag rs 1
4
+ execute if score $ag rs matches 1.. run function mypack:atan2_fixed/then_21
5
+ execute if score $ag rs matches ..0 run function mypack:atan2_fixed/merge_23
@@ -0,0 +1,5 @@
1
+ # block: merge_23
2
+ scoreboard players set $ah rs 0
3
+ execute if score $ad rs > $j rs run scoreboard players set $ah rs 1
4
+ execute if score $ah rs matches 1.. run function mypack:atan2_fixed/then_24
5
+ execute if score $ah rs matches ..0 run function mypack:atan2_fixed/merge_26
@@ -0,0 +1,6 @@
1
+ # block: merge_26
2
+ scoreboard players set $ai rs 0
3
+ scoreboard players set $aj rs 0
4
+ execute if score $ad rs > $aa rs run scoreboard players set $aj rs 1
5
+ execute if score $aj rs matches 1.. run function mypack:atan2_fixed/then_27
6
+ execute if score $aj rs matches ..0 run function mypack:atan2_fixed/merge_29
@@ -0,0 +1,4 @@
1
+ # block: merge_29
2
+ scoreboard players set $al rs 0
3
+ scoreboard players set $am rs 45
4
+ function mypack:atan2_fixed/loop_check_30
@@ -0,0 +1,5 @@
1
+ # block: merge_38
2
+ scoreboard players set $ba rs 0
3
+ execute if score $o rs > $a rs run scoreboard players set $ba rs 1
4
+ execute if score $ba rs matches 1.. run function mypack:atan2_fixed/then_39
5
+ execute if score $ba rs matches ..0 run function mypack:atan2_fixed/merge_41
@@ -0,0 +1,5 @@
1
+ # block: merge_41
2
+ scoreboard players set $bd rs 0
3
+ execute if score $u rs >= $a rs run scoreboard players set $bd rs 1
4
+ execute if score $bd rs matches 1.. run function mypack:atan2_fixed/then_45
5
+ execute if score $bd rs matches ..0 run function mypack:atan2_fixed/merge_47
@@ -0,0 +1,5 @@
1
+ # block: merge_44
2
+ scoreboard players set $bc rs 360
3
+ scoreboard players operation $bc rs -= $ax rs
4
+ scoreboard players operation $k rs = $bc rs
5
+ return run scoreboard players get $bc rs
@@ -0,0 +1,5 @@
1
+ # block: merge_47
2
+ scoreboard players set $bf rs 180
3
+ scoreboard players operation $bf rs += $ax rs
4
+ scoreboard players operation $k rs = $bf rs
5
+ return run scoreboard players get $bf rs
@@ -0,0 +1,5 @@
1
+ # block: merge_5
2
+ scoreboard players set $x rs 0
3
+ execute if score $u rs < $a rs run scoreboard players set $x rs 1
4
+ execute if score $x rs matches 1.. run function mypack:atan2_fixed/then_6
5
+ execute if score $x rs matches ..0 run function mypack:atan2_fixed/merge_8