swap-local-global: allow conversion between local and global across multiple sprites - #9075
Open
griffpatch wants to merge 1 commit into
Open
swap-local-global: allow conversion between local and global across multiple sprites#9075griffpatch wants to merge 1 commit into
griffpatch wants to merge 1 commit into
Conversation
…ultiple sprites When converting global→local, create a local copy in each other sprite that uses the variable so their blocks keep working. When converting local→global, merge any same-named locals in other sprites into the new global by remapping block references and deleting the now-redundant locals.
apple502j
reviewed
Jun 21, 2026
apple502j
left a comment
Member
There was a problem hiding this comment.
Question, should the code change sensing_of (for local->global?)
Contributor
Author
|
Yeah, I wondered about that... I am not sure, maybe even if it should have
a warning when that is the case because it can be a breaking change as in
the other direction it will not know which sprite you were referencing
…On Sun, 21 Jun 2026, 18:37 apple502j, ***@***.***> wrote:
***@***.**** commented on this pull request.
Question, should the code change sensing_of (for local->global?)
—
Reply to this email directly, view it on GitHub
<#9075?email_source=notifications&email_token=ABTM3PSU73624SWSAEHGY5D5BAMO3A5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTINJUGAYDKMRUHEZKM4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L#pullrequestreview-4540052492>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABTM3PWORK5I7RRWO2RPKF35BAMO3AVCNFSNUABFKJSXA33TNF2G64TZHMZDQMRSG4YTQMBTHNEXG43VMU5TINRYGE2DAMBWG4Z2C5QC>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/ABTM3PVO3PQQTVSEMXM7EXD5BAMO3A5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTINJUGAYDKMRUHEZKM4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KUZTPN52GK4S7NFXXG>
and Android
<https://github.com/notifications/mobile/android/ABTM3PT5JQSKJV242MJ3HIL5BAMO3A5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTINJUGAYDKMRUHEZKM4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2K4ZTPN52GK4S7MFXGI4TPNFSA>.
Download it today!
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
The swap-local-global addon now allows converting a variable between local and global even when it is used by multiple sprites. Previously this was blocked with an error message.
Changes
Global → Local: When converting a global variable to local on the current sprite, any other sprite that also uses that variable now automatically gets its own independent local copy with the same name and current value. All of those sprites' block references are remapped to their new local ID so nothing breaks.
Local → Global: When converting a local variable to global, any other sprite that happens to have a same-named local variable is automatically merged into the new global — its blocks are remapped to point at the global ID and its now-redundant local is deleted.
A small shared helper
remapVariableReferencesInTargetwas added to walk a target's block fields and update any field whose ID matches the old variable, used by both conversion paths.Reason for changes
The previous behaviour blocked very common real-world cases. A game's
scoreorlivesvariable is often shared between a player sprite and the stage. A student clicking "make local" on such a variable was met with an unhelpful error rather than a useful outcome. The new behaviour does what users intuitively expect: each sprite gets its own copy (or they all share the one global), with no manual cleanup needed.Tests
Tested in Chrome: