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
)
Simon
Offline
It certainly sounds possible, and interesting.
Offline
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
It will make something like
switch output 1 on
Last edited by LS97 (2012-08-23 08:23:25)
Offline
@LS97 - Just what I wanted to know
I wasn't going to learn how to make my own blocks if it couldn't be easily be done
Brain in gear time
Simon
Offline
SimpleScratch wrote:
@LS97 - Just what I wanted to know
![]()
Cool, glad to know it worked. And I suppose you understand how to adapt it for other blocks and broadcasts!
Offline
@LS97 - Just done Shift-Click R so far
But I'm a quick learner
Simon
Offline
SimpleScratch wrote:
@LS97 - Just done Shift-Click R so far
![]()
But I'm a quick learner![]()
Simon
OK, good luck! You'll find many tutorials that will help you if you do some searches in the Advanced Topics.
Offline
Yippee - my first Scratch block works
I found a tutorial by some geezer called LS97 http://scratch.mit.edu/forums/viewtopic.php?id=34152
Thanks
Simon
Offline
Right - I'm moving onto Stage 2 - make the 1 into a variable
I might be back for more help later
SImon
Offline
Got this now
self broadcast: t1 asString asUTF8 , 'on'
so I can use a variable for the port number
Just off to work out how to make the 'on' a variable so I can so 'off' as well as a block parameter
Having a great time
Simon
Offline
This is fun
got the port number and the state (on or off) as variables
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
Cool!
You could always make a new category... And split variables/lists into separate categories so you still have an even number.
Offline