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

#1 2012-08-17 12:21:47

killerchip
New Scratcher
Registered: 2012-08-02
Posts: 8

variable based event receptions

It would be great to have event reception block to be based on variable content.

For example:

when I receive (myevent)
It' great that you can do it with broadcast.

You see when I create a sprite I create a prototype (e.g. spaceship1) with all scenarios in it handling events like

when I receive [ship1.destroy]
when I receive [ship1.launch]
etc.

When I'm done, I copy the original sprite to multiple ones so I can use in game (e.g. spaceship2, spaceship3, etc.)
But with each copy I need to go and change manually all event handlers.

If I had
when I receive <join(myname).[destroy]>
It would be easy to replicate, and re-use the sprite in other projects. It could be easier to share with other scratchers as a kind of 'black-box' object, without having to 'mess' with the code.

Any suggestions on this idea?

Thanks
Costas

Offline

 

#2 2012-08-17 13:25:18

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

Re: variable based event receptions

Hmm, I see what you mean. It's sometimes a a bit disappointing that you can't put blocks (such as variables) inside of the "when I receive" block.  That would certainly allow more possibilities for creative uses of broadcasts.  But you would still have to manually change "myname" for each ship, right? So either way there's a bit of work involved.


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

Offline

 

#3 2012-08-17 16:38:35

killerchip
New Scratcher
Registered: 2012-08-02
Posts: 8

Re: variable based event receptions

Yes. But you have to change only the 'myname' variable at one place (usually at 'when fg clicked', instead of searching through the code for all events :-)

Offline

 

Board footer