From bb4ca7b31ad81b92651c81203fa74c1c8e4cbd87 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 23 Jun 2019 00:06:39 +0900 Subject: [PATCH] Resolve #5010 --- locales/ja-JP.yml | 3 +++ src/misc/aiscript/evaluator.ts | 1 + src/misc/aiscript/index.ts | 1 + 3 files changed, 5 insertions(+) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 47e1d4d93..88673e804 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -2151,6 +2151,9 @@ pages: _pick: arg1: "リスト" arg2: "位置" + listLen: "リストの長さを取得" + _listLen: + arg1: "リスト" number: "数値" stringToNumber: "テキストを数値に" _stringToNumber: diff --git a/src/misc/aiscript/evaluator.ts b/src/misc/aiscript/evaluator.ts index d93fcebcf..f6165afb6 100644 --- a/src/misc/aiscript/evaluator.ts +++ b/src/misc/aiscript/evaluator.ts @@ -171,6 +171,7 @@ export class ASEvaluator { numberToString: (a: number) => a.toString(), splitStrByLine: (a: string) => a.split('\n'), pick: (list: any[], i: number) => list[i - 1], + listLen: (list: any[]) => list.length, random: (probability: number) => Math.floor(seedrandom(`${this.opts.randomSeed}:${block.id}`)() * 100) < probability, rannum: (min: number, max: number) => min + Math.floor(seedrandom(`${this.opts.randomSeed}:${block.id}`)() * (max - min + 1)), randomPick: (list: any[]) => list[Math.floor(seedrandom(`${this.opts.randomSeed}:${block.id}`)() * list.length)], diff --git a/src/misc/aiscript/index.ts b/src/misc/aiscript/index.ts index 8635399da..3a21e9b1c 100644 --- a/src/misc/aiscript/index.ts +++ b/src/misc/aiscript/index.ts @@ -74,6 +74,7 @@ export const funcDefs: Record