Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions docs/language/blocks/music.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
# Music Blocks

### play drum () for () beats

```goboscript
play_drum drum, beats;
```

```scratchblocks
play drum (1 v) for (beats) beats
```

### play note () for () beats

```goboscript
play_note note, beats;
```

```scratchblocks
play note (note) for (beats) beats
```

### set instrument to ()

```goboscript
set_instrument instrument;
```

```scratchblocks
set instrument to (instrument)
```

### rest for () beats

```goboscript
Expand Down
3 changes: 3 additions & 0 deletions gdsl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ change_pen_saturation changePenColorParamBy VALUE |
change_pen_brightness changePenColorParamBy VALUE | | COLOR_PARAM@colorParam:pen_menu_colorParam=brightness
change_pen_transparency changePenColorParamBy VALUE | | COLOR_PARAM@colorParam:pen_menu_colorParam=transparency
[music]==========================================================|==========================|
play_drum playDrumForBeats DRUM,BEATS | | DRUM:music_menu_DRUM=1
play_note playNoteForBeats NOTE,BEATS | |
set_instrument setInstrument INSTRUMENT | | INSTRUMENT:music_menu_INSTRUMENT=1
rest restForBeats BEATS | |
set_tempo setTempo TEMPO | |
change_tempo changeTempo ... | |
Expand Down
53 changes: 51 additions & 2 deletions src/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ pub enum Block {
ChangePenSaturation,
ChangePenBrightness,
ChangePenTransparency,
PlayDrum1,
PlayDrum2,
PlayNote,
SetInstrument,
Rest,
SetTempo,
ChangeTempo,
Expand Down Expand Up @@ -434,6 +438,24 @@ impl Block {
field: "colorParam",
default: "transparency",
}),
Self::PlayDrum1 => Some(Menu {
opcode: "music_menu_DRUM",
input: "DRUM",
field: "DRUM",
default: "1",
}),
Self::PlayDrum2 => Some(Menu {
opcode: "music_menu_DRUM",
input: "DRUM",
field: "DRUM",
default: "1",
}),
Self::SetInstrument => Some(Menu {
opcode: "music_menu_INSTRUMENT",
input: "INSTRUMENT",
field: "INSTRUMENT",
default: "1",
}),
_ => None,
}
}
Expand All @@ -445,6 +467,7 @@ impl Block {
"say" => &[Self::Say2, Self::Say1],
"think" => &[Self::Think2, Self::Think1],
"clone" => &[Self::Clone0, Self::Clone1],
"play_drum" => &[Self::PlayDrum1, Self::PlayDrum2],
_ => &[],
}
}
Expand Down Expand Up @@ -550,6 +573,11 @@ impl Block {
("change_pen_saturation", _) => Some(Self::ChangePenSaturation),
("change_pen_brightness", _) => Some(Self::ChangePenBrightness),
("change_pen_transparency", _) => Some(Self::ChangePenTransparency),
("play_drum", 1) => Some(Self::PlayDrum1),
("play_drum", 2) => Some(Self::PlayDrum2),
("play_drum", _) => Some(Self::PlayDrum1),
("play_note", _) => Some(Self::PlayNote),
("set_instrument", _) => Some(Self::SetInstrument),
("rest", _) => Some(Self::Rest),
("set_tempo", _) => Some(Self::SetTempo),
("change_tempo", _) => Some(Self::ChangeTempo),
Expand Down Expand Up @@ -653,6 +681,10 @@ impl Block {
Self::ChangePenSaturation => "change_pen_saturation",
Self::ChangePenBrightness => "change_pen_brightness",
Self::ChangePenTransparency => "change_pen_transparency",
Self::PlayDrum1 => "play_drum",
Self::PlayDrum2 => "play_drum",
Self::PlayNote => "play_note",
Self::SetInstrument => "set_instrument",
Self::Rest => "rest",
Self::SetTempo => "set_tempo",
Self::ChangeTempo => "change_tempo",
Expand Down Expand Up @@ -750,6 +782,9 @@ impl Block {
"change_pen_saturation",
"change_pen_brightness",
"change_pen_transparency",
"play_drum",
"play_note",
"set_instrument",
"rest",
"set_tempo",
"change_tempo",
Expand Down Expand Up @@ -852,6 +887,10 @@ impl Block {
Self::ChangePenSaturation => "pen_changePenColorParamBy",
Self::ChangePenBrightness => "pen_changePenColorParamBy",
Self::ChangePenTransparency => "pen_changePenColorParamBy",
Self::PlayDrum1 => "music_playDrumForBeats",
Self::PlayDrum2 => "music_playDrumForBeats",
Self::PlayNote => "music_playNoteForBeats",
Self::SetInstrument => "music_setInstrument",
Self::Rest => "music_restForBeats",
Self::SetTempo => "music_setTempo",
Self::ChangeTempo => "music_changeTempo",
Expand Down Expand Up @@ -954,6 +993,10 @@ impl Block {
Self::ChangePenSaturation => &["VALUE"],
Self::ChangePenBrightness => &["VALUE"],
Self::ChangePenTransparency => &["VALUE"],
Self::PlayDrum1 => &["BEATS"],
Self::PlayDrum2 => &["DRUM", "BEATS"],
Self::PlayNote => &["NOTE", "BEATS"],
Self::SetInstrument => &["INSTRUMENT"],
Self::Rest => &["BEATS"],
Self::SetTempo => &["TEMPO"],
Self::ChangeTempo => &["TEMPO"],
Expand Down Expand Up @@ -1058,6 +1101,10 @@ impl Block {
Self::ChangePenSaturation => None,
Self::ChangePenBrightness => None,
Self::ChangePenTransparency => None,
Self::PlayDrum1 => None,
Self::PlayDrum2 => None,
Self::PlayNote => None,
Self::SetInstrument => None,
Self::Rest => None,
Self::SetTempo => None,
Self::ChangeTempo => None,
Expand Down Expand Up @@ -1145,8 +1192,10 @@ impl Repr {
}
}

pub fn overloads(_name: &str) -> &'static [Self] {
&[]
pub fn overloads(name: &str) -> &'static [Self] {
match name {
_ => &[],
}
}

pub fn from_shape(name: &str, args: usize) -> Option<Self> {
Expand Down
Loading