Discuss Scratch

Dom_206
Scratcher
50 posts

new block

Alex5002 wrote:

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)

this is not intuitive and easy to understand. the whole point of this block is to make it easy to make variables. new users may not understand how this workaround actually works so we need a block for it. if they don't understand it they cant utilize it.

edit: oh you were just providing a workaround since the block doesn't exist yet. my bad.

Last edited by Dom_206 (Oct. 24, 2025 13:38:13)

Powered by DjangoBB