-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
添加了control-block, 可以简单的控制break和continue的目标了
- Loading branch information
Showing
7 changed files
with
286 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "mindustry_logic_bang_lang" | ||
version = "0.12.7" | ||
version = "0.12.8" | ||
edition = "2021" | ||
|
||
authors = ["A4-Tacks <[email protected]>"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#** | ||
* 这是0.12.8加入的功能, 可以自定义break和continue的跳出点. | ||
* 语法为(("break" | "continue") "!"?)+ Block | ||
* 其中编写break就是表示捕获break至块末尾, | ||
* 编写continue就是表示捕获continue至块末尾. | ||
* | ||
* 当break或者continue后方加上了叹号时, 将反转其跳转点, | ||
* 例如`break! { ... }`内部使用break会跳转到块首部, | ||
* 也就是应该continue跳转到的位置. | ||
*# | ||
|
||
i = 0; | ||
while i < 10 { | ||
continue! { | ||
getlink block i; | ||
continue !(sensor $ block @enabled;); | ||
} | ||
op i i + 1; | ||
} | ||
#* >>> | ||
set i 0 | ||
jump 0 greaterThanEq i 10 | ||
getlink block i | ||
sensor __0 block @enabled | ||
jump 5 equal __0 false | ||
op add i i 1 | ||
jump 2 lessThan i 10 | ||
*# | ||
# 可以看到, 控制块中的continue被导向了i自加处, | ||
# 这样就可以在循环等结构中简单的定义break和continue的导向处了 | ||
# 合理使用可以增加一些可读性等 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters