Discuss Scratch

Splashmasters
Scratcher
15 posts

Boolean variables.

Variables are used for a lot of stuff. Especially numbers. But wouldn't it be fun to have an standard boolean? So for example: An variable with the name “Is Cat” would normally say “0”, but that doesn't make any sense because it is a yes or no question, not a numberic question. So add an checkbox named “Boolean” and a description saying “Instead of numbers, uses true or false.” This, when paired with on cloud, should be used as extra or less score on the leaderboard, thus should have an other variable attached to it with cloud enabled too and an number adding or subtracting the score. That way, code can be shortened and new players have ease with variables.

Edit: Yes, I know that you could already do so, but… it's just shortening code and makes it default “false”

Here is an example for code before:
exampleisequalto50,foryourknowledgesetbooleantotrueifbooleanistruethenincreaseexampleby100Justsayingsomethingforthevalues.scratchblocksThevalueofexamplewouldbe150NowherethesameoutputbutthenwithmysuggestionBooleanhasbeenlinkedwithexampleandhasbeenselectedwith100.Exampleisstill50.Alsoforsomeungodlyreasonitwon'tchangetonormaltextandshowsablocksaying"scratchblock"itshouldbehidden...scratchblockstogglebooleanORwecoulddoflipbooleantotrueForyourknowlege,forsomeungodlyreason,itwon'tchangetoadropdownwhateverIdo.scratchblocksAndtheresultisthatexampleisequalto150,shorteningthecodetoONEblock.Sooverallthisistoshortencode.

Last edited by Splashmasters (June 16, 2024 14:52:55)

hydrofungus
Scratcher
1000+ posts

Boolean variables.

Doesn’t the operator blocks already do this? (The <, > and = ones)
You can do like, for example 0 is false and 1 is true
whenclickedsetvariableto0iftouchingsmth?thensetvariableto1
whenclickedifvariable=1thensayhello world!for2secs

Last edited by hydrofungus (June 15, 2024 09:53:07)

jmdzti_0-0
Scratcher
500+ posts

Boolean variables.

No support.

This has an easy workaround:
foo=true
julmik6478
Scratcher
500+ posts

Boolean variables.

Support, beacuse it can expand my custom blocks pack named backblocks. Also I know workaround:
setfootobooleanfoo=true
hydrofungus
Scratcher
1000+ posts

Boolean variables.

julmik6478 wrote:

Support, beacuse it can expand my custom blocks pack named backblocks. Also I know workaround:
setfootobooleanfoo=true
That workaround doesn’t exist?
medians
Scratcher
1000+ posts

Boolean variables.

hydrofungus wrote:

julmik6478 wrote:

Support, beacuse it can expand my custom blocks pack named backblocks. Also I know workaround:
setfootobooleanfoo=true
That workaround doesn’t exist?
But it does?
Anyways, already suggested:
https://scratch.mit.edu/discuss/post/59944/
Foldy_TPOT
Scratcher
100+ posts

Boolean variables.

No support.
ifconditionthensetboolean variabletotrueelsesetboolean variabletofalse
julmik6478
Scratcher
500+ posts

Boolean variables.

Duplicate of https://scratch.mit.edu/discuss/topic/8618/

hydrofungus wrote:

Doesn’t the operator blocks already do this? (The <, > and = ones)
You can do like, for example 0 is false and 1 is true
whenclickedsetvariableto0iftouchingsmth?thensetvariableto1
whenclickedifvariable=1thensayhello world!for2secs
Easier version:
setvariabletotouchingsmth?

Last edited by julmik6478 (June 16, 2024 07:55:34)

Splashmasters
Scratcher
15 posts

Boolean variables.

Yes, I already know you just can do this:
set ExampletoTrue
But it is at default just 0.
If it would be at default like this:
Example=false
Then it would save some space (i think) and this could shorten code, especially for other variables
spectre_specs
Scratch Team
1000+ posts

Boolean variables.

Closed as duplicate.

Powered by DjangoBB