diff --git a/src/makecode/generate-main-scripts.ts b/src/makecode/generate-main-scripts.ts
index 414dd5c18..a2180b61d 100644
--- a/src/makecode/generate-main-scripts.ts
+++ b/src/makecode/generate-main-scripts.ts
@@ -15,14 +15,16 @@ interface BlockPos {
y: number;
}
-const onMLEventBlock = (name: string, children: string, pos: BlockPos) => `
-
- ml.event.${name}
-
- ${children}
-
-
-`;
+const onMLEventBlock = (name: string, children: string, pos: BlockPos) => {
+ let code = "";
+ code += ``;
+ code += `ml.event.${name}`;
+ code += '';
+ code += children;
+ code += "";
+ code += "";
+ return code;
+};
type Language = "blocks" | "javascript";
@@ -38,7 +40,7 @@ const statements: Record = {
javascript: {
wrapper: (children) => children + "\n",
showLeds: (ledPattern) => `basic.showLeds(\`${ledPattern}\`)`,
- showIcon: (iconName) => `basic.showIcon(IconNames.${iconName})`,
+ showIcon: (iconName) => `\n basic.showIcon(IconNames.${iconName})\n`,
clearDisplay: () => "basic.clearScreen()",
onMLEvent: (name, children) => {
return `ml.onStart(ml.event.${name}, function () {${children}})`;
@@ -80,6 +82,6 @@ export const getMainScript = (actions: Action[], lang: Language) => {
y: initPos.y + idx * 180,
})
)
- .join("\n")
+ .join(lang === "javascript" ? "\n" : "")
);
};