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

#2551 2011-02-01 11:21:22

xly
Scratcher
Registered: 2010-04-17
Posts: 100+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

xly wrote:

1-writes a list of data into a global variable,

Using globals will cause trouble if two events overlap!

You are totally right. Still an issue to address ! In the meantime I am looking for the solution of semi-persistent variables to store a list of main properties of a sprite when it is hit. Question : how is managed by Scratch the "broadcast concurrency ?"

Ps - which is the role of the new GET instruction ?

Offline

 

#2552 2011-02-01 11:27:53

xly
Scratcher
Registered: 2010-04-17
Posts: 100+

Re: BYOB 3 - Discussion Thread

@ bharvey

.... with the semi-persistent solution each sprite has its own set of variables (defined and set when the sprite is created). Then remains the broadcast concurrency issue which can be addressed by creating one broadcast per sprite. I'm looking further on ...

Offline

 

#2553 2011-02-01 11:37:21

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

Re: BYOB 3 - Discussion Thread

xly wrote:

Question : how is managed by Scratch the "broadcast concurrency ?"

Ps - which is the role of the new GET instruction ?

Scratch actually handles it badly.  They try to prevent the usual concurrency issues by processing each time through a loop atomically, but when a BROADCAST event happens during the running of its script from an earlier event, it stops the script partway through and starts over.  This otherwise bizarre behavior is, I'm told, useful in keeping the timing of polyphonal music synchronized.

In BYOB you can check the "thread safe scripts" box in the edit menu, and then when overlapping events happen, the second event is just ignored, allowing the first one to complete.  This isn't perfect but at least it prevents leaving the project in an inconsistent state.

