From ca2949fbb4521bffb6a4d31ea673016ffd55d65a Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 5 May 2019 20:31:15 +0900 Subject: [PATCH] =?UTF-8?q?MisskeyPages=E3=81=AB=E3=83=AA=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=81=8B=E3=82=89=E9=81=B8=E6=8A=9E=E9=96=A2=E6=95=B0?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/ja-JP.yml | 5 +++++ src/misc/aiscript/evaluator.ts | 1 + src/misc/aiscript/index.ts | 2 ++ 3 files changed, 8 insertions(+) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index e337f9383..c9f7436a9 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1941,6 +1941,7 @@ pages: fn: "関数" text: "テキスト操作" convert: "変換" + list: "リスト" blocks: text: "テキスト" multiLineText: "テキスト(複数行)" @@ -2062,6 +2063,10 @@ pages: DRPWPM: "確率付きリストからランダムに選択 (ユーザーごとに日替わり)" _DRPWPM: arg1: "テキストのリスト" + pick: "リストから選択" + _pick: + arg1: "リスト" + arg2: "位置" number: "数値" stringToNumber: "テキストを数値に" _stringToNumber: diff --git a/src/misc/aiscript/evaluator.ts b/src/misc/aiscript/evaluator.ts index e28bf6414..2100b565d 100644 --- a/src/misc/aiscript/evaluator.ts +++ b/src/misc/aiscript/evaluator.ts @@ -169,6 +169,7 @@ export class ASEvaluator { stringToNumber: (a: string) => parseInt(a), numberToString: (a: number) => a.toString(), splitStrByLine: (a: string) => a.split('\n'), + pick: (list: any[], i: number) => list[i - 1], 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 46d075168..4f66d688e 100644 --- a/src/misc/aiscript/index.ts +++ b/src/misc/aiscript/index.ts @@ -23,6 +23,7 @@ import { faSortNumericUp, faExchangeAlt, faRecycle, + faIndent, } from '@fortawesome/free-solid-svg-icons'; import { faFlag } from '@fortawesome/free-regular-svg-icons'; @@ -72,6 +73,7 @@ export const funcDefs: Record