Discuss Scratch

shlop
Scratcher
4 posts

Boolean block creation

I know you can create blocks in scratch using the ‘more blocks’ category, but I can only see ways to create action blocks - is there a way to create, for example, custom <Boolean> blocks?

The particular block that I want to make includes being able to define the <key pressed?> block with a (variable), or with a (list), so that it would only be true when any/all (using a drop-down menu) of the keys were pressed.

Then I was wondering if it would be possible to combine more than one of them to make one boolean block, that would look something like this:

any/allkey/spressedandnotany/allkey/spressed?

This would give a true/false report. If any of the inputs were not registered keys it could simply report false.

Can this be done within the ‘more blocks’ category or does it need to be done in the blockspec editor?

Thanks in advance
ParkerS98
Scratcher
46 posts

Boolean block creation

I'm not familiar with the blockspec editor, but I can tell you that can't make boolean blocks in the “More Blocks” editor. I would probably just create this base block and put it in the backpack.
Photoguy77_test
New Scratcher
13 posts

Boolean block creation

This is not achievable without some serious hacking. If you want to continue you might want to ask Hardmath123.
shlop
Scratcher
4 posts

Boolean block creation

ah, okay… I might do that. I think an included interface for squeak and blockspec editing, tucked away but easy to use would be a valuable feature to add to scratch.

ParkerS98 wrote:

I would probably just create this base block and put it in the backpack.
What did you mean by this?
shlop
Scratcher
4 posts

Boolean block creation

Also, does anybody know of a way to report the sprite (that the script is in)'s name within a project?

Last edited by shlop (Oct. 24, 2013 14:28:15)

lederniersamourai
Scratcher
500+ posts

Boolean block creation

Just create a local variable and initalize it with the sprite name with copy/paste.
Be careful when modifying sprite names.
But you can write a code that will check that all vars are well intitialized:
Send a message so that all sprite puts their recorded name in a global list.
Then iterate on the list for testing with the sensing block that the local var content corresponds to the name of the sprite put in the list.

See http://scratch.mit.edu/projects/13577663/

Yes, … this is a pity that you have to do that “by hand” and here is no reporter …
lafoudre
Scratcher
100+ posts

Boolean block creation

lederniersamourai wrote:

Just create a local variable and initalize it with the sprite name with copy/paste.
Be careful when modifying sprite names.
But you can write a code that will check that all vars are well intitialized:
Send a message so that all sprite puts their recorded name in a global list.
Then iterate on the list for testing with the sensing block that the local var content corresponds to the name of the sprite put in the list.

See http://scratch.mit.edu/projects/13577663/

Yes, … this is a pity that you have to do that “by hand” and here is no reporter …

Then, you can also use that for showing the list of sprite that are currently running code by inserting/deleting their names in the list when they start/stop running code.

Do you need that for debugging your code ?
SuperCrazy246
Scratcher
13 posts

Boolean block creation

Hey, for block/reporter/boolean/c-loop creation, you can take a look at BYOB (or Snap!)
shlop
Scratcher
4 posts

Boolean block creation

Ahhh yes, BYOB does have it Although you can't upload BYOB to the scratch website though…

Powered by DjangoBB