forked from scratchfoundation/scratch-flash
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Broadcast vars #42
Merged
Merged
Broadcast vars #42
Conversation
This file contains 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
These are basically custom blocks with a special prefix ("$$SCRAP:") that get disguised as different blocks. Their procedure definitions don't appear in the scripting area or script explorer. Fun fact/misfeature: you can right-click on library blocks and get access to the usual "define" block, letting you access the block's code from your normal project! This is kind of interesting and does inspire things like real modules (..ha..ha..). In order to consider this a real feature I'll need to prevent those custom blocks from being edited. Also, this commit is S U P E R C O N T R O V E R S I A L, because the current only langauge block dynamically sets a variable using a HACKED BLOCK! Which is somewhat against the idea of Scrap entirely. But that's why this is on a different branch. PS, of course, language blocks work in normal Scratch. They're only *displayed* differently, they're not actual new blocks. ---- Scratch code changes: * New constants, Specs.MAGIC_PROC_PREFIX ("$$SCRAP") and Specs.MAGIC_PROC_HUMAN ("(Scrap)") * If the start of a block label is MAGIC_PROC_PREFIX, it will be replaced with MAGIC_PROC_HUMAN. * Converted PaletteBuilder.as into normal whitespace instead of tabs, for convenience * Added new "add library" button to More Blocks palette * Placed after normal custom blocks, before extensions * Adds blocks from the "Scrap library", through a new addJSONScripts ScratchObj method * Added new "visibleScripts" method to ScratchObj * Returns scripts that should be visible for editing * "Visible" means all scripts, excluding procedures whose definitions start with MAGIC_PROC_PREFIX * Used anywhere obj.scripts would be looped through in relation to displaying blocks (i.e. script browser, script pane) * Added new "magicProcedureDefinitions" method to ScratchObj * Returns the procedure definitions for library blocks * Includes only procedure definitions whose definitions start with MAGIC_PROC_PREFIX * Edited procedureDefinitions method to not include library block procedure defintions * Made variables that start with the text '$$broadcast' hidden in the block palette * To be continued further * Added new addJSONScripts to ScratchObj * Adds scripts from script entries, following the format found in project.json files * [x, y, stack] * Used by instantiateFromJSON and PaletteBuilder's addScrapLibrary
This commit finishes the broadcast variables UI/blocks part of broadcast variables. (Well, I guess that's all of it, since this mod doesn't change anything in the runtime..) ----- * Added new broadcastVar menu * Gets all the broadcast variables of a specific broadcast message * Message gotten from block's first input * Has 'new variable' option * Opens a broadcast variable maker dialog, similar to the variable maker dialog * Used in 'set broadcast var' block, part of Scrap library * Updated 'set broadcast var' library block * Block spec now uses broadcast-specific menus instead of text inputs * Added new collectBroadcastVarNames method to ScratchStage * Gets global/stage variables that have a name following format BROADCAST_VAR_PREFIX + msg + '>' + (some name) * Used in broadcastVar menu * Should be used in PaletteBuilder (TODO) * Fixed duplicate variable 'b:Block' warning * Added missing semicolon
When you open a sprite, the palette was updated *before* its scripts were viewed, making the palette still think another script was viewed. This fixes the issue by updating the palette *after* the scripts are viewed in the script pane, rather than before.
This simplifies PaletteBuilder's broadcast variable code quite significantly, removing redundant code. It also updates collectBroadcastVarName's return format, and changes the code in the broadcast variable menu accordingly.
This is just so that a new broadcast variable will appear in the data palette as soon as you make it.
ah, if the world breaks, um, |
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.
I can't remember the status of this but I think it's mostly finished. Scrap is essentially abandoned/finished anyways; may as well merge in one of the main features that makes it worth using.