This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#176 2010-04-27 18:37:51

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: BYOB 3 - Discussion Thread

New question; I'm making a custom block that I want to have the drop down list of list names. How can I do this?

Offline

 

#177 2010-04-27 18:38:55

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

Lucario621 wrote:

I don't really get what the scripts variable script does  hmm

It's an alternative to the "Make a variable" button inside the Block Editor, but (a new feature) can also be used in scripts outside the Block Editor that need temporary storage.  For example, you've probably used the Scratch REPEAT block along with a variable that counts repetitions, using a CHANGE BY block inside the REPEAT.  Well, if that variable doesn't need to be kept around forever, instead of making it a sprite variable or a global variable you can make it local to this script, so you get a new variable each time you run the script.  This avoids clutter in the project.

We're talking about getting rid of the Block Editor's "Make a variable" button, since Script Variables does the same job better, we think.  But it's true that it takes a little getting used to, and the "Make a variable" button has the advantage of being just like the Scratch one.

Cool!

Although I do think you should keep them - because very often you need to use variables in multiple scripts.


http://i.imgur.com/WBkM2QQ.png

Offline

 

#178 2010-04-27 18:49:56

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Re: BYOB 3 - Discussion Thread

shadow_7283 wrote:

New question; I'm making a custom block that I want to have the drop down list of list names. How can I do this?

Nope - you can't do drop-down lists yet.


http://i.imgur.com/WBkM2QQ.png

Offline

 

#179 2010-04-27 18:51:45

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Lucario621 wrote:

shadow_7283 wrote:

New question; I'm making a custom block that I want to have the drop down list of list names. How can I do this?

Nope - you can't do drop-down lists yet.

Darn. I also need a feature that allows you to put lists in block definitons.

Offline

 

#180 2010-04-27 19:16:03

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Re: BYOB 3 - Discussion Thread

I finished watching the project/video  smile . I really like it! Now I actually understand how those new blocks really work...


http://i.imgur.com/WBkM2QQ.png

Offline

 

#181 2010-04-27 20:34:04

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

xly wrote:

I've found an interesting workaround ! I create a "mirror" Motion Reporter function (move# 80 ) copying the same Motion Command (move 80),and then this "mirror" function can be used into a list of motion commands (For each Item of ...list (move# 80)(turn# 90)(move# 80)(turn# 90)(move# 80)(turn# 90)(move# 80)(turn# 90)...run with Inputs))

I don't understand.  FOR EACH takes commands to begin with, not reporters.  So I'm not seeing why you need to make reporters out of the motion commands.

Sorry if I'm being dense....


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#182 2010-04-27 20:36:22

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Re: BYOB 3 - Discussion Thread

I have a feature request  tongue

Although you can have a block for all sprites, or just that one sprite - how about you can also have the option to have it also only for the background, or only for sprites  smile


http://i.imgur.com/WBkM2QQ.png

Offline

 

