From c9763dabe1c7e372777af69fa1df627b469a609a Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 30 Apr 2019 07:49:46 +0900 Subject: [PATCH] =?UTF-8?q?=E5=A4=89=E6=8F=9B=E9=96=A2=E6=95=B0=E3=82=92?= =?UTF-8?q?=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 | 7 +++++++ src/client/app/common/scripts/aiscript.ts | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 343d9cfc3..463c4cbf7 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1907,6 +1907,7 @@ pages: value: "値" fn: "関数" text: "テキスト操作" + convert: "変換" blocks: text: "テキスト" multiLineText: "テキスト(複数行)" @@ -2005,6 +2006,12 @@ pages: _dailyRandomPick: arg1: "リスト" number: "数" + stringToNumber: "テキストを数値に" + _stringToNumber: + arg1: "テキスト" + numberToString: "数値をテキストに" + _numberToString: + arg1: "数値" ref: "変数" in: "入力" _in: diff --git a/src/client/app/common/scripts/aiscript.ts b/src/client/app/common/scripts/aiscript.ts index fe9a29500..98c1da921 100644 --- a/src/client/app/common/scripts/aiscript.ts +++ b/src/client/app/common/scripts/aiscript.ts @@ -26,6 +26,7 @@ import { faNotEqual, faDice, faSortNumericUp, + faExchangeAlt, } from '@fortawesome/free-solid-svg-icons'; import { faFlag } from '@fortawesome/free-regular-svg-icons'; @@ -69,6 +70,8 @@ const funcDefs = { strPick: { in: ['string', 'number'], out: 'string', category: 'text', icon: faQuoteRight, }, strReplace: { in: ['string', 'string', 'string'], out: 'string', category: 'text', icon: faQuoteRight, }, strReverse: { in: ['string'], out: 'string', category: 'text', icon: faQuoteRight, }, + stringToNumber: { in: ['string'], out: 'number', category: 'convert', icon: faExchangeAlt, }, + numberToString: { in: ['number'], out: 'string', category: 'convert', icon: faExchangeAlt, }, rannum: { in: ['number', 'number'], out: 'number', category: 'random', icon: faDice, }, random: { in: ['number'], out: 'boolean', category: 'random', icon: faDice, }, randomPick: { in: [0], out: 0, category: 'random', icon: faDice, }, @@ -421,6 +424,8 @@ export class AiScript { strPick: (a, b) => a[b - 1], strReplace: (a, b, c) => a.split(b).join(c), strReverse: (a) => a.split('').reverse().join(''), + stringToNumber: (a) => parseInt(a), + numberToString: (a) => a.toString(), random: (probability) => Math.floor(seedrandom(`${this.opts.randomSeed}:${block.id}`)() * 100) < probability, rannum: (min, max) => min + Math.floor(seedrandom(`${this.opts.randomSeed}:${block.id}`)() * (max - min + 1)), randomPick: (list) => list[Math.floor(seedrandom(`${this.opts.randomSeed}:${block.id}`)() * list.length)],