-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Allow GUI, Blocks, and VM to be modified by userscripts #122
Comments
Isn't this what extensions are for? |
Extensions (as far as I know) are blocks added by an API that are meant to interact with the outside world (LEGO WeDo) user scripts, would be able to change the code or make more direct modifications like changing the colors in scratch-blocks or adding a whole new category. for an example of how useful this is check out https://github.com/Airhogs777/sb3-theme and https://github.com/Airhogs777/sb3-theme/wiki/Themes-Library and load up one of the user scripts and load it up in the vertical SCRATCH-BLOCKS playground. (it is made to only run on the scratch blocks url) |
Admittedly, I don't know much about userscripts in 2.0, it depends on how extensions are implemented, and @thisandagain said they're changing things. However if you're loading js, and scratch 3.0 is built with js, you could just overwrite or add any functions you wanted -- or so I would imagine. |
There are not user scripts in 2.0, it is a 3.0 thing. Check out https://github.com/Airhogs777/sb3-theme and https://github.com/Airhogs777/sb3-theme/wiki/Themes-Library. |
I imagine that extensions would be used to add functionality to projects, whereas userscripts would be used by power-users to extend the editor itself. sb3-theme is basically abandoned at this point (since the ST was cool enough to accept code into scratch-blocks that natively does the same thing), but it wouldn't've been possible if Blockly wasn't exposed to other scripts. I can imagine similar kinds of userscripts that would benefit from access to Blockly or the VM--for example, if a user wanted to change the framerate or aspect ratio of the player (for themself), or code that allows them to create hacked blocks (maybe, to allow variables into boolean inputs if the user knows its value will be true or false). There's an ongoing 2.0 mod called Scrap that is built on the premise of making it easier to create advanced valid Scratch projects--those are the kinds of things that would be done with a userscript as opposed to an extension. |
Those were just the first couple examples that came to my mind, I'm sure there are better use-cases |
I made a small scratch mod (https://github.com/TheBrokenRail/scratch-gui/tree/scratch-extended) that runs off of src/lib/blocks.js because it has access to the VM and Blockly, access to these from the outside would allow you to use multiple mods at one (as long as they don't overwrite the same thing} it would also make it easier to install them (user scripts). Here is a way to expose them (put this in src/lib/blocks.js or src/containers/blocks.jsx) window.ScratchBlocks = ScratchBlocks;
window.vm = vm; |
Here is an example of what can be done with user scripts (does not work on scratch-gui as ScratchBlocks and VM are not exposed): (make sure to remove the .txt extension) (GitHub would not let me upload a .ZIP) |
That seems like a good use for an extension, since those blocks would stop working if the userscript wasn't installed on the user's browser. But what would be cool is if it used those blocks and then allowed you to convert them to scratch-compatible equivalents |
This is just a simple example but another thing you could do would be adding a stretch ability to the sprite or making blocks that need to directly modify the code, or even making a userscript just to change block colors or disable a few blocks. |
Or just basically being able to mostly modify the code without needing to rely on an API. |
Or you could use this to directly modify the functions or looks of other blocks. |
And for your comment about the blocks stop working, same would be for an extension if it is not installed, in the future though when scratchfoundation/scratch-blocks#756 is fixed the blocks will keep there inputs and not be deleted but still not work. As well, when I look at how extensions are currently handled they require you to use stuff like ScratchX to use custom ones. |
A way this could be exposed could be like the VM does it now with a window.Scratch object like this: window.Scratch = {
vm: vm,
ScratchBlocks: ScratchBlocks
} |
Expected Behavior
User scripts should be able to modify them.
Actual Behavior
They can not.
Why
Allowing them to be modified by user scripts would make mudding way easier, making it possible to theme scratch-blocks, allow you to stack modifications so you don't need to manually combine them into one repo, no forking required to mod, etc.
The text was updated successfully, but these errors were encountered: