Discuss Scratch

Dom_206
Scratcher
50 posts

new block

create [clone v] variable()

this would be used for clones, sprites, and backdrops to make variables as the project runs. this would be in the control section. iff two variables are made with the same name, they will be treated as the same variable. that space you see will contain the name of the variable. a good way to do it would be

create [clone v] variable(join [var] (var_number)

Last edited by Dom_206 (Oct. 23, 2025 15:06:11)

jmb1293634
Scratcher
1000+ posts

new block

why not just in variables? whats to prevent someone from doing something like this:
when green flag clicked
set [i v] to [0]
forever
change [i v] by (1)
create [clone v] variable (join [var] (i))::variables
end
and crashing scratch
also what would the drop-down do would it create the variable for the specified sprite/clone/backdrop in which case why not just make it so that it creates it for whatever creates the variable I think it would be better if it was something like this:
create [for this sprite only v] variable named: []::variables

Last edited by jmb1293634 (Oct. 23, 2025 15:49:36)

Dom_206
Scratcher
50 posts

new block

jmb1293634 wrote:

why not just in variables? wahts to prevent someone from doing something like this:
when green flag clicked
set [i v] to [0]
forever
change [i v] by (1)
create [clone v] variable (join [var] (i))::variables
end
and crashing scratch
also what would the drop-down do would it create the variable for the specified sprite/clone/backdrop in which case why not just make it so that it creates it for whatever creates the variable I think it would be better if it was something like this:
create [for this sprite only v] variable named: []::variables

the drop-down has the options: clone, sprite, backdrop. that would just make variables over and over and might crash it, but I think people could infer that and not do it.

Last edited by Dom_206 (Oct. 23, 2025 15:43:45)

Dom_206
Scratcher
50 posts

new block

its supposed to be used for mostly clones. when a clone starts it make its own variable. prob more uses tho
d016
Scratcher
100+ posts

new block

So… a

create a [sprite v] variable named [this is my variable] :: variables

would make a

(this is my variable)

that is only accessible for the sprite that ran the create variable block?
Dom_206
Scratcher
50 posts

new block

d016 wrote:

So… a

create a [sprite v] variable named [this is my variable] :: variables

would make a

(this is my variable)

that is only accessible for the sprite that ran the create variable block?
no, variables created by this block are for all sprites and clones and backdrops.
Dom_206
Scratcher
50 posts

new block

a

Last edited by Dom_206 (Oct. 23, 2025 17:00:53)

Imtwentytenth
Scratcher
500+ posts

new block

I don’t really see use in this variable, cause you aren’t able to select it in the drop down because it isn’t in the project yet.
Dom_206
Scratcher
50 posts

new block

Imtwentytenth wrote:

I don’t really see use in this variable, cause you aren’t able to select it in the drop down because it isn’t in the project yet.

you can interact with blocks in the pallet and this isn't in scratch yet but when it is in it you can use the dropdown. that's like saying you don't see use in a car because you cant buy it yet.
Imtwentytenth
Scratcher
500+ posts

new block

Dom_206 wrote:

Imtwentytenth wrote:

I don’t really see use in this variable, cause you aren’t able to select it in the drop down because it isn’t in the project yet.

you can interact with blocks in the pallet and this isn't in scratch yet but when it is in it you can use the dropdown. that's like saying you don't see use in a car because you cant buy it yet.
I meant that it’s not permanent, it is created automatically and Scratch probably wouldn’t be able to make them in the drop down.
Dom_206
Scratcher
50 posts

new block

Imtwentytenth wrote:

Dom_206 wrote:

Imtwentytenth wrote:

I don’t really see use in this variable, cause you aren’t able to select it in the drop down because it isn’t in the project yet.

you can interact with blocks in the pallet and this isn't in scratch yet but when it is in it you can use the dropdown. that's like saying you don't see use in a car because you cant buy it yet.
I meant that it’s not permanent, it is created automatically and Scratch probably wouldn’t be able to make them in the drop down.

its not supposed to be permanent. only while the project runs. also the drop down isn't where the variables are created and nothing is ever put in drop downs.
Imtwentytenth
Scratcher
500+ posts

new block

Dom_206 wrote:

Imtwentytenth wrote:

Dom_206 wrote:

Imtwentytenth wrote:

I don’t really see use in this variable, cause you aren’t able to select it in the drop down because it isn’t in the project yet.

you can interact with blocks in the pallet and this isn't in scratch yet but when it is in it you can use the dropdown. that's like saying you don't see use in a car because you cant buy it yet.
I meant that it’s not permanent, it is created automatically and Scratch probably wouldn’t be able to make them in the drop down.

its not supposed to be permanent. only while the project runs. also the drop down isn't where the variables are created and nothing is ever put in drop downs.
You can’t change it without it being in a drop down of a “change” or “set” variable block.
tagrim123
Scratcher
500+ posts

new block

Imtwentytenth wrote:

Dom_206 wrote:

Imtwentytenth wrote:

Dom_206 wrote:

Imtwentytenth wrote:

-sni[

-snip
I meant that it’s not permanent, it is created automatically and Scratch probably wouldn’t be able to make them in the drop down.

its not supposed to be permanent. only while the project runs. also the drop down isn't where the variables are created and nothing is ever put in drop downs.
You can’t change it without it being in a drop down of a “change” or “set” variable block.
How about something like this?
make a [for this sprite only v] variable named (foo ::grey) ::control //like the my-blocks "define" block when you make variables, you can drag the "foo" part out to other places.
using (foo ::grey){
...
}::control
this might be script variables tho
but basically it adds the inserted block into the dropdown menu :3

Last edited by tagrim123 (Oct. 23, 2025 20:40:33)

Dom_206
Scratcher
50 posts

new block

Imtwentytenth wrote:

Dom_206 wrote:

Imtwentytenth wrote:

Dom_206 wrote:

Imtwentytenth wrote:

I don’t really see use in this variable, cause you aren’t able to select it in the drop down because it isn’t in the project yet.

you can interact with blocks in the pallet and this isn't in scratch yet but when it is in it you can use the dropdown. that's like saying you don't see use in a car because you cant buy it yet.
I meant that it’s not permanent, it is created automatically and Scratch probably wouldn’t be able to make them in the drop down.

its not supposed to be permanent. only while the project runs. also the drop down isn't where the variables are created and nothing is ever put in drop downs.
You can’t change it without it being in a drop down of a “change” or “set” variable block.

I think you misunderstand what Im saying
da-ultimate-creater
Scratcher
100+ posts

new block

I would support this is there was a way you could type a variable name into the
 set variable [ v] to () :: variables 
block.
Dom_206
Scratcher
50 posts

new block

da-ultimate-creater wrote:

I would support this is there was a way you could type a variable name into the
 set variable [ v] to () :: variables 
block.
you already have it; you can type in the little space. do you only use forums?

Last edited by Dom_206 (Oct. 24, 2025 12:04:03)

Alex5002
Scratcher
94 posts

new block

Workarround

Create two lists : Variable name and Variable value.

Then define this :
define set variable (variable name) to (variable value)
if <not<[Variable name v] contains (variable name) ?>> then
add (variable name) to [Variable name v]
add (variable value) to [Variable value v]
else
replace item (item # of (variable name) in [Variable name v]) of [Variable value v] with (variable value)
end

Now you can set a variable with :
set variable [] to [] :: custom

And to read a value (can be shorten if custom reporters are made available to official Scratch) :
(item (item # of [] in [Variable name v]) of [Variable value v] :: list)

Last edited by Alex5002 (Oct. 24, 2025 12:23:44)

Imtwentytenth
Scratcher
500+ posts

new block

Dom_206 wrote:

da-ultimate-creater wrote:

I would support this is there was a way you could type a variable name into the
 set variable [ v] to () :: variables 
block.
you already have it; you can type in the little space. do you only use forums?
It's meant to give the variable a value (insert skull)
Dom_206
Scratcher
50 posts

new block

Imtwentytenth wrote:

Dom_206 wrote:

da-ultimate-creater wrote:

I would support this is there was a way you could type a variable name into the
 set variable [ v] to () :: variables 
block.
you already have it; you can type in the little space. do you only use forums?
It's meant to give the variable a value (insert skull)

no that's where the name goes
Imtwentytenth
Scratcher
500+ posts

new block

Dom_206 wrote:

Imtwentytenth wrote:

Dom_206 wrote:

da-ultimate-creater wrote:

I would support this is there was a way you could type a variable name into the
 set variable [ v] to () :: variables 
block.
you already have it; you can type in the little space. do you only use forums?
It's meant to give the variable a value (insert skull)

no that's where the name goes
What space do you mean? The
[ v] ::variables
or
[] ::variables

Powered by DjangoBB