Skip to content
This repository was archived by the owner on Apr 19, 2025. It is now read-only.

Commit 2610bcc

Browse files
Update cloudlink_adacraft.js
also diff format so might not work
1 parent c54128a commit 2610bcc

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

scratch/cloudlink_adacraft.js

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@
7878

7979
// Store extension state
8080
var clVars = {
81-
81+
// variable for preventing any spammy messages (TX and RX) that CL logs, potentially increasing performance. Noticed by TheShovel and mentioned it in the discord server, so I'm just adding it here
82+
logToConsole: true,
83+
8284
// WebSocket object.
8385
socket: null,
8486

@@ -384,7 +386,9 @@
384386
}
385387

386388
// Send the message
387-
console.log("[CloudLink] TX:", message);
389+
if (clVars.logToConsole) {
390+
console.log("[CloudLink] TX:", message);
391+
}
388392
clVars.socket.send(outgoing);
389393
}
390394

@@ -482,7 +486,9 @@
482486
console.error("[CloudLink] Incoming message read failure! This message doesn't contain the required \"cmd\" key. Is this really a CloudLink server?", packet);
483487
return;
484488
}
485-
console.log("[CloudLink] RX:", packet);
489+
if (clVars.logToConsole) {
490+
console.log("[CloudLink] RX:", packet);
491+
}
486492
switch (packet.cmd) {
487493
case "gmsg":
488494
clVars.gmsg.varState = packet.val;
@@ -1484,6 +1490,21 @@
14841490
},
14851491

14861492
"---",
1493+
1494+
{
1495+
opcode: "changeLogToConsole",
1496+
blockType: BlockType.COMMAND,
1497+
text: "[BOOL] logging to console",
1498+
arguments: {
1499+
BOOL: {
1500+
type: ArgumentType.STRING,
1501+
menu: "boolmenu",
1502+
defaultValue: "Enable",
1503+
},
1504+
}
1505+
},
1506+
1507+
"---",
14871508

14881509
],
14891510
menus: {
@@ -1499,6 +1520,9 @@
14991520
almostallmenu: {
15001521
items: ['Global data', 'Private data', 'Direct data', 'Status code', "Global variables", "Private variables"]
15011522
},
1523+
boolmenu: {
1524+
items: ['Enable', 'Disable']
1525+
}
15021526
}
15031527
};
15041528
}
@@ -2319,6 +2343,10 @@
23192343
break;
23202344
}
23212345
}
2346+
2347+
changeLogToConsole(args) {
2348+
clVars.logToConsole = args.BOOL == 'Enable';
2349+
}
23222350
}
23232351
console.log("[CloudLink] Extension loaded!");
23242352
module.exports = CloudLink;

0 commit comments

Comments
 (0)