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

#1 2011-07-29 09:32:20

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

The List Blocks

I want to make a lot of blocks for lists, but whenever I make one, the default list is "a" instead of the first existing list.  So if my list is named list, instead of |do this to {list v}|
it becomes |do this to list {a v}|.  Does anyone know how to change this to the default list?

Offline

 

#2 2011-07-29 10:25:54

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: The List Blocks

I know it. It's something somewhere which tells the menus to set their default option to some variable. Let me look for it...

Offline

 

#3 2011-07-29 10:27:58

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: The List Blocks

ScriptableScratchMorph -> blocks -> defaultArgFor:
smile

Offline

 

#4 2011-07-29 10:57:39

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: The List Blocks

LS97 wrote:

ScriptableScratchMorph -> blocks -> defaultArgFor:
smile

Thanks so much LS97!!!!!!!!

big_smile   big_smile   big_smile

Offline

 

#5 2011-07-30 10:17:47

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: The List Blocks

LS97 wrote:

ScriptableScratchMorph -> blocks -> defaultArgFor:
smile

Darn.  I thought I knew how to change that code correctly, but it's not working.

My block's method is FontsToList.  It takes one %L argument.

Based on the surrounding code, I assumed this was what I needed to add:

Code:

#FontstoList: = t4
        ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].

But it's not working.  What am I doing wrong?

If anyone can fix this, I'll give them credit as an improvement to the block when I share it at the Library.

Offline

 

#6 2011-07-30 11:23:47

Baderous
New Scratcher
Registered: 2011-04-14
Posts: 100+

Re: The List Blocks

In the blockspec of your new block, put a default value of 'list', just like the "replace" and "contains" list blocks:

Code:

('fontsToList %L'                    r    fontsToList: 'list')

I don't know if you want a reporter, this was just an example to show you how to solve your problem.

Offline

 

#7 2011-07-30 11:31:58

Baderous
New Scratcher
Registered: 2011-04-14
Posts: 100+

Re: The List Blocks

And by the way, you shouldn't use the original Scratch to create your mod, but use the Scratch source code provided by MIT, because in the source code, variables have names that tell the programmer what they mean, not strange things like t1, t2, t3 and so on. If I hadn't the source code, I wouldn't be able to guess what the hell was t4 and t2, which in the source code have the names "sel" (from the word "selector") and "defaultArgs". I guess I don't have to say anything more to show you how easy this is to interpret.

Offline

 

#8 2011-07-30 13:32:29

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: The List Blocks

Baderous wrote:

And by the way, you shouldn't use the original Scratch to create your mod, but use the Scratch source code provided by MIT, because in the source code, variables have names that tell the programmer what they mean, not strange things like t1, t2, t3 and so on. If I hadn't the source code, I wouldn't be able to guess what the hell was t4 and t2, which in the source code have the names "sel" (from the word "selector") and "defaultArgs". I guess I don't have to say anything more to show you how easy this is to interpret.

Where is that?  I just use the browser...

Offline

 

#9 2011-07-30 13:33:34

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: The List Blocks

Baderous wrote:

In the blockspec of your new block, put a default value of 'list', just like the "replace" and "contains" list blocks:

Code:

('fontsToList %L'                    r    fontsToList: 'list')

I don't know if you want a reporter, this was just an example to show you how to solve your problem.

That's odd.  I could have sworn that I had tried that...but it's working.  Thanks!

EDIT:  Oh wait, that's because you need to do both.  Oh...

Last edited by Greenatic (2011-07-30 13:34:44)

Offline

 

#10 2011-07-30 13:50:53

Baderous
New Scratcher
Registered: 2011-04-14
Posts: 100+

Re: The List Blocks

Greenatic wrote:

Baderous wrote:

And by the way, you shouldn't use the original Scratch to create your mod, but use the Scratch source code provided by MIT, because in the source code, variables have names that tell the programmer what they mean, not strange things like t1, t2, t3 and so on. If I hadn't the source code, I wouldn't be able to guess what the hell was t4 and t2, which in the source code have the names "sel" (from the word "selector") and "defaultArgs". I guess I don't have to say anything more to show you how easy this is to interpret.

Where is that?  I just use the browser...

The browser is just a tool to explore the code. You can explore it in 2 ways:
1) Hacking the original Scratch, by shift-clicking the loop in the 'R' character of "Scratch", and selecting turn fill screen off, then opening the browser;
2) Run the source code image which already gives you an open browser and a Scratch window that isn't full screen;

The difference in using both, besides license's restrictions, is that the code in the source code image is well formatted (like having tabs and etc in things such as blockspecs, so it doesn't show up as a single confusing line) and methods variables have self-describing names to help programmers understand what they do, instead of the tX, 1<=X<infinity, naming rule used in the original Scratch.

Offline

 

#11 2011-07-30 13:59:54

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: The List Blocks

Baderous wrote:

Greenatic wrote:

Baderous wrote:

