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

#1 2012-08-22 17:42:41

SimpleScratch
Scratcher
Registered: 2007-05-25
Posts: 100+

Is is trivial convert a broadcast to a block?

I'm listening for broadcasts using RSC in python
e.g Broadcast 1on - I take that broadcast and switch output1 on on a RaspberryPi GPIO port.
How hard to make a unique block to send the same broadcast e.g Turn1On block?
(PS Not done any modding at all yet apart from today when I learnt how to import a .change file from MathWhizz  smile  )

Simon

Offline

 

#2 2012-08-22 19:50:50

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: Is is trivial convert a broadcast to a block?

It certainly sounds possible, and interesting.


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#3 2012-08-23 08:22:25

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

Re: Is is trivial convert a broadcast to a block?

So a unique block that will send that broadcast?

Blockspec:
('switch output 1 on' - output1on)

Code:

output1on
self broadcast: '1on'.

Assuming you know (or can find out) how to add blocks, that's it  smile

It will make something like

switch output 1 on

Last edited by LS97 (2012-08-23 08:23:25)

Offline

 

#4 2012-08-23 09:10:51

SimpleScratch
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Is is trivial convert a broadcast to a block?

@LS97 - Just what I wanted to know  smile
I wasn't going to learn how to make my own blocks if it couldn't be easily be done  smile
Brain in gear time  smile

Simon

Offline

 

#5 2012-08-23 12:42:39

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

Re: Is is trivial convert a broadcast to a block?

SimpleScratch wrote:

@LS97 - Just what I wanted to know  smile

Cool, glad to know it worked. And I suppose you understand how to adapt it for other blocks and broadcasts!

Offline

 

#6 2012-08-23 13:08:28

SimpleScratch
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Is is trivial convert a broadcast to a block?

@LS97 - Just done Shift-Click R so far  smile
But I'm a quick learner  smile

Simon

Offline

 

#7 2012-08-23 13:18:46

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

Re: Is is trivial convert a broadcast to a block?

SimpleScratch wrote:

@LS97 - Just done Shift-Click R so far  smile
But I'm a quick learner  smile

Simon

OK, good luck! You'll find many tutorials that will help you if you do some searches in the Advanced Topics.

Offline

 

#8 2012-08-23 14:26:38

SimpleScratch
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Is is trivial convert a broadcast to a block?

Yippee - my first Scratch block works  smile
I found a tutorial by some geezer called LS97 http://scratch.mit.edu/forums/viewtopic.php?id=34152  smile
Thanks
Simon

Offline

 

#9 2012-08-23 14:31:56

SimpleScratch
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Is is trivial convert a broadcast to a block?

Right - I'm moving onto Stage 2 - make the 1 into a variable  smile
I might be back for more help later  smile
SImon

Offline

 

#10 2012-08-23 18:04:00

SimpleScratch
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Is is trivial convert a broadcast to a block?

Got this now
self broadcast: t1 asString asUTF8 , 'on'
so I can use a variable for the port number  smile

Just off to work out how to make  the 'on' a variable so I can so 'off' as well as a block parameter  smile
Having a great time  smile
Simon

Offline

 

#11 2012-08-23 19:29:10

SimpleScratch
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Is is trivial convert a broadcast to a block?

This is fun  smile
got the port number and the state (on or off) as variables  smile

BUT, I want to be greedy and have the port numbers only be in the 1-8 range and the state variable only to be on or off.

24Aug12 - And got that working as well by looking at what others do so I've now got a lovely block where you can select ports 1-4 (or all) and set state to on or off.

My main issue now is which category should it go in and can I make it a custom colour?

Simon

Last edited by SimpleScratch (2012-08-24 11:42:58)

Offline

 

#12 2012-08-24 12:54:39

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

Re: Is is trivial convert a broadcast to a block?

Cool!  smile  You could always make a new category... And split variables/lists into separate categories so you still have an even number.


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

Offline

 

Board footer