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

#6176 2012-11-15 08:45:55

MMSequeira
Scratcher
Registered: 2010-01-04
Posts: 26

Re: BYOB 3 - Discussion Thread

Thanks for all your answers! Very welcoming. :-)

Offline

 

#6177 2012-11-15 11:11:18

MMSequeira
Scratcher
Registered: 2010-01-04
Posts: 26

Re: BYOB 3 - Discussion Thread

What are the good practices under Snap! 4.0 for dealing with pre-conditions? And in BYOB 3.1.1? In BYOB 3.1.1 I would use on of the debug blocks to enter debug mode before reporting some invalid result, in the case of reporters, or simply stopping, in the case of commands.

Offline

 

#6178 2012-11-15 13:49:36

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: BYOB 3 - Discussion Thread

MMSequeira wrote:

custom blocks are not localizable.

Is there a Google translate API that could be used?


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#6179 2012-11-15 14:22:08

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

Re: BYOB 3 - Discussion Thread

MMSequeira wrote:

What are the good practices under Snap! 4.0 for dealing with pre-conditions? And in BYOB 3.1.1? In BYOB 3.1.1 I would use on of the debug blocks to enter debug mode before reporting some invalid result, in the case of reporters, or simply stopping, in the case of commands.

You could write an ASSERT block with a Boolean input that gives the error message if the input is false.

Truth is, though, we don't encourage our students to do that sort of sanity checking, because we are targeting non-computer-scientists, and I think teacher rigidity about proper programming style is the second biggest turnoff in traditional intro CS education (after Java syntax).  We don't even give error messages based on user-declared input slot types.  Better a few errors than students deciding this field isn't for them.

They can learn defensive programming later on, from someone else.  smile


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

Offline

 

#6180 2012-11-15 15:16:41

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: BYOB 3 - Discussion Thread

1) What's the cloud thing meant to do? It doesn't work at the moment.
2) How come the http block only works in the snap.berkley.edu domain?

Last edited by joefarebrother (2012-11-15 15:16:58)


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#6181 2012-11-15 15:26:07

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

joefarebrother wrote:

1) What's the cloud thing meant to do? It doesn't work at the moment.
2) How come the http block only works in the snap.berkley.edu domain?

1) Exactly what you observed - It doesn't work at the moment.
2) Some kind of XSS protection, I'd guess

Offline

 

#6182 2012-11-15 16:38:03

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: BYOB 3 - Discussion Thread

joefarebrother wrote:

2) How come the http block only works in the snap.berkley.edu domain?

It's an XMLHttpRequest thing.


nXIII

Offline

 

#6183 2012-11-15 20:52:51

alloplastic
New Scratcher
Registered: 2012-08-30
Posts: 12

Re: BYOB 3 - Discussion Thread

Dreammod & nXIII,

Any progress on a BYOB to Snap! converter?  I should have some cycles this weekend to start getting involved with this effort.  Is one of you (nXIII?) on the verge of having a complete implementation?  Or does it make sense for both efforts to move forward in parallel?

In case either of you wants that complex test case I mentioned, here's the library: http://www.newlifeinteractive.com/technologies/gameblocks/GameBlocks_v0.2.1.zip.

I have some video tutorials on YouTube I can share if you want to see how the blocks actually work, but none of this is public yet.  I think there are performance issues that should be addressed before this library would be doing anyone any favors.  :-)

Thanks,

Offline

 

#6184 2012-11-15 21:50:16

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: BYOB 3 - Discussion Thread

alloplastic wrote:

Dreammod & nXIII,

Any progress on a BYOB to Snap! converter?  I should have some cycles this weekend to start getting involved with this effort.  Is one of you (nXIII?) on the verge of having a complete implementation?  Or does it make sense for both efforts to move forward in parallel?

In case either of you wants that complex test case I mentioned, here's the library: http://www.newlifeinteractive.com/technologies/gameblocks/GameBlocks_v0.2.1.zip.

I have some video tutorials on YouTube I can share if you want to see how the blocks actually work, but none of this is public yet.  I think there are performance issues that should be addressed before this library would be doing anyone any favors.  :-)

Thanks,

You can try out the converter here. The "download" checkbox is a convenience for Chrome users which will save the .xml file automatically. (The other stuff is for debugging  tongue )

Last edited by nXIII (2012-11-15 22:00:12)


nXIII

Offline

 

#6185 2012-11-16 21:15:14

alloplastic
New Scratcher
Registered: 2012-08-30
Posts: 12

Re: BYOB 3 - Discussion Thread

