From d5c9d1789935723c7d5e64b96a900c5aae1fddc0 Mon Sep 17 00:00:00 2001 From: vlad Date: Sun, 20 Feb 2022 16:16:45 +0200 Subject: [PATCH] Fix forever blocks with only one block not working --- config.py | 8 ++++++-- scratch.py | 14 ++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/config.py b/config.py index 59dadd0..38292dc 100644 --- a/config.py +++ b/config.py @@ -24,11 +24,15 @@ # Enable terminal output # Set whether any output messages should be allowed. -enableTerminalOutput = True +enableTerminalOutput: bool = False # Enable debug messages # Set whether debug messages (messages to stderr) should be allowed. -enableDebugMessages = True +enableDebugMessages: bool = True + +# Enable Scratch Addons debugger logs +# This allows projects using Scratch Addons to print messages to the console. Vanilla Scratch doesn't support it. +showSALogs: bool = True # Max FPS # Set maximum frame rate. Most projects won't break, but they diff --git a/scratch.py b/scratch.py index f50eb62..89b8eac 100644 --- a/scratch.py +++ b/scratch.py @@ -241,6 +241,7 @@ def execute(block, s, keys=[]): s.target.blocks[b].blockRan = False nextBlock = s.target.blocks[inputs["SUBSTACK"][1]] nb = s.target.blocks[inputs["SUBSTACK"][1]] + block.substack.add(nb.blockID) while nb.next and nb.next != block.blockID: # TODO: Caution: Don't loop the program nb.blockRan = False @@ -252,12 +253,13 @@ def execute(block, s, keys=[]): nb.next = block.blockID return nextBlock elif opcode == "procedures_call": - if block.proccode == "​​log​​ %s": # Scratch Addons log () - print("PROJECT LOG:", block.getCustomInputValue(0), file=sys.stderr) - elif block.proccode == "​​warn​​ %s": # Scratch Addons warn () - print("PROJECT WARN:", block.getCustomInputValue(0), file=sys.stderr) - elif block.proccode == "​​error​​ %s": # Scratch Addons error () - print("PROJECT ERROR:", block.getCustomInputValue(0), file=sys.stderr) + if config.showSALogs: + if block.proccode == "​​log​​ %s": # Scratch Addons log () + print("PROJECT LOG:", block.getCustomInputValue(0), file=sys.stderr) + elif block.proccode == "​​warn​​ %s": # Scratch Addons warn () + print("PROJECT WARN:", block.getCustomInputValue(0), file=sys.stderr) + elif block.proccode == "​​error​​ %s": # Scratch Addons error () + print("PROJECT ERROR:", block.getCustomInputValue(0), file=sys.stderr) else: print("Unknown opcode:", opcode)