Discuss Scratch
- TheLogFather
- Scratcher
1000+ posts
How the "Pick Random" Block Works
The value is turned into an integer in the json when you save it (e.g. numerical 1.0 in the slot ends up written just as numerical 1 in the json).before you save the project, and get transformed into “pick random 0 to 1” on reloading, so it then only gives either zero or one…Obfuscated remix detection, anyone? However, there's a glitch in the way values are saved which means that entries like “1.0” and “0.0” (i.e. something which is written as a real value, but is equal to an integer) end being turned into integer values when the project is next loaded. (So “0.0” becomes “0” and “1.0” becomes “1”). This means “pick random 0.0 to 1.0” will give real values
You can get around that by editing the json to make the integer values into strings (e.g. “1.0” rather than numerical 1). That retains the strings in the script when you reload it.
However, it also seems to then re-save it as strings, even when remixed…
It is interesting, though, 'cos it means that the difference between a numerical value and a string is maintained, quietly and invisibly, across loads/saves/remixing/copying…
Siggy the Kumquat slayer:
Main account: DadOfMrLog –– Frameworks for basic pen-rendered 3D in scratch (see studio). Examples:
- - - - 3D Text - - - - - - Simple shapes - - - Controllable structures - - - On the ground - - - - - - In space - - - -
- - - - 3D Text - - - - - - Simple shapes - - - Controllable structures - - - On the ground - - - - - - In space - - - -