The GET block (which I'm hoping to eliminate) takes a text string as input and returns the variable that has that name -- it's for program-generated variable names.  But it's totally not clear that that'll make the final cut.


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

Offline

 

#2554 2011-02-01 12:46:19

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Was my bug reproduced? Solved?

Offline

 

#2555 2011-02-01 15:28:13

14God
Scratcher
Registered: 2008-11-14
Posts: 100+

Re: BYOB 3 - Discussion Thread

xly, you might like this
Its got a block for handling messages an updated 'send' block and some object list handling so you don't need explicit references anymore. Also a working but somewhat experimental block for reporting all sprites touching a sprite. Hitting the space bar will refresh the object lists, but that also happens when the green flag is clicked. All of your code should be put under the 'Go' broadcast after all the setup steps have happend. Enjoy everyone  wink


http://cs.berkeley.edu/~bh/sig4.png
Logic and reason have led me to atheism... but I'm stuck with the name  tongue

Offline

 

#2556 2011-02-01 16:02:52

14God
Scratcher
Registered: 2008-11-14
Posts: 100+

Re: BYOB 3 - Discussion Thread

'Ask' block, sibling of the 'Send':
http://lh6.ggpht.com/_YFAqfnvRMjg/TUh0Du6rkGI/AAAAAAAAAFw/MSiGyFAfjao/s128/ask.gif
http://lh4.ggpht.com/_YFAqfnvRMjg/TUh0Du1FxZI/AAAAAAAAAF0/-rhF_GPKZNk/s128/insideask.gif
Gunna have to squint at those pictures, but it takes too long to get them to the right size without messing up quality.

Last edited by 14God (2011-02-01 16:05:41)


http://cs.berkeley.edu/~bh/sig4.png
Logic and reason have led me to atheism... but I'm stuck with the name  tongue

Offline

 

#2557 2011-02-01 17:27:11

xly
Scratcher
Registered: 2010-04-17
Posts: 100+

Re: BYOB 3 - Discussion Thread

@ 14God & bharvey & Jens
I've succeeded to make my idea work, ie "when a sprite is hit it reports a semi-persistent variable ( = list of name +xpos +ypos), owned by the sprite, and sends a broadcast". When the broadcast is received the semi-variable is retrieved and resent to the master sprite as to display it.

I've noticed that broadcast is 1st class-like (accepts value) but not the "hat control When I receive broadcast". Need to finalize manually.

I'm now going to look at your work with much pleasure.
You could also like this : http://www.xleroy.net/ByobTuto/52-tutonew-10.html

Offline

 

#2558 2011-02-01 20:00:29

14God
Scratcher
Registered: 2008-11-14
Posts: 100+

Re: BYOB 3 - Discussion Thread

Are there any plans regarding networking and multiple connection meshes for 3.1/4.0?


http://cs.berkeley.edu/~bh/sig4.png
Logic and reason have led me to atheism... but I'm stuck with the name  tongue

Offline

 

#2559 2011-02-01 20:20:51

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: BYOB 3 - Discussion Thread

Any chance of a "When I am created <params...>" hat?


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#2560 2011-02-01 20:28:48

14God
Scratcher
Registered: 2008-11-14
Posts: 100+

Re: BYOB 3 - Discussion Thread

fullmoon wrote:

Any chance of a "When I am created <params...>" hat?

No need, just make a  'for this sprite only' block and call it "created" and give it whatever arguments you see fit. Then when you spawn a sprite call it's "created" block.


http://cs.berkeley.edu/~bh/sig4.png
Logic and reason have led me to atheism... but I'm stuck with the name  tongue

Offline

 

#2561 2011-02-01 20:54:31

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

Re: BYOB 3 - Discussion Thread

scimonster wrote:

Was my bug reproduced? Solved?

Nope.  Maybe you could upload a project, if you can get it to fail reliably?


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

Offline

 

#2562 2011-02-01 20:55:48

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

Re: BYOB 3 - Discussion Thread

14God wrote:

Are there any plans regarding networking and multiple connection meshes for 3.1/4.0?

Not 3.1, I'm pretty sure.  Anything is possible for 4.0 though.


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

Offline

 

#2563 2011-02-01 21:00:54

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: BYOB 3 - Discussion Thread

14God wrote:

fullmoon wrote:

Any chance of a "When I am created <params...>" hat?

No need, just make a  'for this sprite only' block and call it "created" and give it whatever arguments you see fit. Then when you spawn a sprite call it's "created" block.

Actually, I just spotted a major flaw in my idea...if you were to have multiple parameter-accepting creation hats they would all have to accept the same arguments, which sounds like a disaster, since it wouldn't be clear how they are scoped. Much better to just keep it BYOB-y!


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#2564 2011-02-01 21:03:39

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

Re: BYOB 3 - Discussion Thread

14God wrote:

No need, just make a  'for this sprite only' block and call it "created" and give it whatever arguments you see fit. Then when you spawn a sprite call it's "created" block.

That's true, but we'll probably make a CREATED hat anyway, because, for one thing, CLONE is a reporter and you might not want to have to bother making sure that the CREATED block gets called because you're busy putting the child in a list or something.


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

Offline

 

#2565 2011-02-01 21:09:15

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

Re: BYOB 3 - Discussion Thread

fullmoon wrote:

Actually, I just spotted a major flaw in my idea...if you were to have multiple parameter-accepting creation hats they would all have to accept the same arguments, which sounds like a disaster, since it wouldn't be clear how they are scoped.

I'm not sure I understand about the arguments.  Do you want to specify their values in the CLONE block?  (I talked Jens into changing the name from SPAWN.  smile  )

I suppose it would be possible for it to just have one input, and if you want more, just put them in a list!


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

Offline

 

#2566 2011-02-01 21:29:35

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

fullmoon wrote:

Actually, I just spotted a major flaw in my idea...if you were to have multiple parameter-accepting creation hats they would all have to accept the same arguments, which sounds like a disaster, since it wouldn't be clear how they are scoped.

I'm not sure I understand about the arguments.  Do you want to specify their values in the CLONE block?  (I talked Jens into changing the name from SPAWN.  smile  )

I suppose it would be possible for it to just have one input, and if you want more, just put them in a list!

I was thinking the SPAWN block would behave similarly to RUN or LAUNCH with the option of specifying a hard-coded set of parameters or a list. However I think it might be confusing (or bad practice) to allow hats to receive parameters:

Code:

When I am created |param|:
  param = 'foo'

When I am created |param|:
  wait 1 sec
  say param

So, does the sprite say 'foo''? The answer seems like it would obviously be no, but if you were to write a "created" block that simulates this functionality the answer might be different:

Code:

created = |param|{
  launch({
     param = 'foo'
  })
  launch({
     wait 1 sec
     say param
     //Yes, param == 'foo' thanks to the closure that is created.
   })
}

So I might have changed my mind about constructor hats with parameters...


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#2567 2011-02-01 22:32:07

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

scimonster wrote:

Was my bug reproduced? Solved?

Nope.  Maybe you could upload a project, if you can get it to fail reliably?

Use BYOB 3.0.8. Click make a block. Type this into the block editor:

Code:

" glide %n secs to %m

The %n should be a number insert and %m a sprite list.

Offline

 

#2568 2011-02-01 22:47:39

14God
Scratcher
Registered: 2008-11-14
Posts: 100+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

That's true, but we'll probably make a CREATED hat anyway, because, for one thing, CLONE is a reporter and you might not want to have to bother making sure that the CREATED block gets called because you're busy putting the child in a list or something.

You can keep a reference to an object with a block like this:
https://sites.google.com/site/byobimages/home/KeepBlock.gif
https://sites.google.com/site/byobimages/home/InsideKeepBlock.gif
(accidental left the 'save' var just name it keep)

So you can then do with the object as you please after adding it somewhere. Also you can make an 'interception' block (as I like to call it) which takes the same role as an existing block but adds functionality you want. So if you change the spawn block to clone I could make a 'spawn' block which uses the clone block and also adds the object to a clones list.

I think I talk to much...

Last edited by 14God (2011-02-01 22:50:54)


http://cs.berkeley.edu/~bh/sig4.png
Logic and reason have led me to atheism... but I'm stuck with the name  tongue

Offline

 

#2569 2011-02-01 23:14:26

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

Re: BYOB 3 - Discussion Thread

scimonster wrote:

Code:

" glide %n secs to %m

Oh yeah huh!  That is very bizarre.  Thanks for the report!


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

Offline

 

#2570 2011-02-01 23:21:20

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

Re: BYOB 3 - Discussion Thread

fullmoon wrote:

\ However I think it might be confusing (or bad practice) to allow hats to receive parameters:

Code:

When I am created |param|:
  param = 'foo'

When I am created |param|:
  wait 1 sec
  say param

So, does the sprite say 'foo''? The answer seems like it would obviously be no, but if you were to write a "created" block that simulates this functionality the answer might be different:

Code:

created = |param|{
  launch({
     param = 'foo'
  })
  launch({
     wait 1 sec
     say param
     //Yes, param == 'foo' thanks to the closure that is created.
   })
}

So I might have changed my mind about constructor hats with parameters...

This example doesn't bother me.  In one case you have two references to the same name in different scopes; in the other case you have two references clearly (as you say) in the same scope.  So they should behave differently!  I point out that if you want the latter behavior in the former situation you could use LAUNCH there, too.

I'm more nervous about the precedent of inputs to hat blocks altogether.  This sort of blurs the distinction between custom blocks and script-area scripts.  As I recall nXIII was arguing for that a while ago, but all else being equal it makes me nervous when a language provides two tools for the same task; I never know which I'm supposed to use when.

You're going to tell me about the pulldown menu in WHEN < > KEY PRESSED but that's not really an input; it doesn't bind a variable to whichever key you pressed.  (Maybe I shouldn't be giving nXIII ideas.  smile  )


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

