Discuss Scratch
- mybearworld
-
1000+ posts
"Query" blocks
By doing https://scratch.mit.edu/projects/1581299/?q=hello_world, you should be able to change the value of a block:
Let's take a look at an example where this could be used.
For example, you have a dictionary, like https://scratch.mit.edu/projects/485870527/ is.
By putting
This would also be useful for animations (linking to a certain part).
There is one issue though. People may want to put “100% Pen” in a query. However, ?q=100% Pen doesn't work - you'd have to put ?q=100%25 Pen.
To solve that, the “Copy Link” dialog should get a new option.

They would not be called Sections, but Quueries, I forgot to rename them.
The creator would be able to set up all the queries listed on that menu. Those also wouldn't be the only ones possible.
(query::sensing)//This would be changed from nothing to hello_world
<query exists?::sensing>//This would turn true.
Let's take a look at an example where this could be used.
For example, you have a dictionary, like https://scratch.mit.edu/projects/485870527/ is.
By putting
if <query exists?::sensing> thenyou would be able to write links like https://scratch.mit.edu/projects/485870527/?q=Advertising and it would automatically go to that page.
switch backdrop to (query::sensing)
end
This would also be useful for animations (linking to a certain part).
There is one issue though. People may want to put “100% Pen” in a query. However, ?q=100% Pen doesn't work - you'd have to put ?q=100%25 Pen.
To solve that, the “Copy Link” dialog should get a new option.

They would not be called Sections, but Quueries, I forgot to rename them.
The creator would be able to set up all the queries listed on that menu. Those also wouldn't be the only ones possible.
Last edited by mybearworld (Jan. 18, 2023 13:38:41)
- Yellowsheep43
-
1000+ posts
"Query" blocks
This would be way too complicated for new scratchers
- ShyGamer16
-
500+ posts
"Query" blocks
So? Maybe you should check This would be way too complicated for new scratchersthis out then…
- SmartCat3
-
500+ posts
"Query" blocks
It would be complicated to a 4 year old This would be way too complicated for new scratchers
- Maximouse
-
1000+ posts
"Query" blocks
New Scratches would probably just ignore the blocks, but this seems like a feature that would be difficult to implement in a way that isn't complicated. This would be way too complicated for new scratchers
- SmartCat3
-
500+ posts
"Query" blocks
I have a slightly different suggestion( I think this is different from what you are suggesting)
If the query/project was incorrect, it would do this:
get query [scratch.mit.edu/projects/104/?q=Weekend] :: sensingThe rest would be the same.
If the query/project was incorrect, it would do this:
think [error!] for (2) secsTHe rest would be the same
- _nix
-
1000+ posts
"Query" blocks
It'd actually be pretty easy to code an extension which does this! The query is stored inside the JavaScript “location” object, so the code would just look something like this:New Scratches would probably just ignore the blocks, but this seems like a feature that would be difficult to implement in a way that isn't complicated. This would be way too complicated for new scratchers
class Scratch3QueryBlocks { ... getQuery() { return this.location.search; } hasQuery() { return this.location.search.length > 0; } }

I think this would be a neat feature as an extension, maybe with other browser-related blocks! (Those could probably come from other similar suggestions.)
- JackK211424
-
500+ posts
"Query" blocks
(Actually .search includes the whole thing, e.g. “?q=123” instead of just “123”, so you'd have to do a little bit of string processing, but you get the idea.)
class Scratch3QueryBlocks { ... getQuery() { return this.location.search.substring(3); } hasQuery() { return this.location.search.length > 0; } }
Aaaaanyways this is a genuinely good idea!
One thing I may suggest would be the ability to set the query, so, going back to the dictionary, if you select a word it will set the query so you dont have to manually.
Last edited by JackK211424 (Oct. 6, 2021 20:42:45)
- mybearworld
-
1000+ posts
"Query" blocks
One thing I may suggest would be the ability to set the query, so, going back to the dictionary, if you select a word it will set the query so you dont have to manually.That would be difficult to implement. You can't just change URLs midway.
- PkmnQ
-
1000+ posts
"Query" blocks
I think you can workaround it using something like this: One thing I may suggest would be the ability to set the query, so, going back to the dictionary, if you select a word it will set the query so you dont have to manually.
when green flag clicked
if <<query exists? :: sensing> and <(query set?) = [0]>> then
set [query v] to (query :: sensing)
set [query set? v] to [1]
end
Last edited by PkmnQ (Oct. 7, 2021 08:25:26)
- mybearworld
-
1000+ posts
"Query" blocks
How would this work off-line
<query exists?::sensing> // is always false
(query::sensing)// is always blank
or in an embed? https://scratch.mit.edu/projects/xyz/embed?q=abc
- JackK211424
-
500+ posts
"Query" blocks
An embed would just use the embeds query and off-line it wouldn't work like the username block. How would this work off-line, or in an embed?
Edit: Ninja'd by 14 seconds.
Last edited by JackK211424 (Oct. 8, 2021 18:39:34)
- ScolderCreations
-
1000+ posts
"Query" blocks
Here's another question: what about websites that can run scratch projects, but have their own url parameters?
- mybearworld
-
1000+ posts
"Query" blocks
Again, in the embed link, the query should be included. It has nothing to do with the website's link. Here's another question: what about websites that can run scratch projects, but have their own url parameters?
- Maximouse
-
1000+ posts
"Query" blocks
If you're talking about mods and alternative players: this would only read the “q” parameter – if the website already has one, it could be named differently there. Here's another question: what about websites that can run scratch projects, but have their own url parameters?
- ScolderCreations
-
1000+ posts
"Query" blocks
I don't think you understood me. I'm not talking about embeds, I'm talking about scratch modifications, such as turbowarp.Again, in the embed link, the query should be included. It has nothing to do with the website's link. Here's another question: what about websites that can run scratch projects, but have their own url parameters?
- mybearworld
-
1000+ posts
"Query" blocks
The code is not very complicated, modders could just change the query name manually. I don't think you understood me. I'm not talking about embeds, I'm talking about scratch modifications, such as turbowarp.