内置函数
IM 的脚本自带一套函数库,本节按类别列出。函数名不带 @ 前缀,参数用括号包围。
分类一览
| 页面 | 覆盖 |
|---|---|
| 数学 / 随机 / 字符串 | max / min / clamp / floor / ceil / round / sqrt / pow / abs / between;rand / rand_float / weighted_random;length / substring / replace / lowercase / uppercase / trim / contains / startswith / endswith / split / format / color / matches / equals / isempty |
| 时间 / 条件 | now / date / time / datetime / hour / minute / dayofweek / dayofmonth / month / year;clamp / between / coalesce / ifnull / typeof |
| 列表 / 统计 | list_size / list_get / list_contains / list_join / list_index / list_add / list_insert / list_set / list_remove / list_remove_value / list_clear / list_copy;count_filled / count_on / sum / sum_extract / sum_attr |
| 物品 / JSON | item / getItem / itemid / isMM / isNI / item.create;json_get / json_has / json_unescape;nidata / nidata_debug |
| 外部集成 / 冷却 / 调试 | hasPermission / isOp / papi / papi_parse;cooldown 系列;cx_* / cxt_*;lshop_*;wh_*;vault.*;log / debug;match_recipe |
约定
- 返回值:本文所有表格的"返回值"标注脚本视角的类型(
Number/String/Boolean/List/ItemStack/Any/null)。 - 变长参数:
...表示可接受任意个同类型参数,例如max(a, b, ...)。 - 槽位组参数:像
count_filled(@food)这样直接传@xxx引用的函数,既接受单个槽位也接受槽位组。 - 副作用函数:如
cooldown_set、vault.store、cx_set会修改外部状态,不建议放在variables中(每次刷新都会执行)。
下一步:数学 / 随机 / 字符串。