Skip to content

Commit

Permalink
feat(generate-npc): 支持了数组长度过滤
Browse files Browse the repository at this point in the history
  • Loading branch information
Raven-Book committed Sep 22, 2024
1 parent 94df5e5 commit f718c08
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions docs/src/黑星的Macro合集/宏列表 第一弹.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ setup.config = {

### 3.1 过滤条件编写

> [!INFO]
> 可通过 `length` 限制返回的个数。
>
> 如果希望随机返回指定个数,正常filter并使用方糖的[randomMany函数](https://www.motoslave.net/sugarcube/2/docs/#methods-array-prototype-method-randommany) `_result.randomMany(返回数)`,随机后使用临时变量存储,就可以对该数组进行遍历以及其他操作了。
1. 范围过滤(min, max),指定数字在指定范围内。
- 属性:力量 (strength)
- 条件: 在 50 到 100 之间
Expand Down Expand Up @@ -192,6 +197,10 @@ setup.config = {
<<print _result.length>>
<</filternpc>>
<!-- 获取一个tags包含家人的NPC -->
<<filternpc $npcs `{ tags: ['家人'], length: 1}`>>
<<print _result.length>>
<</filternpc>>
<!-- 打印 -->
<<for _i, _npc range $npcs>>
_npc.first _npc.last
Expand Down
4 changes: 2 additions & 2 deletions src/js/utils/generate-npc.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f718c08

Please sign in to comment.