From 13d9a967d946db62f79325e61b7bf74f5ecf1b71 Mon Sep 17 00:00:00 2001 From: Silver Kuusik Date: Sat, 6 Jan 2018 11:55:13 +0100 Subject: [PATCH] fix Python code upload --- sumorobot.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sumorobot.js b/sumorobot.js index 46a6446..903c934 100755 --- a/sumorobot.js +++ b/sumorobot.js @@ -408,9 +408,17 @@ window.onload = function() { /* start button listener */ $(".btn-start").click(function() { sumostart = true; + /* if we are in Python mode */ if (pythonEnabled) { - sumorobot.send("start:" + $("#blocklyCode").val().replace(/sumorobot./g, "").replace(/\)/g, ", \"\")")); + /* add the an empty block ID to the functions */ + var code = $("#blocklyCode").val().replace(/sumorobot./g, "").replace(/\)/g, ", \"\")"); + /* is_enemy doesn't need the , */ + code = code.replace(/\(, ""\)/g, "(\"\")"); + /* send the code to the SumoRobot */ + sumorobot.send("start:" + code); + /* otherwise when we are in blockly mode */ } else { + /* send the code to the SumoRobot */ sumorobot.send("start:" + sumocode.replace(/sumorobot./g, "")); } });