Discuss Scratch
- mybearworld
-
Scratcher
1000+ posts
Parameters for Scratch Projects
URLs can have certain parameters. For example, you can add ?q=Query to a lot of search engines, and they will open with that query typed in already. This allows to linking a certain page, like "Go to https://startpage.com/search?q=tomato to find out interesting things about tomatoes“ instead of ”Go to https://startpage.com/ and type in tomato to find out interesting things about tomatoes“.
That would work for Scratch too. Say project XYZ has a save code system. Instead of saing ”Go to https://scratch.mit.edu/projects/XYZ/, go to the save code input and type in ABC123“, you could just say ”Go to https://scratch.mit.edu/projects/XYZ?save=ABC123", and the project could look at those parameters and start the project in a certain way.
These blocks would have to be added:
URLs are limited to 8,192 characters, so this would be the limit for parameters.
That would work for Scratch too. Say project XYZ has a save code system. Instead of saing ”Go to https://scratch.mit.edu/projects/XYZ/, go to the save code input and type in ABC123“, you could just say ”Go to https://scratch.mit.edu/projects/XYZ?save=ABC123", and the project could look at those parameters and start the project in a certain way.
These blocks would have to be added:
(parameter [save] :: control)If a parameter is not given, the reporter would simply report the empty string - the boolean is to be able to distinguish https://scratch.mit.edu/projects/XYZ/?param from just https://scratch.mit.edu/projects/XYZ/. The stack block is so you can simply copy the link from the adress bar.
<parameter [save] given? :: control>
set [save] to [ABC123] :: control
URLs are limited to 8,192 characters, so this would be the limit for parameters.
Last edited by mybearworld (June 1, 2023 10:24:42)
- k0d3rrr
-
Scratcher
1000+ posts
Parameters for Scratch Projects
So, would this basically load the save code (or whatever) into the project, or would it just automatically load the data into whatever variable it wanted?
If it was the latter, I wouldn't want this because if it set a random variable to a save code (or whatever) without any “context” in the link, it could break the project. I'm not thinking properly.
If it was the latter, I wouldn't want this because if it set a random variable to a save code (or whatever) without any “context” in the link, it could break the project. I'm not thinking properly.
- mybearworld
-
Scratcher
1000+ posts
Parameters for Scratch Projects
(#2)It could just do nothing too. The user has to code in parameter support themselves
So, would this basically load the save code (or whatever) into the project, or would it just automatically load the data into whatever variable it wanted?
If it was the latter, I wouldn't want this because if it set a random variable to a save code (or whatever) without any “context” in the link, it could break the project. I'm not thinking properly.
- musicROCKS013
-
Scratcher
1000+ posts
Parameters for Scratch Projects
So this is similar to the old user ID block but it stores unrelated numbers now, such as a save code?
- mybearworld
-
Scratcher
1000+ posts
Parameters for Scratch Projects
(#4)Not really, that data is stored in URLs
So this is similar to the old user ID block but it stores unrelated numbers now, such as a save code?
- musicROCKS013
-
Scratcher
1000+ posts
Parameters for Scratch Projects
Not really, that data is stored in URLsOhhhhh like they can add a save code to the end of the link? Genuis.
- mybearworld
-
Scratcher
1000+ posts
Parameters for Scratch Projects
(#6)Yes, exactly!Not really, that data is stored in URLsOhhhhh like they can add a save code to the end of the link? Genuis.
- musicROCKS013
-
Scratcher
1000+ posts
Parameters for Scratch Projects
Could there maybe be this block as well?
This would allow you to simply have to copy the link, instead of type it out yourself, and could make this feature a lot easier for users of the project, especially if the parameter needs to save a lot of data.
set parameter to [] :: control
This would allow you to simply have to copy the link, instead of type it out yourself, and could make this feature a lot easier for users of the project, especially if the parameter needs to save a lot of data.
Last edited by musicROCKS013 (Aug. 18, 2022 15:16:21)
- ScolderCreations
-
Scratcher
1000+ posts
Parameters for Scratch Projects
Could there maybe be this block as well?I think that’s a great idea! It’s definitely possible too.set parameter to [] :: control
This would allow you to simply have to copy the link, instead of type it out yourself, and could make this feature a lot easier for users of the project, especially if the parameter needs to save a lot of data.
I know it’s possible since clicking on a post timestamp on the forums will add a URL parameter.
Last edited by ScolderCreations (Aug. 18, 2022 20:10:06)
- SonicFanX123_321
-
Scratcher
1000+ posts
Parameters for Scratch Projects
i'd actually find that kinda useful sometimes. support
- mybearworld
-
Scratcher
1000+ posts
Parameters for Scratch Projects
(#8)Good idea! Added to the OP
Could there maybe be this block as well?set parameter to [] :: control
This would allow you to simply have to copy the link, instead of type it out yourself, and could make this feature a lot easier for users of the project, especially if the parameter needs to save a lot of data.
- musicROCKS013
-
Scratcher
1000+ posts
Parameters for Scratch Projects
Looking at the mock-up blocks I just wondered something. Can you have multiple parameters, and that is why you can name them for the drop down?
Last edited by musicROCKS013 (Aug. 21, 2022 15:22:50)
- mybearworld
-
Scratcher
1000+ posts
Parameters for Scratch Projects
(#12)Yes, like https://scratch.mit.edu/projects/XYZ?save=ABC&appearence=dark, for example
Looking at the mock-up blocks I just wondered something. Can you have multiple parameters, and that is why you can name them for the drop down?
- PGBFLITE6373
-
Scratcher
1000+ posts
Parameters for Scratch Projects
Well, I think this suggestion idea is genius. I mean, it could easily be used to save data and other things. I mean, it couldn't that hard to code in instead of save codes in-game. I just have one question. How would the user get the parameter? I mean, from the block choice I don't see a way it could show the parameter unless I'm wrong, and I don't think the link could update.
- PkmnQ
-
Scratcher
1000+ posts
Parameters for Scratch Projects
Well, I think this suggestion idea is genius. I mean, it could easily be used to save data and other things. I mean, it couldn't that hard to code in instead of save codes in-game. I just have one question. How would the user get the parameter? I mean, from the block choice I don't see a way it could show the parameter unless I'm wrong, and I don't think the link could update.I think I've seen the link update, but I also think one of these would also help:
(parameters :: sensing) // returns "?foo=bar"Also, wouldn't these better fit in sensing?
(link with parameters :: sensing) // returns "https://scratch.mit.edu/54323456/?foo=bar"
- mybearworld
-
Scratcher
1000+ posts
Parameters for Scratch Projects
(#16)What would these be used for though?Well, I think this suggestion idea is genius. I mean, it could easily be used to save data and other things. I mean, it couldn't that hard to code in instead of save codes in-game. I just have one question. How would the user get the parameter? I mean, from the block choice I don't see a way it could show the parameter unless I'm wrong, and I don't think the link could update.I think I've seen the link update, but I also think one of these would also help:(parameters :: sensing) // returns "?foo=bar"Also, wouldn't these better fit in sensing?
(link with parameters :: sensing) // returns "https://scratch.mit.edu/54323456/?foo=bar"
- musicROCKS013
-
Scratcher
1000+ posts
Parameters for Scratch Projects
But you could use this block to detect if a project is a remix or not, which isn't good. People will likely make the project crash if the link isn't the original, so that isn't good. Plus, what other implementation would there be?(link with parameters :: sensing) // returns "https://scratch.mit.edu/54323456/?foo=bar"