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:
(parameter [save] :: control)
<parameter [save] given? :: control>
set [save] to [ABC123] :: 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.

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.
mybearworld
Scratcher
1000+ posts

Parameters for Scratch Projects

k0d3rrr wrote:

(#2)
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.
It could just do nothing too. The user has to code in parameter support themselves
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

musicROCKS013 wrote:

(#4)
So this is similar to the old user ID block but it stores unrelated numbers now, such as a save code?
Not really, that data is stored in URLs
musicROCKS013
Scratcher
1000+ posts

Parameters for Scratch Projects

mybearworld wrote:

Not really, that data is stored in URLs
Ohhhhh like they can add a save code to the end of the link? Genuis.
mybearworld
Scratcher
1000+ posts

Parameters for Scratch Projects

musicROCKS013 wrote:

(#6)

mybearworld wrote:

Not really, that data is stored in URLs
Ohhhhh like they can add a save code to the end of the link? Genuis.
Yes, exactly!
musicROCKS013
Scratcher
1000+ posts

Parameters for Scratch Projects

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.

Last edited by musicROCKS013 (Aug. 18, 2022 15:16:21)

ScolderCreations
Scratcher
1000+ posts

Parameters for Scratch Projects

musicROCKS013 wrote:

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.
I think that’s a great idea! It’s definitely possible too.
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

musicROCKS013 wrote:

(#8)
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.
Good idea! Added to the OP
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

musicROCKS013 wrote:

(#12)
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?
Yes, like https://scratch.mit.edu/projects/XYZ?save=ABC&appearence=dark, for example
mybearworld
Scratcher
1000+ posts

Parameters for Scratch Projects

tttttt
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

PGBFLITE6373 wrote:

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"
(link with parameters :: sensing) // returns "https://scratch.mit.edu/54323456/?foo=bar"
Also, wouldn't these better fit in sensing?
musicROCKS013
Scratcher
1000+ posts

Parameters for Scratch Projects

Bump
mybearworld
Scratcher
1000+ posts

Parameters for Scratch Projects

PkmnQ wrote:

(#16)

PGBFLITE6373 wrote:

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"
(link with parameters :: sensing) // returns "https://scratch.mit.edu/54323456/?foo=bar"
Also, wouldn't these better fit in sensing?
What would these be used for though?
musicROCKS013
Scratcher
1000+ posts

Parameters for Scratch Projects

PkmnQ wrote:

(link with parameters :: sensing) // returns "https://scratch.mit.edu/54323456/?foo=bar"
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?
musicROCKS013
Scratcher
1000+ posts

Parameters for Scratch Projects

Bump

Powered by DjangoBB