From 7b6ba8cb9aa9f859b975711f83f660f95484ead3 Mon Sep 17 00:00:00 2001 From: apple502j <33279053+apple502j@users.noreply.github.com> Date: Fri, 14 Sep 2018 20:56:40 +0900 Subject: [PATCH] Bubble string length limit --- src/blocks/scratch3_looks.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/blocks/scratch3_looks.js b/src/blocks/scratch3_looks.js index f95716f72..373083afd 100644 --- a/src/blocks/scratch3_looks.js +++ b/src/blocks/scratch3_looks.js @@ -58,6 +58,14 @@ class Scratch3LooksBlocks { return 'Scratch.looks'; } + /** + * Limit for say bubble string. + * @const {string} + */ + static get SAY_BUBBLE_LIMIT () { + return 330; + } + /** * @param {Target} target - collect bubble state for this target. Probably, but not necessarily, a RenderedTarget. * @returns {BubbleState} the mutable bubble state associated with that target. This will be created if necessary. @@ -278,7 +286,7 @@ class Scratch3LooksBlocks { if (typeof message === 'number') { message = parseFloat(message.toFixed(2)); } - message = String(message); + message = String(message).substr(0, Scratch3LooksBlocks.SAY_BUBBLE_LIMIT); this.runtime.emit('SAY', util.target, 'say', message); } @@ -299,7 +307,7 @@ class Scratch3LooksBlocks { } think (args, util) { - this._updateBubble(util.target, 'think', String(args.MESSAGE)); + this._updateBubble(util.target, 'think', String(args.MESSAGE).substr(0, Scratch3LooksBlocks.SAY_BUBBLE_LIMIT)); } thinkforsecs (args, util) {