And by the way, you shouldn't use the original Scratch to create your mod, but use the Scratch source code provided by MIT, because in the source code, variables have names that tell the programmer what they mean, not strange things like t1, t2, t3 and so on. If I hadn't the source code, I wouldn't be able to guess what the hell was t4 and t2, which in the source code have the names "sel" (from the word "selector") and "defaultArgs". I guess I don't have to say anything more to show you how easy this is to interpret.

Where is that?  I just use the browser...

The browser is just a tool to explore the code. You can explore it in 2 ways:
1) Hacking the original Scratch, by shift-clicking the loop in the 'R' character of "Scratch", and selecting turn fill screen off, then opening the browser;
2) Run the source code image which already gives you an open browser and a Scratch window that isn't full screen;

The difference in using both, besides license's restrictions, is that the code in the source code image is well formatted (like having tabs and etc in things such as blockspecs, so it doesn't show up as a single confusing line) and methods variables have self-describing names to help programmers understand what they do, instead of the tX, 1<=X<infinity, naming rule used in the original Scratch.

So when I open the source code image, it gives me an easier-to-read browser?  (correct me if I'm misunderstanding).

How do I get the source code image?  Also, what's the difference in the license restrictions?  And will I need to copy over the changes I made in the browser?

Offline

 

#12 2011-07-30 14:20:56

Baderous
New Scratcher
Registered: 2011-04-14
Posts: 100+

Re: The List Blocks

Greenatic wrote:

Baderous wrote:

Greenatic wrote:

Where is that?  I just use the browser...

The browser is just a tool to explore the code. You can explore it in 2 ways:
1) Hacking the original Scratch, by shift-clicking the loop in the 'R' character of "Scratch", and selecting turn fill screen off, then opening the browser;
2) Run the source code image which already gives you an open browser and a Scratch window that isn't full screen;

The difference in using both, besides license's restrictions, is that the code in the source code image is well formatted (like having tabs and etc in things such as blockspecs, so it doesn't show up as a single confusing line) and methods variables have self-describing names to help programmers understand what they do, instead of the tX, 1<=X<infinity, naming rule used in the original Scratch.

So when I open the source code image, it gives me an easier-to-read browser?  (correct me if I'm misunderstanding).

Check the differences:

1) ScriptableScratchMorph>>blockSpecs in the source code image: http://i.imgur.com/ugHYW.png
2) The same in the original Scratch: http://i.imgur.com/PV1Nu.png

Greenatic wrote:

How do I get the source code image?

The source code can be downloaded from this page: http://info.scratch.mit.edu/Source_Code

Greenatic wrote:

Also, what's the difference in the license restrictions?  And will I need to copy over the changes I made in the browser?

I don't know if there are any restrictions on using the original Scratch to create a mod, but the source code package has its own license. Also, the original Scratch license doesn't say anything about modding it, so I think it's safer to use the source code image. But you should contact the Scratch Team if you want to know more about it.

Offline

 

#13 2011-07-30 14:31:40

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: The List Blocks

Baderous wrote:

Greenatic wrote:

Baderous wrote:


The browser is just a tool to explore the code. You can explore it in 2 ways:
1) Hacking the original Scratch, by shift-clicking the loop in the 'R' character of "Scratch", and selecting turn fill screen off, then opening the browser;
2) Run the source code image which already gives you an open browser and a Scratch window that isn't full screen;

The difference in using both, besides license's restrictions, is that the code in the source code image is well formatted (like having tabs and etc in things such as blockspecs, so it doesn't show up as a single confusing line) and methods variables have self-describing names to help programmers understand what they do, instead of the tX, 1<=X<infinity, naming rule used in the original Scratch.

So when I open the source code image, it gives me an easier-to-read browser?  (correct me if I'm misunderstanding).

Check the differences:

1) ScriptableScratchMorph>>blockSpecs in the source code image: http://i.imgur.com/ugHYW.png
2) The same in the original Scratch: http://i.imgur.com/PV1Nu.png

Greenatic wrote:

How do I get the source code image?

The source code can be downloaded from this page: http://info.scratch.mit.edu/Source_Code

Greenatic wrote:

Also, what's the difference in the license restrictions?  And will I need to copy over the changes I made in the browser?

I don't know if there are any restrictions on using the original Scratch to create a mod, but the source code package has its own license. Also, the original Scratch license doesn't say anything about modding it, so I think it's safer to use the source code image. But you should contact the Scratch Team if you want to know more about it.

Yeah, that does look a lot easier.  But since I'm used to using the standard browser and I don't plan on officially making a mod, I don't think I need it right now.  Thanks though  smile

Offline

 

#14 2011-07-30 15:15:06

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: The List Blocks

Greenatic wrote:

Since I'm used to using the standard browser and I don't plan on officially making a mod, I don't think I need it right now.  Thanks though  smile

The browser's exactly the same -- really the only thing that the source adds is the CHANGES file, which contains this nice code formatting and explanatory comments.

Offline

 

Board footer