nXIII,

Wow, it worked really well.  About 98% of the code came through just fine.  The only issue I saw was that some of the list argument slots in my custom blocks didn't come through quite right.  I see text like "% list of sprite names" instead of an active slot for the variable "list of sprite names."

Here are screen-grabs of blocks with this problem:

     http://www.newlifeinteractive.com/technologies/gameblocks/img/Hide_Sprites_Block.png
     http://www.newlifeinteractive.com/technologies/gameblocks/img/Launch_On_Sprites_Block.png

And here's one where the list slot ("costumes") was converted correctly:

http://www.newlifeinteractive.com/technologies/gameblocks/img/Cartoons_Play_Block.png

There are some other problems caused by my library's use of deprecated blocks like "object" and "the script."  I have a Snap! question about how to migrate such code to the new block set... but I'll put that into a separate post.

Thanks for sharing the converter.  I'm sure that there are other developers out there like me who will be thrilled to have a migration path to Snap!

Offline

 

#6186 2012-11-16 21:26:10

alloplastic
New Scratcher
Registered: 2012-08-30
Posts: 12

Re: BYOB 3 - Discussion Thread

So, here's my question on Snap!

A key feature of BYOB for my game blocks library is the ability to run code on a sprite other than the one in which the script appears.  This allows for an NPC conversation or cut-scene to be coded in the flow of a single script.  It also allows for blocks like "launch on sprites" that create basic particle effects or convenience blocks like "hide sprites" for changing game levels.

My question is how might this be accomplished in Snap?  I see an input slot for an "Object," and the slot looks a lot like the default sprite, but I don't see how to fill that slot with a reference to a sprite.  Does it only accept code objects?  I see that I can put a "ringed" item in there like a code block.

One trick my BYOB library uses is iterating through a list of sprite objects by name.  The code is something like "Run [The Script] of [object <sprite name>]," as pictured here:

http://www.newlifeinteractive.com/technologies/gameblocks/img/Hide_Sprites_Block.png

Is there any way to accomplish the same sort of remote-control of multiple sprites in Snap?

Offline

 

#6187 2012-11-16 23:46:35

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

Re: BYOB 3 - Discussion Thread

alloplastic wrote:

deprecated blocks like "object" and "the script."

The OOP features that were added in BYOB 3.1 aren't in Snap! yet and probably won't be until 4.1, so hold off on converting OOP projects.

But THE SCRIPT should (@nXIII) be converted to a ring in Snap!.


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

Offline

 

#6188 2012-11-17 10:58:41

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

alloplastic wrote:

deprecated blocks like "object" and "the script."

The OOP features that were added in BYOB 3.1 aren't in Snap! yet and probably won't be until 4.1, so hold off on converting OOP projects.

But THE SCRIPT should (@nXIII) be converted to a ring in Snap!.

It is converted to a ring…

The most frequent "obsolete" block is (attribute) OF (object), which usually has a script inside of it.

Last edited by nXIII (2012-11-17 11:02:28)


nXIII

Offline

 

#6189 2012-11-17 11:56:18

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: BYOB 3 - Discussion Thread

nXIII wrote:

joefarebrother wrote:

2) How come the http block only works in the snap.berkley.edu domain?

It's an XMLHttpRequest thing.

Is it possible to use some other object than XMLHttpRequest since you only need to read  the files contents not execute any scripts on the page?


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#6190 2012-11-17 11:58:45

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: BYOB 3 - Discussion Thread

joefarebrother wrote:

nXIII wrote:

joefarebrother wrote:

2) How come the http block only works in the snap.berkley.edu domain?

It's an XMLHttpRequest thing.

Is it possible to use some other object than XMLHttpRequest since you only need to read  the files contents not execute any scripts on the page?

That's not the reason it's blocked, but the only real alternative to a direct XMLHttpRequest is an one to a server on the same domain which would just echo the contents of the URL (or CORS, but only if the specific server allows it).

Last edited by nXIII (2012-11-17 11:59:39)


nXIII

Offline

 

#6191 2012-11-17 13:24:12

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: BYOB 3 - Discussion Thread

nXIII wrote:

joefarebrother wrote:

nXIII wrote:


It's an XMLHttpRequest thing.

Is it possible to use some other object than XMLHttpRequest since you only need to read  the files contents not execute any scripts on the page?

That's not the reason it's blocked, but the only real alternative to a direct XMLHttpRequest is an one to a server on the same domain which would just echo the contents of the URL (or CORS, but only if the specific server allows it).

