Skip to content

Commit

Permalink
feat: add distance_to and distance_to_mouse_pointer to syntax and blo…
Browse files Browse the repository at this point in the history
…ck definitions
  • Loading branch information
aspizu committed Jan 21, 2025
1 parent 13b2dfe commit 48177b2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion editors/code/syntaxes/goboscript.tmGrammar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ patterns:
- name: support.function.builtin
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|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|wait_until|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"
- name: entity.name.type
match: "\\b(x_position|y_position|direction|size|costume_number|costume_name|backdrop_number|backdrop_name|volume|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)\\b"
match: "\\b(distance_to_moues_pointer|distance_to|x_position|y_position|direction|size|costume_number|costume_name|backdrop_number|backdrop_name|volume|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)\\b"
- name: punctuation
match: ",|;"
- name: keyword.operator
Expand Down
2 changes: 2 additions & 0 deletions gdsl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ backdrop_name ... | ...=name
[sound]==========================================================|====================|=
volume volume | |
[sensing]========================================================|====================|=
distance_to_mouse_pointer distanceto | | DISTANCETOMENU:sensing_distancetomenu=_mouse_
distance_to distanceto DISTANCETOMENU | | DISTANCETOMENU:sensing_distancetomenu=_mouse_
touching_mouse_pointer touchingobject | | TOUCHINGOBJECTMENU:sensing_touchingobjectmenu=_mouse_
touching_edge touchingobject | | TOUCHINGOBJECTMENU:sensing_touchingobjectmenu=_edge_
touching touchingobject TOUCHINGOBJECTMENU| | TOUCHINGOBJECTMENU:sensing_touchingobjectmenu=_mouse_
Expand Down
26 changes: 26 additions & 0 deletions src/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,8 @@ pub enum Repr {
BackdropNumber,
BackdropName,
Volume,
DistanceToMousePointer,
DistanceTo,
TouchingMousePointer,
TouchingEdge,
Touching,
Expand Down Expand Up @@ -1079,6 +1081,18 @@ pub enum Repr {
impl Repr {
pub fn menu(&self) -> Option<Menu> {
match self {
Self::DistanceToMousePointer => Some(Menu {
opcode: "sensing_distancetomenu",
input: "DISTANCETOMENU",
field: "DISTANCETOMENU",
default: "_mouse_",
}),
Self::DistanceTo => Some(Menu {
opcode: "sensing_distancetomenu",
input: "DISTANCETOMENU",
field: "DISTANCETOMENU",
default: "_mouse_",
}),
Self::TouchingMousePointer => Some(Menu {
opcode: "sensing_touchingobjectmenu",
input: "TOUCHINGOBJECTMENU",
Expand Down Expand Up @@ -1124,6 +1138,8 @@ impl Repr {
("backdrop_number", _) => Some(Self::BackdropNumber),
("backdrop_name", _) => Some(Self::BackdropName),
("volume", _) => Some(Self::Volume),
("distance_to_mouse_pointer", _) => Some(Self::DistanceToMousePointer),
("distance_to", _) => Some(Self::DistanceTo),
("touching_mouse_pointer", _) => Some(Self::TouchingMousePointer),
("touching_edge", _) => Some(Self::TouchingEdge),
("touching", _) => Some(Self::Touching),
Expand Down Expand Up @@ -1161,6 +1177,8 @@ impl Repr {
Self::BackdropNumber => "backdrop_number",
Self::BackdropName => "backdrop_name",
Self::Volume => "volume",
Self::DistanceToMousePointer => "distance_to_mouse_pointer",
Self::DistanceTo => "distance_to",
Self::TouchingMousePointer => "touching_mouse_pointer",
Self::TouchingEdge => "touching_edge",
Self::Touching => "touching",
Expand Down Expand Up @@ -1197,6 +1215,8 @@ impl Repr {
"backdrop_number",
"backdrop_name",
"volume",
"distance_to_mouse_pointer",
"distance_to",
"touching_mouse_pointer",
"touching_edge",
"touching",
Expand Down Expand Up @@ -1233,6 +1253,8 @@ impl Repr {
Self::BackdropNumber => "looks_backdropnumbername",
Self::BackdropName => "looks_backdropnumbername",
Self::Volume => "sound_volume",
Self::DistanceToMousePointer => "sensing_distanceto",
Self::DistanceTo => "sensing_distanceto",
Self::TouchingMousePointer => "sensing_touchingobject",
Self::TouchingEdge => "sensing_touchingobject",
Self::Touching => "sensing_touchingobject",
Expand Down Expand Up @@ -1269,6 +1291,8 @@ impl Repr {
Self::BackdropNumber => &[],
Self::BackdropName => &[],
Self::Volume => &[],
Self::DistanceToMousePointer => &[],
Self::DistanceTo => &["DISTANCETOMENU"],
Self::TouchingMousePointer => &[],
Self::TouchingEdge => &[],
Self::Touching => &["TOUCHINGOBJECTMENU"],
Expand Down Expand Up @@ -1305,6 +1329,8 @@ impl Repr {
Self::BackdropNumber => Some("{\"NUMBER_NAME\": [\"number\", null]}"),
Self::BackdropName => Some("{\"NUMBER_NAME\": [\"name\", null]}"),
Self::Volume => None,
Self::DistanceToMousePointer => None,
Self::DistanceTo => None,
Self::TouchingMousePointer => None,
Self::TouchingEdge => None,
Self::Touching => None,
Expand Down

0 comments on commit 48177b2

Please sign in to comment.