Discuss Scratch

BFDISuperFan
Scratcher
100+ posts

join () () can be used to identify the variable or list name in data blocks

The join operator block should be able to be put in the variable selector of a data block so I can specify what variable I want to modify. This can be helpful when using a self-made Block.

For example, If I have a long stack of blocks meant to add text to two lists, instead of using the regular add item to list block and manually changing which list it gets added to by the drop down menu, I can do this:
(Player 1 :: list)
(Player 2 :: list)
add ["3948"] to Player [1]
add ["109"] to Player [2]
add ["2983"] to Player [1]
add ["1092"] to Player [2]

define add (block of text) to Player (Player #)
add (block of text) to (join [Player ] (Player #)

It's quicker to change a bit of text than swapping variable blocks, so it should help when you are duplicating a bunch of blocks that add an item to a list and then changing which list it should go in.

Last edited by BFDISuperFan (Jan. 25, 2019 01:26:18)


Oh hi signature reader! Thanks for reading this post. I’m BFDISuperFan, and I really love rhythm games. Oh, and while you’re here reading this, if you also like rhythm games, how about you go try out my attempt at porting DDRMAX2 on Scratch?
I'm also attempting to recreate beatmania IIDX 15: DJ TROOPERS on Scratch, but right now it's just a glorified animation gallery, check it out if you're interested!
What? An evil kumquat? Eating signatures!? Haha, you come up with some funny things-
Hey, where did my closing signature go?
PhantomForcesX
Scratcher
100+ posts

join () () can be used to identify the variable or list name in data blocks

bump, and support. Provides a method of shortening recursive code across different lists as well.

(ARC) Phantom
Seven. One for the friends along the way, one for the adventures we've had, one for the struggles we overcame, one for those that have passed on, one for those who have chosen to stay, and one for those we've left behind.
The last, my own.
AlexeyChub
Scratcher
100+ posts

join () () can be used to identify the variable or list name in data blocks

Support. This can save hundreds of blocks in some projects.
--Explosion--
Scratcher
1000+ posts

join () () can be used to identify the variable or list name in data blocks

Total support! This used to be a hack in 2.0, but it broke with the release of 3.0, this would be very usefull!

Last edited by kaj (Tomorrow 00:00:00)
✰✩✭✴★--Explosion--★✴✭✩✰
Forum helper | boy | platformers | 14yrs | guitar | website


AlexeyChub
Scratcher
100+ posts

join () () can be used to identify the variable or list name in data blocks

Bump.
AlexeyChub
Scratcher
100+ posts

join () () can be used to identify the variable or list name in data blocks

This isn't getting the attention it deserves!
BFDISuperFan
Scratcher
100+ posts

join () () can be used to identify the variable or list name in data blocks

AlexeyChub wrote:

This isn't getting the attention it deserves!
Likely because it was made a whole year ago, but now it's getting put on the front page again with bumps from the likes of you. Thanks for that!

Oh hi signature reader! Thanks for reading this post. I’m BFDISuperFan, and I really love rhythm games. Oh, and while you’re here reading this, if you also like rhythm games, how about you go try out my attempt at porting DDRMAX2 on Scratch?
I'm also attempting to recreate beatmania IIDX 15: DJ TROOPERS on Scratch, but right now it's just a glorified animation gallery, check it out if you're interested!
What? An evil kumquat? Eating signatures!? Haha, you come up with some funny things-
Hey, where did my closing signature go?
AlexeyChub
Scratcher
100+ posts

join () () can be used to identify the variable or list name in data blocks

I see no real downsides to this suggestion. Good job coming up with such an idea!
hedgehog_blue
Scratcher
1000+ posts

join () () can be used to identify the variable or list name in data blocks

I support, but there is a small problem with it.

If it was only allowed the join block, it would be confusing because all the other blocks that allow a block as input allow any block to be put in (except booleans, but they have a shape, which sort of shows that you have to put in another block of that shape). It would be better to allow any block to be put in.

I can see why accepting any block might be a problem, because it might be confusing to input a list name when compared to more advanced programming languages that can handle lists inside of lists, where you would input the object of a list itself.

add [thing] to (item (1) of (list v)) //add "thing" to the list with the name of the first item of "list"

add [thing] to (item (1) of (list::list)) //add "thing" to the list stored in the first item of the list named "list"

Both of these problems don't stop me from supporting this suggestion, but if the suggestion is added, we would have to deal with one of these problems, depending on how it is implemented.

Sheep_maker
Scratcher
1000+ posts

join () () can be used to identify the variable or list name in data blocks

What would happen if the variable/list doesn't exist?

In Scratch 2.0, it automatically created a for-this-sprite-only variable defaulting to 0, but a loop could easily spam-create a ton of variables and lag the user.

Also, would there be a way to dynamically get variables? In Scratch 2.0, we used to use the _ of _ block, but not only was it a bit inconvenient to set the second dropdown to the sprite in a different sprite (the dropdown excludes the current sprite), it also didn't work for clones.

Perhaps there could be a “myself” or “this sprite” option in the second dropdown that is always listed and works for clones:
((join [] []) of [myself v])

- Sheep_maker This is a kumquat-free signature. :P
This is my signature. It appears below all my posts. Discuss it on my profile, not the forums. Here's how to make your own.
.postsignature { overflow: auto; } .scratchblocks { overflow-x: auto; overflow-y: hidden; }
PhantomForcesX
Scratcher
100+ posts

join () () can be used to identify the variable or list name in data blocks

Sheep_maker wrote:

What would happen if the variable/list doesn't exist?

In Scratch 2.0, it automatically created a for-this-sprite-only variable defaulting to 0, but a loop could easily spam-create a ton of variables and lag the user.


I think that by default, 3.0 could opt to NOT create a list every time an invalid list is selected. Also, the spam-creation of variables is kind of on the user – we have run without screen refresh that acts as an optimization but put something like a wait block in there and voila! lag. Though I do agree that this is on a whole 'nother level because of the built-in integration instead of an optional checkbox, but again, ST could make the script not create vars/lists.

(ARC) Phantom
Seven. One for the friends along the way, one for the adventures we've had, one for the struggles we overcame, one for those that have passed on, one for those who have chosen to stay, and one for those we've left behind.
The last, my own.
AlexeyChub
Scratcher
100+ posts

join () () can be used to identify the variable or list name in data blocks

Bumpity bomp
AlexeyChub
Scratcher
100+ posts

join () () can be used to identify the variable or list name in data blocks

More bomps
AlexeyChub
Scratcher
100+ posts

join () () can be used to identify the variable or list name in data blocks

Another BuMp
Jun-Dragon
Scratcher
61 posts

join () () can be used to identify the variable or list name in data blocks

bump.

make this happen. this was a hacked block in 2.0 but now i have to do so much for the same result
PhantomForcesX
Scratcher
100+ posts

join () () can be used to identify the variable or list name in data blocks

bump

(ARC) Phantom
Seven. One for the friends along the way, one for the adventures we've had, one for the struggles we overcame, one for those that have passed on, one for those who have chosen to stay, and one for those we've left behind.
The last, my own.
Zerofile
Scratcher
100+ posts

join () () can be used to identify the variable or list name in data blocks

bump yessss, although scratch doesn't seem to listen to the suggestion forums but this would be great to be re-added

thanks for the website ST
Greg8128
Scratcher
500+ posts

join () () can be used to identify the variable or list name in data blocks

This suggestion is mostly fine but there are problems, which mainly have to do with the fact that you get a variable by name:

> Renaming variables forces you to hunt down and replace every place where the variable is called by name
> Namespace conflicts: two or more different variables or lists could have the same name
> Boundaries: this approach does not let you pass a private variable by reference to a block by another sprite
> Similarity of:
set [var v] to []
set (var) to []
My fix is to pass variables not by name but by an ID which is guaranteed to be unique to the variable. If a sprite is cloned, the private variables of each clone get their own ID. The ID can be obtained with a block:
(id of [variable v])
(id of [list v])
A variable or list can be obtained with a ‘variable with ID ()’ or ‘list with ID()’ reporter. The block will work even if the ID is that of a private variable of another sprite. If the ID does not refer to any currently-existing variable or list then nothing happens.
(Variable with ID ())
(List with ID())
set (variable with ID ()) to []
add [] to (list with ID())
// and so forth

My best projects:

PolyBit
Scratcher
49 posts

join () () can be used to identify the variable or list name in data blocks

bump

define run for (num) seconds or until <bool::#de30f2>

Please check out my post about live function values
saverofthewo
Scratcher
100+ posts

join () () can be used to identify the variable or list name in data blocks

ik it's been a while, but bump and support. Even though there IS a workaround, for projects with lots of variables it could look terrible. Nobody has shown us what you actually need to do, so https://scratch.mit.edu/projects/675014756/ Eww. Look at this code! Imagine doing this with 20 or 30 variables.

I want the Scratch Team to #ConsiderCollabs! Help save Scratch's unshared projects feature before it's too late!
well its too late already but you know
oh my god look its my old signature

Hello!
I am a big fan of terraria. I love the exploring and building and boss fights!

heres the part that isnt old
uh instert kumquat joke here
uhhh uhhhhh SHOAESUDJKVNS
does
it
no it doesnt why whywhywhywhyoh my god why does this existbut does it work?oh my god it doeswoahwoahwoah

Powered by DjangoBB