hmm. I wonder if it would be that much strain on the servers. It is, after all, literally one line of PHP required:

Code:

<?php echo file_get_contents('http://www.' . $_GET['url']); ?>

But how expensive is file_get_contents() and how many would use block at once? It would be useful, though...

How likely is it that this will be implemented?


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#6192 2012-11-17 14:26:42

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: BYOB 3 - Discussion Thread

joefarebrother wrote:

nXIII wrote:

joefarebrother wrote:

Is it possible to use some other object than XMLHttpRequest since you only need to read  the files contents not execute any scripts on the page?

That's not the reason it's blocked, but the only real alternative to a direct XMLHttpRequest is an one to a server on the same domain which would just echo the contents of the URL (or CORS, but only if the specific server allows it).

hmm. I wonder if it would be that much strain on the servers. It is, after all, literally one line of PHP required:

Code:

<?php echo file_get_contents('http://www.' . $_GET['url']); ?>

But how expensive is file_get_contents() and how many would use block at once?

Wouldn't this then basically turn the server into a proxy?  hmm

It would probably be worth at least adding mime-type checks to ensure you're not returning a binary image or something that Snap! won't like...


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#6193 2012-11-17 15:04:14

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

Re: BYOB 3 - Discussion Thread

nXIII wrote:

It is converted to a ring…

Ah, sorry, I should have known better.  Decades ago, my brilliant mentor Ralph Gorin told me, "Never believe anything a user says"!   tongue

PS  It's very hard to post a reply to a message that includes an embedded Snap! project.  sad

@jfb, blob: Jens says we'll use CORS to solve the HTTP: block problem.  I am trying to avoid learning the details, trusting that he'll make it all happy.


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

Offline

 

#6194 2012-11-17 15:59:42

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

@jfb, blob: Jens says we'll use CORS to solve the HTTP: block problem.

To Jens, then: if I understand it correctly, doesn't CORS have to be enabled on any servers you want to make requests to?


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#6195 2012-11-17 16:27:30

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: BYOB 3 - Discussion Thread

blob8108 wrote:

bharvey wrote:

@jfb, blob: Jens says we'll use CORS to solve the HTTP: block problem.

To Jens, then: if I understand it correctly, doesn't CORS have to be enabled on any servers you want to make requests to?

Yeah, the server at the request URI has to send the Access-Control-Allow-Origin header.

Last edited by nXIII (2012-11-17 16:30:39)


nXIII

Offline

 

#6196 2012-11-17 17:46:44

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: BYOB 3 - Discussion Thread

nXIII wrote:

blob8108 wrote:

bharvey wrote:

@jfb, blob: Jens says we'll use CORS to solve the HTTP: block problem.

To Jens, then: if I understand it correctly, doesn't CORS have to be enabled on any servers you want to make requests to?

Yeah, the server at the request URI has to send the Access-Control-Allow-Origin header.

Awww, that's what I thought. There's no way of doing it from one domain to any domain, then.


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#6197 2012-11-17 20:11:22

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

PS  It's very hard to post a reply to a message that includes an embedded Snap! project.  sad

Agreed. You need to add a built-in URL shortener to Snap! to compress those crazy URLs.

P.S. Can we please stop adding exclamation points to Snap!?!


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#6198 2012-11-18 07:56:37

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

P.S. Can we please stop adding exclamation points to Snap!?!

I tried that one already. Apparently the exclamation mark is part of Snap!'s name.  tongue


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#6199 2012-11-18 08:32:43

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: BYOB 3 - Discussion Thread

blob8108 wrote:

Hardmath123 wrote:

P.S. Can we please stop adding exclamation points to Snap!?!

I tried that one already. Apparently the exclamation mark is part of Snap!'s name.  tongue

I'm gonna start calling it Snap*CLICK* if this keeps up.  tongue


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#6200 2012-11-18 11:31:03

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

Re: BYOB 3 - Discussion Thread

Hardmath123 wrote:

I'm gonna start calling it Snap*CLICK* if this keeps up.  tongue

I believe the correct pronunciation would be "Snap-bang" if you're not happy with the intended staccato "Snap."  smile

Okay, look, Jens doesn't like it either (although he did at the beginning), but the point is that there are about a zillion things called "snap," including half a zillion computer-related things, and the exclamation point is supposed to make this one stand out from the crowd.  And it's also supposed to be onomotopoetic, because of the sound the blocks make as they snap together.  smile   Aren't those things worth the occasional awkwardness of a sentence that ends with "Snap!"?


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

Offline

 

Board footer