From 1eb557806374373a682d0d0a192ac9f09007ef85 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 20 Dec 2019 02:09:51 +0900 Subject: [PATCH] Add round function --- locales/ja-JP.yml | 3 +++ src/misc/aiscript/evaluator.ts | 1 + src/misc/aiscript/index.ts | 2 ++ 3 files changed, 6 insertions(+) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index e0fb5087a..6483eb541 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -2200,6 +2200,9 @@ pages: _mod: arg1: "A" arg2: "B" + round: "少数を丸める" + _round: + arg1: "数" eq: "AとBが同じ" _eq: arg1: "A" diff --git a/src/misc/aiscript/evaluator.ts b/src/misc/aiscript/evaluator.ts index f6165afb6..857de1308 100644 --- a/src/misc/aiscript/evaluator.ts +++ b/src/misc/aiscript/evaluator.ts @@ -162,6 +162,7 @@ export class ASEvaluator { multiply: (a: number, b: number) => a * b, divide: (a: number, b: number) => a / b, mod: (a: number, b: number) => a % b, + round: (a: number) => Math.round(a), strLen: (a: string) => a.length, strPick: (a: string, b: number) => a[b - 1], strReplace: (a: string, b: string, c: string) => a.split(b).join(c), diff --git a/src/misc/aiscript/index.ts b/src/misc/aiscript/index.ts index 3a21e9b1c..f2de1bb40 100644 --- a/src/misc/aiscript/index.ts +++ b/src/misc/aiscript/index.ts @@ -24,6 +24,7 @@ import { faExchangeAlt, faRecycle, faIndent, + faCalculator, } from '@fortawesome/free-solid-svg-icons'; import { faFlag } from '@fortawesome/free-regular-svg-icons'; @@ -59,6 +60,7 @@ export const funcDefs: Record