From fc0aab38cede6938c9a16e04a7135dd47223fea5 Mon Sep 17 00:00:00 2001 From: fustyles <34397289+fustyles@users.noreply.github.com> Date: Mon, 9 Oct 2023 17:48:21 +0800 Subject: [PATCH] Update javascript.js --- GameElements_20190131/blockly/javascript.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/GameElements_20190131/blockly/javascript.js b/GameElements_20190131/blockly/javascript.js index 29bcc0b3a0..171e97bbdb 100644 --- a/GameElements_20190131/blockly/javascript.js +++ b/GameElements_20190131/blockly/javascript.js @@ -2331,3 +2331,18 @@ Blockly.JavaScript['music_delete'] = function (block) { var code = 'clearInterval(musicTimer);\nmusic_delete();\n'; return code; }; + +Blockly.JavaScript['element_select'] = function (block) { + var value_source_ = block.getFieldValue('source_'); + var value_id_ = Blockly.JavaScript.valueToCode(block, 'id_', Blockly.JavaScript.ORDER_ATOMIC); + if ((value_id_.indexOf("'")==0)&&(value_id_.lastIndexOf("'")==value_id_.length-1)) + value_id_ = value_id_.substring(1,value_id_.length-1); + var source_id; + if (value_source_=="text") + source_id = 'gametext_'+value_id_; + else if (value_source_=="textarea") + source_id = 'gametextarea_'+value_id_; + + var code = 'element_select("' + source_id + '");\n'; + return code; +};