Discuss Scratch

mybearworld
Scratcher
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:
(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> then
switch backdrop to (query::sensing)
end
you would be able to write links like https://scratch.mit.edu/projects/485870527/?q=Advertising and it would automatically go to that page.
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)

SmartCat3
Scratcher
500+ posts

"Query" blocks

SUpport, it would be easier to make dictionaries
Yellowsheep43
Scratcher
1000+ posts

"Query" blocks

This would be way too complicated for new scratchers
ShyGamer16
Scratcher
500+ posts

"Query" blocks

Yellowsheep43 wrote:

This would be way too complicated for new scratchers
So? Maybe you should check this out then…
SmartCat3
Scratcher
500+ posts

"Query" blocks

Yellowsheep43 wrote:

This would be way too complicated for new scratchers
It would be complicated to a 4 year old
Maximouse
Scratcher
1000+ posts

"Query" blocks

Yellowsheep43 wrote:

This would be way too complicated for new scratchers
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.
SmartCat3
Scratcher
500+ posts

"Query" blocks

I have a slightly different suggestion( I think this is different from what you are suggesting)
get query [scratch.mit.edu/projects/104/?q=Weekend] :: sensing
The rest would be the same.
If the query/project was incorrect, it would do this:
think [error!] for (2) secs
THe rest would be the same
_nix
Scratcher
1000+ posts

"Query" blocks

Maximouse wrote:

Yellowsheep43 wrote:

This would be way too complicated for new scratchers
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.
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:
class Scratch3QueryBlocks {
    ...
    getQuery() {
        return this.location.search;
    }
    hasQuery() {
        return this.location.search.length > 0;
    }
}
(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. )

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
Scratcher
500+ posts

"Query" blocks

_nix wrote:

(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;
    }
}
Fixed.

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

"Query" blocks

JackK211424 wrote:

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

"Query" blocks

JackK211424 wrote:

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.
I think you can workaround it using something like this:
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)

SmartCat3
Scratcher
500+ posts

"Query" blocks

Bump
ScolderCreations
Scratcher
1000+ posts

"Query" blocks

How would this work off-line, or in an embed?
mybearworld
Scratcher
1000+ posts

"Query" blocks

ScolderCreations wrote:

How would this work off-line
<query exists?::sensing> // is always false
(query::sensing)// is always blank

ScolderCreations wrote:

or in an embed?
https://scratch.mit.edu/projects/xyz/embed?q=abc
JackK211424
Scratcher
500+ posts

"Query" blocks

ScolderCreations wrote:

How would this work off-line, or in an embed?
An embed would just use the embeds query and off-line it wouldn't work like the username block.

Edit: Ninja'd by 14 seconds.

Last edited by JackK211424 (Oct. 8, 2021 18:39:34)

ScolderCreations
Scratcher
1000+ posts

"Query" blocks

Here's another question: what about websites that can run scratch projects, but have their own url parameters?
mybearworld
Scratcher
1000+ posts

"Query" blocks

ScolderCreations wrote:

Here's another question: what about websites that can run scratch projects, but have their own url parameters?
Again, in the embed link, the query should be included. It has nothing to do with the website's link.
Maximouse
Scratcher
1000+ posts

"Query" blocks

ScolderCreations wrote:

Here's another question: what about websites that can run scratch projects, but have their own url parameters?
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.
ScolderCreations
Scratcher
1000+ posts

"Query" blocks

mybearworld wrote:

ScolderCreations wrote:

Here's another question: what about websites that can run scratch projects, but have their own url parameters?
Again, in the embed link, the query should be included. It has nothing to do with the website's link.
I don't think you understood me. I'm not talking about embeds, I'm talking about scratch modifications, such as turbowarp.
mybearworld
Scratcher
1000+ posts

"Query" blocks

ScolderCreations wrote:

I don't think you understood me. I'm not talking about embeds, I'm talking about scratch modifications, such as turbowarp.
The code is not very complicated, modders could just change the query name manually.

Powered by DjangoBB