Skip to content

Commit

Permalink
小修一下示例
Browse files Browse the repository at this point in the history
  • Loading branch information
A4-Tacks committed Sep 18, 2024
1 parent a1a031c commit a6d8dc3
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README-en_US.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ while id < @unitCount {
while Bind != first {
# if the first unit dies, restart this type of counting
goto :restart (sensor $ first @dead;);
icount += 1;
icount++;
}
# Accumulate the number of units to the total number of units
count += icount;
Expand All @@ -139,7 +139,7 @@ while id < @unitCount {
print unit_type ": " icount "\n";
}
id += 1; # add units type id
id++; # plus units type id
}
print "unit total: " count;
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ while id < @unitCount {
while Bind != first {
# 若头单位死亡, 则重新统计该类单位
goto :restart (sensor $ first @dead;);
icount += 1;
icount++;
}
count += icount; # 将该单位数累加到总单位数
# 打印每种存在的单位
print unit_type ": " icount "\n";
}
id += 1; # 推进单位id
id++; # 推进单位id
}
print "unit total: " count;
Expand Down
4 changes: 2 additions & 2 deletions examples/iter.mdtlbl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const Memory = (
take I = ...i;
if I < ...End {
take ...Run[F];
op I I + 1;
I++;
}
);
const $.ForEach = (
Expand All @@ -76,7 +76,7 @@ const Memory = (
take I = ...i;
while I < ...End {
take ...Run[F];
op I I + 1;
I++;
}
);
);
Expand Down
40 changes: 37 additions & 3 deletions examples/unit_count.mdtlbl
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,50 @@ while id < @unitCount {
while Bind != first {
# 若头单位死亡, 则重新统计该类单位
goto :restart (sensor $ first @dead;);
icount = icount + 1;
icount++;
}
count = count + icount; # 将该单位数累加到总单位数
count += icount; # 将该单位数累加到总单位数

# 打印每种存在的单位
print unit_type ": " icount "\n";
}

id = id + 1; # 推进单位id
id++; # 推进单位id
}

print "unit total: " count;
printflush message1;

#* Li >>>
set id 0
set count id
jump ___3 greaterThanEq id @unitCount
___4:
lookup unit unit_type id
restart:
ubind unit_type
jump ___2 strictEqual @unit null
set first @unit
set icount 1
ubind unit_type
jump ___0 equal @unit first
___1:
sensor __0 first @dead
jump restart notEqual __0 false
op add icount icount 1
ubind unit_type
jump ___1 notEqual @unit first
___0:
op add count count icount
print unit_type
print ": "
print icount
print "\n"
___2:
op add id id 1
jump ___4 lessThan id @unitCount
___3:
print "unit total: "
print count
printflush message1
*#
4 changes: 2 additions & 2 deletions syntax/vim/logic.vim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
" Vim syntax file
" Language: mindustry logic (logic)
" Maintainer: A4-Tacks <[email protected]>
" Last Change: 2024-08-29
" Last Change: 2024-09-18
" URL: https://github.com/A4-Tacks/mindustry_logic_bang_lang
scriptencoding utf-8

Expand Down Expand Up @@ -40,7 +40,7 @@ syn match logicHeadLabel /\%(^\|;\)\@1<=\s*:\=[^ \t\r;:#]\+:\ze\s*[;#\n]/
syn match logicPrint /print[ \t]/ contained nextgroup=logicPrintBody,logicPrintBodyVar skipwhite
syn match logicPrintBody /"[^"\n]*"/ contained nextgroup=logicPrintRest skipwhite contains=logicStringEscape,logicStringColor
syn match logicPrintBodyVar /[^ \t\r;:#"]\+/ contained nextgroup=logicPrintRest skipwhite
syn match logicPrintRest /;[ \t]*print[ \t]/ contained nextgroup=logicPrintBody,logicPrintBodyVar skipwhite conceal
syn match logicPrintRest /;[ \t]*print[ \t]/ contained nextgroup=logicPrintBody,logicPrintBodyVar skipwhite conceal
syn region logicString start=/"/ end=/"/ contains=logicStringEscape,logicStringColor
syn match logicStringColor contained /\[\v%(#\x{6,8}|%(c%(lear|yan|oral)|b%(l%(ack|ue)|r%(own|ick))|white|li%(ghtgray|me)|g%(r%(ay|een)|old%(enrod)?)|darkgray|navy|r%(oyal|ed)|s%(late|ky|carlet|almon)|t%(eal|an)|acid|forest|o%(live|range)|yellow|p%(ink|urple)|ma%(genta|roon)|violet))=\]/
syn match logicStringEscape /\\n\|\[\[/ contained
Expand Down

0 comments on commit a6d8dc3

Please sign in to comment.