Created
September 17, 2013 14:47
-
-
Save champierre/6595357 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "scratchrsc" | |
| class PrintRSC < RSCWatcher | |
| def on_broadcast(name) # when a broadcast is sent | |
| puts "broadcast #{name}" # print it to the screen | |
| end | |
| def on_sensor_update(name,value) # when a variable or sensor is updated | |
| puts "#{name} = #{value}" # print the change to the screen | |
| if name == "test" | |
| @test = value | |
| end | |
| end | |
| def broadcast_hello # when the broadcast "hello" is sent, ignore on_broadcast and | |
| puts "Helloを受け取りました" # greet the world, | |
| puts "test: #{@test}" | |
| end | |
| end | |
| watcher = PrintRSC.new # you can provide the host as an argument | |
| watcher.sensor_update "connected", "1" | |
| loop { watcher.handle_command } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment