Open Wowfunhappy opened 1 year ago
Where is the code responsible for fixing variables that are dragged between sprites, and could that same code be applied to pasting?
Okay, so I've at least found the answer to that question:
https://github.com/LLK/scratch-gui/pull/2619/commits/07a679d19e50a21f5c78f139fe8ecdddf3529788 https://github.com/LLK/scratch-vm/blob/develop/src/virtual-machine.js#L1240
Expected Behavior
No two distinct variables in a given project should have the same ID.
Actual Behavior
Two different local variables in different sprites can share a single ID. This interferes with monitors. Although each sprite can independently access and modify their own copy of the variable (changing the variable in one sprite doesn't change it in the other sprite), the user will only be able to show one of the two variable monitors.
Steps to Reproduce
set foo to 0
) onto the workspace.Operating System and Browser
Mac OS X, Chromium 111.
This may be a duplicate of https://github.com/LLK/scratch-vm/issues/2429, but that issue seems to be caused by some sort of race condition in very large projects . By contrast, the problem described above can be easily replicated in projects of any size, and I've had it come up frequently while teaching students in schools.
Notably, if you drag your block between sprites (share the love) instead of using ⌘C and ⌘V, the new local variable will be created properly. It's merely copying and pasting that causes problems.
Where is the code responsible for fixing variables that are dragged between sprites, and could that same code be applied to pasting?
P.S. See also: https://github.com/LLK/scratch-vm/issues/1766, https://github.com/LLK/scratch-vm/issues/1375