#183 2010-04-27 20:39:20

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Also - I forget (or don't know  tongue )

What's the difference between a boolean and a predicate?


http://i.imgur.com/WBkM2QQ.png

Offline

 

#184 2010-04-27 20:44:06

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: BYOB 3 - Discussion Thread

I don't think there is a difference?


Hai.

Offline

 

#185 2010-04-27 20:51:50

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

shadow_7283 wrote:

When I try to rename a variable, I get another error. Am I doing something wrong?

Hi, Shadow.  I'm not sure how to answer this without more details.  What kind of error -- a red border around your block, or a popup dialog with a Smalltalk error?  And, does it happen when you do the rename, or are you using reporter ovals that still have the old name?  Maybe just post a screenshot?

About the disappearing speech balloons, I agree, it's really annoying, and Jens is going to fix it promptly, aren't you, Jens?  smile

About dropdowns in custom blocks, yeah, that's clearly a good idea, but really hard to specify completely.  First of all, what goes in the menu?  Fixed text? (1, any, last)
All sprites?  All accessible variables?  Some combination?  Then,  can you drop a reporter onto it?  Right now the answer is yes for red list blocks, but no for orange variable setters.  We need to spend some time really coming to understand these questions (and maybe clean up the existing special cases) and then figure out a usable user interface, before we can add custom dropdowns to BYOB.

And lurking behind that hard issue is an even harder one.  Our guiding principle: Everything should be first class!  In particular, sprites should be first class.  So a dropdown that lists the sprites shouldn't report the /name/ of the sprite (as text); it should report the actual sprite! So I think we have to clarify how first class sprites will work (imagine a MAKE SPRITE block that takes a costume -- also first class -- as input, for example) /before/ we put in sprite-related dropdowns, so that we don't encourage people to write programs assuming that the dropdown reports the sprite's name and then be stuck supporting that old code when we want to switch to reporting the actual sprite.

So, that's not a "no," but it's a "not soon."  By August?  I can't guess.


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#186 2010-04-27 20:55:39

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Lucario621 wrote:

Although I do think you should keep them - because very often you need to use variables in multiple scripts.

Hi, Lucario.

Oh, yes, there's no danger of eliminating sprite-owned variables nor global variables.  It's the "Make a variable" button /in the Block Editor/ that we're talking about eliminating, not the one in the Variables palette.

P.S. I'm really glad you liked the tutorial!  I'm starting planning #2 (higher order functions and lists).


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#187 2010-04-27 21:02:01

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

It's the "Make a variable" button /in the Block Editor/ that we're talking about eliminating, not the one in the Variables palette.

Oh - than that makes complete sense! Ok  smile

bharvey wrote:

P.S. I'm really glad you liked the tutorial!  I'm starting planning #2 (higher order functions and lists).

Yay!  smile


http://i.imgur.com/WBkM2QQ.png

Offline

 

#188 2010-04-27 21:13:17

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Lucario621 wrote:

What's the difference between a boolean and a predicate?

I'm glad you asked; this is an important question.

A Boolean (if you type that word into MS Word it'll be auto-capitalized, because they're named after George Boole, the mathematician who worked out the rules about them  smile  ) is TRUE or FALSE.  That's it; there are only two Boolean values.

A predicate is a /function/ -- a reporter, in Scratch -- that reports a Boolean answer.  So, things like = and < and > and CONTAINS and TOUCHING? are predicates.

Scratch sort of handwaves about this, because until you can make your own blocks it isn't so important.  But the distinction has been there all along.

The hexagonal input in IF (and IFELSE) takes a Boolean value, because IF just looks at it once, right at the beginning, to decide whether to run its script (or which script to run, for IFELSE).

But the hexagonal inputs in FOREVER IF, REPEAT UNTIL, and WAIT UNTIL all need predicates, not Booleans, as input, because they are going to re-evaluate the predicate many times.  A single, fixed, true/false input value would be useless to them.

Right now in BYOB you may notice that as you're dragging a predicate block toward the hexagonal input slot of a FOREVER IF, etc., the predicate gets a grey border around it for a moment just before it drops into the slot, but once it's in the slot, its appearance is only subtly different from what you're accustomed to: the block fits /into / the slot rather than resting  /on top of/ the control block the way most reporters do.  This is a compromise we made to try not to freak out the 8-year-olds.  If you drop a predicate into a Predicate-type input slot in a custom block, you'll see a grey border around it in the slot.  The grey border means the same thing it means when you put a block in a list or in a variable: this block is being used as a value in itself, not being /called/ to produce a value.

Tutorial #2, when I get it done (but I think I should get one good night's sleep before I start it  smile  ), will explain more about this grey border business.

Last edited by bharvey (2010-04-27 21:16:29)


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#189 2010-04-27 21:23:33

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

shadow_7283 wrote:

I also need a feature that allows you to put lists in block definitons.

Hi again.  I'm not sure I understand this fully.  Do you mean you want a block that takes a list as input?  We have that.  If you go to the long input dialog, one of the type choices is List; the result is a slot that looks like a tiny list: grey border around red item boxes.  You can drop any list onto that slot, including the red ovals next to the check boxes for the Scratch-style named lists, and also including lists made by list reporters such as LIST or COPY OF (or the custom list blocks in tools.sb).

OTOH if what you're asking for is a "Make a List" button inside the Block Editor, just make a script variable and say SET <var> TO [LIST .....].


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#190 2010-04-27 22:37:46

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

shadow_7283 wrote:

I also need a feature that allows you to put lists in block definitons.

Hi again.  I'm not sure I understand this fully.  Do you mean you want a block that takes a list as input?  We have that.  If you go to the long input dialog, one of the type choices is List; the result is a slot that looks like a tiny list: grey border around red item boxes.  You can drop any list onto that slot, including the red ovals next to the check boxes for the Scratch-style named lists, and also including lists made by list reporters such as LIST or COPY OF (or the custom list blocks in tools.sb).

OTOH if what you're asking for is a "Make a List" button inside the Block Editor, just make a script variable and say SET <var> TO [LIST .....].

Kinda to the second one. I am trying to create a reporter block in the lists section called (item of list [drop down box that's not supported  wink  ] that contains []). That way you can avoid searching an entire list for an item. Not that it is hard to do, but it is sorta irritating and slows the program down. Originally I was just going to report the values in a variable, but I realized that it would just create more problems than it fixed, especially if multiple items fit your requirmebts. So really want I want to do is create a temporary list to store these values, and let the user decide whether to report it as a variable, choose the first item of the list, etc. Can you help me out? (Sorry for any typos, I'm on an iPod touch).

Offline

 

#191 2010-04-27 23:20:13

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: BYOB 3 - Discussion Thread

shadow_7283 wrote:

bharvey wrote:

shadow_7283 wrote:

I also need a feature that allows you to put lists in block definitons.

Hi again.  I'm not sure I understand this fully.  Do you mean you want a block that takes a list as input?  We have that.  If you go to the long input dialog, one of the type choices is List; the result is a slot that looks like a tiny list: grey border around red item boxes.  You can drop any list onto that slot, including the red ovals next to the check boxes for the Scratch-style named lists, and also including lists made by list reporters such as LIST or COPY OF (or the custom list blocks in tools.sb).

OTOH if what you're asking for is a "Make a List" button inside the Block Editor, just make a script variable and say SET <var> TO [LIST .....].

Kinda to the second one. I am trying to create a reporter block in the lists section called (item of list [drop down box that's not supported  wink  ] that contains []). That way you can avoid searching an entire list for an item. Not that it is hard to do, but it is sorta irritating and slows the program down. Originally I was just going to report the values in a variable, but I realized that it would just create more problems than it fixed, especially if multiple items fit your requirmebts. So really want I want to do is create a temporary list to store these values, and let the user decide whether to report it as a variable, choose the first item of the list, etc. Can you help me out? (Sorry for any typos, I'm on an iPod touch).

You mean a block like this?
http://img94.imageshack.us/img94/8397/itemblock.gif


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#192 2010-04-27 23:23:17

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

shadow_7283 wrote:

(item of list [drop down box that's not supported  wink  ] that contains [])

As far as efficiency goes, if I'm understanding what you want to do, I don't think there's any magic way to do it without looking at each item of the list.  But of course from a user interface point of view, you don't have to write the code to look at each element, because you can use the KEEP ITEMS block in tools.sb.  It takes a predicate and a list, applies the predicate to each item of the list, and reports a list of those items for which the predicate returns TRUE.  So your block would look something like

ITEMS OF LIST <thelist> THAT CONTAINS <thetext>
REPORT [KEEP ITEMS SUCH THAT [[ ] CONTAINS <thetext>] FROM <thelist>]

... except I don't think there's a CONTAINS for text strings, so are you thinking about a list of lists?  Or are you going to write CONTAINS in terms of the text primitives?  If so, by using KEEP you only have to write a CONTAINS that looks at one text string to see if that string contains the text you're looking for.

Was that what you meant?

EDIT:  Oh, never mind, now I get it, MathWizz did understand what you wanted and I didn't.  Sorry!

Last edited by bharvey (2010-04-27 23:46:51)


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#193 2010-04-27 23:30:30

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

MathWizz wrote:

You mean a block like this?

Ah, very nice.  Isn't this fun?  Now, for extra credit, write the inverse: a block that takes a deep list (a list of lists, as in your block, to any depth) and an item value, and reports the path (as a list of positive integers) to that item in the list.  So if the list is

[[a b c] [d e [f g h] i] j [k l]]

and the item value is h, it reports [2 3 3]; if the item value is j it reports [3]; etc.  You can report the first path you find; don't worry about multiple copies of the same value.  (Maybe /that/ is the block Shadow wants?)


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#194 2010-04-27 23:43:35

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

soupoftomato wrote:

Yeah like run.
The scripts are supposed to be able to do that without being put into a block.

BWOG wrote:

That made my head hurt...

I'm reviving these earlier messages because I'd like to ask you, if you're still with us, whether the tutorial I posted helped any.  I ask because there are serious questions about how teachable this stuff is.  I'm betting that it /is/ teachable, although not necessarily easy, for anyone who's had high school algebra.  Of course one 20-minute lesson doesn't settle the question, but it'd be helpful to know whether it made a dent or not.  Thanks.


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#195 2010-04-28 00:59:54

tobydanger
Scratcher
Registered: 2010-03-18
Posts: 22

Re: BYOB 3 - Discussion Thread

Here is what should go in a file (possible named BYOB) in /usr/bin on a Linux system to get the BYOB.image file to run. I put the image file in /usr/lib/Scratch and then copied the scratch file in /usr/bin to a file named BYOB and changed the image name. If you create the file from scratch (no pun intended) you will have to set execute permissions on the BYOB file you create. Scratch will have to installed to make this work by the way.

#!/bin/sh
# Squeakvm wrapper to load Scratch image.
#------------------------------------------------------------

/usr/bin/scratch_squeak_vm \
-plugins /usr/lib/scratch/Plugins \
-vm-sound-pulse \
/usr/lib/scratch/BYOB.image "${@}"

Offline

 

#196 2010-04-28 02:19:23

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

http://cs.berkeley.edu/~bh/motion.BMP

I have wanted these for soooo long, and now I can write them myself!  Just as an example of how people who don't want to deal with higher order procedures can still benefit from BYOB.

Edit: Of course I need a POSITION reporter, too, but I realized that after taking the picture and I'm too tired to do it over.  neutral

Last edited by bharvey (2010-04-28 03:21:26)


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#197 2010-04-28 02:50:21

Chrischb
Scratcher
Registered: 2008-07-24
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Jens wrote:

Jonathanpb wrote:

Just a thought - maybe the icon for BYOB could be a Gobo? After all, the start sprite is a Gobo...  smile

Excellent suggestion, Jonathanpb! We'll try to do it for one of the next releases.

I have a related suggestion...  big_smile

Can the default Gobo have more than one costume? The Scratch cat has two, and there are several Gobo costumes that come with Scratch...  neutral


I fall: It's a tragedy. You fall: It's comedy.
Hmph enjoy your fall - I get a lovely spring... without pans of new leaves.

Offline

 

#198 2010-04-28 03:25:23

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Chrischb wrote:

Can the default Gobo have more than one costume? The Scratch cat has two, and there are several Gobo costumes that come with Scratch...

Oh yeah huh.  smile   Of course we have to edit them to match his new hairdo!


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#199 2010-04-28 03:28:35

bharvey
Scratcher
Registered: 2008-08-10
Posts: 1000+

Re: BYOB 3 - Discussion Thread

tobydanger wrote:

Scratch will have to installed to make this work by the way.

Thanks!  This will be really useful for us at Berkeley, if we can run our BYOB-based course in a Linux lab.  Do you know if there's a Scratch build for Fedora?  Last I looked all I could find was Debian, and our sysadmins seem to have settled on Linux (except for the labs that run Solaris, but that's another issue...)


http://cs.berkeley.edu/~bh/sig5.png

Offline

 

#200 2010-04-28 10:22:22

tobydanger
Scratcher
Registered: 2010-03-18
Posts: 22

Re: BYOB 3 - Discussion Thread

Yeah, I wasn't thinking about the fact the install I used was for Debian. I am using Ubuntu and it works great. I am not a huge Linux user at the moment but I put it on a laptop that was performing badly with Windows. I bet there is an installation for Squeak and then it would be a matter of getting the Scratch files from a Debian installation. It might be a little work but I think it could be done.

Offline

 

Board footer