Skip to content

Commit 54143f0

Browse files
authored
Add online() reporter block (sensing_online) (#279)
Adds the `online()` reporter block with opcode `sensing_online` to the sensing reporters. No arguments. Documentation added to `docs/language/reporters/sensing.md`.
2 parents 0680dfb + e5428bf commit 54143f0

5 files changed

Lines changed: 28 additions & 24 deletions

File tree

docs/language/reporters/sensing.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,16 @@ user = username();
200200
(username)
201201
```
202202

203+
### online?
204+
205+
```goboscript
206+
is_online = online();
207+
```
208+
209+
```scratchblocks
210+
<online?>
211+
```
212+
203213
### touching color ()?
204214

205215
```goboscript

editors/code/syntaxes/goboscript.tmGrammar.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ patterns:
3131
- name: support.function.builtin
3232
match: "\\b(move|turn_left|turn_right|goto_random_position|goto_mouse_pointer|goto|glide|glide_to_random_position|glide_to_mouse_pointer|point_in_direction|point_towards_mouse_pointer|point_towards_random_direction|point_towards|change_x|set_x|change_y|set_y|if_on_edge_bounce|set_rotation_style_left_right|set_rotation_style_do_not_rotate|set_rotation_style_all_around|say|think|switch_costume|next_costume|switch_backdrop|previous_backdrop|random_backdrop|next_backdrop|set_size|change_size|change_color_effect|change_fisheye_effect|change_whirl_effect|change_pixelate_effect|change_mosaic_effect|change_brightness_effect|change_ghost_effect|set_color_effect|set_fisheye_effect|set_whirl_effect|set_pixelate_effect|set_mosaic_effect|set_brightness_effect|set_ghost_effect|clear_graphic_effects|show|hide|goto_front|goto_back|go_forward|go_backward|play_sound_until_done|start_sound|stop_all_sounds|change_pitch_effect|change_pan_effect|set_pitch_effect|set_pan_effect|change_volume|set_volume|clear_sound_effects|broadcast|broadcast_and_wait|wait|stop_all|stop_this_script|stop_other_scripts|delete_this_clone|clone|ask|set_drag_mode_draggable|set_drag_mode_not_draggable|reset_timer|erase_all|stamp|pen_down|pen_up|set_pen_color|change_pen_size|set_pen_size|set_pen_hue|set_pen_saturation|set_pen_brightness|set_pen_transparency|change_pen_hue|change_pen_saturation|change_pen_brightness|change_pen_transparency|rest|set_tempo|change_tempo)\\b"
3333
- name: entity.name.type
34-
match: "\\b(x_position|y_position|direction|size|costume_number|costume_name|backdrop_number|backdrop_name|volume|distance_to_mouse_pointer|distance_to|touching_mouse_pointer|touching_edge|touching|key_pressed|mouse_down|mouse_x|mouse_y|loudness|timer|current_year|current_month|current_date|current_day_of_week|current_hour|current_minute|current_second|days_since_2000|username|touching_color|color_is_touching_color|answer|random|contains)\\b"
34+
match: "\\b(x_position|y_position|direction|size|costume_number|costume_name|backdrop_number|backdrop_name|volume|distance_to_mouse_pointer|distance_to|touching_mouse_pointer|touching_edge|touching|key_pressed|mouse_down|mouse_x|mouse_y|loudness|timer|current_year|current_month|current_date|current_day_of_week|current_hour|current_minute|current_second|days_since_2000|username|online|touching_color|color_is_touching_color|answer|random|contains)\\b"
3535
- name: punctuation
3636
match: ",|;"
3737
- name: keyword.operator

editors/notepad++/goboscript.udl.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<Keywords name="Keywords5">on onflag onkey onclick onbackdrop onloudness ontimer onclone on</Keywords>
3232
<Keywords name="Keywords6">show hide add to delete insert at of as</Keywords>
3333
<Keywords name="Keywords7">move turn_left turn_right goto_random_position goto_mouse_pointer goto glide glide_to_random_position glide_to_mouse_pointer point_in_direction point_towards_mouse_pointer point_towards_random_direction point_towards change_x set_x change_y set_y if_on_edge_bounce set_rotation_style_left_right set_rotation_style_do_not_rotate set_rotation_style_all_around say think switch_costume next_costume switch_backdrop next_backdrop set_size change_size change_color_effect change_fisheye_effect change_whirl_effect change_pixelate_effect change_mosaic_effect change_brightness_effect change_ghost_effect set_color_effect set_fisheye_effect set_whirl_effect set_pixelate_effect set_mosaic_effect set_brightness_effect set_ghost_effect clear_graphic_effects show hide goto_front goto_back go_forward go_backward play_sound_until_done start_sound stop_all_sounds change_pitch_effect change_pan_effect set_pitch_effect set_pan_effect change_volume set_volume clear_sound_effects broadcast broadcast_and_wait wait stop_all stop_this_script stop_other_scripts delete_this_clone clone ask set_drag_mode_draggable set_drag_mode_not_draggable reset_timer erase_all stamp pen_down pen_up set_pen_color change_pen_size set_pen_size set_pen_hue set_pen_saturation set_pen_brightness set_pen_transparency change_pen_hue change_pen_saturation change_pen_brightness change_pen_transparency rest set_tempo change_tempo</Keywords>
34-
<Keywords name="Keywords8">x_position y_position direction size costume_number costume_name backdrop_number backdrop_name volume distance_to_mouse_pointer distance_to touching_mouse_pointer touching_edge touching key_pressed mouse_down mouse_x mouse_y loudness timer current_year current_month current_date current_day_of_week current_hour current_minute current_second days_since_2000 username touching_color color_is_touching_color answer random contains</Keywords>
34+
<Keywords name="Keywords8">x_position y_position direction size costume_number costume_name backdrop_number backdrop_name volume distance_to_mouse_pointer distance_to touching_mouse_pointer touching_edge touching key_pressed mouse_down mouse_x mouse_y loudness timer current_year current_month current_date current_day_of_week current_hour current_minute current_second days_since_2000 username online touching_color color_is_touching_color answer random contains</Keywords>
3535
<Keywords name="Delimiters">00&quot; 01\&quot; 02&quot; 03 04 05 06``` 07 08``` 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23</Keywords>
3636
</KeywordLists>
3737
<Styles>

gdsl.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ current_minute ... | ...=MINUTE
193193
current_second ... | ...=SECOND |
194194
days_since_2000 dayssince2000 | |
195195
username username | |
196+
online online | |
196197
touching_color touchingcolor COLOR | |
197198
color_is_touching_color coloristouchingcolor COLOR,COLOR2| |
198199
answer answer | |

src/blocks.rs

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,7 @@ pub enum Block {
276276
ChangePenSaturation,
277277
ChangePenBrightness,
278278
ChangePenTransparency,
279-
PlayDrum1,
280-
PlayDrum2,
279+
PlayDrum,
281280
PlayNote,
282281
SetInstrument,
283282
Rest,
@@ -438,13 +437,7 @@ impl Block {
438437
field: "colorParam",
439438
default: "transparency",
440439
}),
441-
Self::PlayDrum1 => Some(Menu {
442-
opcode: "music_menu_DRUM",
443-
input: "DRUM",
444-
field: "DRUM",
445-
default: "1",
446-
}),
447-
Self::PlayDrum2 => Some(Menu {
440+
Self::PlayDrum => Some(Menu {
448441
opcode: "music_menu_DRUM",
449442
input: "DRUM",
450443
field: "DRUM",
@@ -467,7 +460,6 @@ impl Block {
467460
"say" => &[Self::Say2, Self::Say1],
468461
"think" => &[Self::Think2, Self::Think1],
469462
"clone" => &[Self::Clone0, Self::Clone1],
470-
"play_drum" => &[Self::PlayDrum1, Self::PlayDrum2],
471463
_ => &[],
472464
}
473465
}
@@ -573,9 +565,7 @@ impl Block {
573565
("change_pen_saturation", _) => Some(Self::ChangePenSaturation),
574566
("change_pen_brightness", _) => Some(Self::ChangePenBrightness),
575567
("change_pen_transparency", _) => Some(Self::ChangePenTransparency),
576-
("play_drum", 1) => Some(Self::PlayDrum1),
577-
("play_drum", 2) => Some(Self::PlayDrum2),
578-
("play_drum", _) => Some(Self::PlayDrum1),
568+
("play_drum", _) => Some(Self::PlayDrum),
579569
("play_note", _) => Some(Self::PlayNote),
580570
("set_instrument", _) => Some(Self::SetInstrument),
581571
("rest", _) => Some(Self::Rest),
@@ -681,8 +671,7 @@ impl Block {
681671
Self::ChangePenSaturation => "change_pen_saturation",
682672
Self::ChangePenBrightness => "change_pen_brightness",
683673
Self::ChangePenTransparency => "change_pen_transparency",
684-
Self::PlayDrum1 => "play_drum",
685-
Self::PlayDrum2 => "play_drum",
674+
Self::PlayDrum => "play_drum",
686675
Self::PlayNote => "play_note",
687676
Self::SetInstrument => "set_instrument",
688677
Self::Rest => "rest",
@@ -887,8 +876,7 @@ impl Block {
887876
Self::ChangePenSaturation => "pen_changePenColorParamBy",
888877
Self::ChangePenBrightness => "pen_changePenColorParamBy",
889878
Self::ChangePenTransparency => "pen_changePenColorParamBy",
890-
Self::PlayDrum1 => "music_playDrumForBeats",
891-
Self::PlayDrum2 => "music_playDrumForBeats",
879+
Self::PlayDrum => "music_playDrumForBeats",
892880
Self::PlayNote => "music_playNoteForBeats",
893881
Self::SetInstrument => "music_setInstrument",
894882
Self::Rest => "music_restForBeats",
@@ -993,8 +981,7 @@ impl Block {
993981
Self::ChangePenSaturation => &["VALUE"],
994982
Self::ChangePenBrightness => &["VALUE"],
995983
Self::ChangePenTransparency => &["VALUE"],
996-
Self::PlayDrum1 => &["BEATS"],
997-
Self::PlayDrum2 => &["DRUM", "BEATS"],
984+
Self::PlayDrum => &["DRUM", "BEATS"],
998985
Self::PlayNote => &["NOTE", "BEATS"],
999986
Self::SetInstrument => &["INSTRUMENT"],
1000987
Self::Rest => &["BEATS"],
@@ -1101,8 +1088,7 @@ impl Block {
11011088
Self::ChangePenSaturation => None,
11021089
Self::ChangePenBrightness => None,
11031090
Self::ChangePenTransparency => None,
1104-
Self::PlayDrum1 => None,
1105-
Self::PlayDrum2 => None,
1091+
Self::PlayDrum => None,
11061092
Self::PlayNote => None,
11071093
Self::SetInstrument => None,
11081094
Self::Rest => None,
@@ -1142,6 +1128,7 @@ pub enum Repr {
11421128
CurrentSecond,
11431129
DaysSince2000,
11441130
Username,
1131+
Online,
11451132
TouchingColor,
11461133
ColorIsTouchingColor,
11471134
Answer,
@@ -1192,7 +1179,7 @@ impl Repr {
11921179
}
11931180
}
11941181

1195-
pub fn overloads(_name: &str) -> &'static [Self] {
1182+
pub fn overloads(name: &str) -> &'static [Self] {
11961183
&[]
11971184
}
11981185

@@ -1227,6 +1214,7 @@ impl Repr {
12271214
("current_second", _) => Some(Self::CurrentSecond),
12281215
("days_since_2000", _) => Some(Self::DaysSince2000),
12291216
("username", _) => Some(Self::Username),
1217+
("online", _) => Some(Self::Online),
12301218
("touching_color", _) => Some(Self::TouchingColor),
12311219
("color_is_touching_color", _) => Some(Self::ColorIsTouchingColor),
12321220
("answer", _) => Some(Self::Answer),
@@ -1267,6 +1255,7 @@ impl Repr {
12671255
Self::CurrentSecond => "current_second",
12681256
Self::DaysSince2000 => "days_since_2000",
12691257
Self::Username => "username",
1258+
Self::Online => "online",
12701259
Self::TouchingColor => "touching_color",
12711260
Self::ColorIsTouchingColor => "color_is_touching_color",
12721261
Self::Answer => "answer",
@@ -1306,6 +1295,7 @@ impl Repr {
13061295
"current_second",
13071296
"days_since_2000",
13081297
"username",
1298+
"online",
13091299
"touching_color",
13101300
"color_is_touching_color",
13111301
"answer",
@@ -1345,6 +1335,7 @@ impl Repr {
13451335
Self::CurrentSecond => "sensing_current",
13461336
Self::DaysSince2000 => "sensing_dayssince2000",
13471337
Self::Username => "sensing_username",
1338+
Self::Online => "sensing_online",
13481339
Self::TouchingColor => "sensing_touchingcolor",
13491340
Self::ColorIsTouchingColor => "sensing_coloristouchingcolor",
13501341
Self::Answer => "sensing_answer",
@@ -1384,6 +1375,7 @@ impl Repr {
13841375
Self::CurrentSecond => &[],
13851376
Self::DaysSince2000 => &[],
13861377
Self::Username => &[],
1378+
Self::Online => &[],
13871379
Self::TouchingColor => &["COLOR"],
13881380
Self::ColorIsTouchingColor => &["COLOR", "COLOR2"],
13891381
Self::Answer => &[],
@@ -1423,6 +1415,7 @@ impl Repr {
14231415
Self::CurrentSecond => Some("{\"CURRENTMENU\": [\"SECOND\", null]}"),
14241416
Self::DaysSince2000 => None,
14251417
Self::Username => None,
1418+
Self::Online => None,
14261419
Self::TouchingColor => None,
14271420
Self::ColorIsTouchingColor => None,
14281421
Self::Answer => None,

0 commit comments

Comments
 (0)