Offline

 

#2571 2011-02-01 23:23:19

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

Re: BYOB 3 - Discussion Thread

14God wrote:

I think I talk to much...

Nah, you're thinking of me.  wink


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

Offline

 

#2572 2011-02-02 00:02:56

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: BYOB 3 - Discussion Thread

I don't know if this is the right place, but how does the debugger work?

Offline

 

#2573 2011-02-02 00:39:58

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

Re: BYOB 3 - Discussion Thread

scimonster wrote:

I don't know if this is the right place, but how does the debugger work?

This is as right as anyplace.  smile

You have to bear in mind that the debugger is a half-finished project.  So it has rough edges.  But we think it's a good start at a way of thinking about debugging that doesn't overwhelm you with options.

It's documented here, an excerpt from the README file distributed with BYOB.


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

Offline

 

#2574 2011-02-02 00:40:45

14God
Scratcher
Registered: 2008-11-14
Posts: 100+

Re: BYOB 3 - Discussion Thread

@ Scimonster
wow thats weird, when you put " in front of %(some letter) its like some flag that will make different things happen on you block like:

Code:

 " Test %m

will give you a drop down of sprites... useless though because you cant use them as arguments.

Try:

Code:

 " Test %x

it looks like something they were going to put in scratch but didn't

If Jens made some of these work like arguments it would be pretty cool.


http://cs.berkeley.edu/~bh/sig4.png
Logic and reason have led me to atheism... but I'm stuck with the name  tongue

Offline

 

#2575 2011-02-02 00:55:11

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: BYOB 3 - Discussion Thread

bharvey wrote:

scimonster wrote:

I don't know if this is the right place, but how does the debugger work?

This is as right as anyplace.  smile

You have to bear in mind that the debugger is a half-finished project.  So it has rough edges.  But we think it's a good start at a way of thinking about debugging that doesn't overwhelm you with options.

It's documented here, an excerpt from the README file distributed with BYOB.

OK, now I understand.
Also, pretty cool about the BYOB screensaver!

Offline

 

Board footer