Skip to content

Commit ea51c3f

Browse files
author
ShinkoNet
committed
Add support for custom instruments in datapack export
This also stops a crash where the datapack exporter will not be able to export a song if it used custom instruments in the past. The custom instrument's playsound IDs are the name of the custom instrument. This allows regular minecraft sounds to be used as instruments.
1 parent 0d1fd0f commit ea51c3f

File tree

2 files changed

+42
-36
lines changed

2 files changed

+42
-36
lines changed

scripts/dat_generate/dat_generate.gml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ for (a = 0; a <= o.enda; a ++) {
1212
for (b = 0; b <= o.collast[a]; b += 1) {
1313
if (o.song_exists[a, b] && (o.lockedlayer[b] = 0 || o.dat_includelocked)) {
1414
if (o.song_key[a, b] > 32 && o.song_key[a, b] < 58) {
15-
instrument = dat_instrument(ds_list_find_index(other.instrument_list, o.song_ins[a, b]))
15+
instrument = dat_instrument(ds_list_find_index(other.instrument_list, o.song_ins[a, b]))
1616
pitch = dat_pitch(o.song_key[a, b])
1717
blockvolume = o.layervol[b]/100
1818
s = o.layerstereo[b] // Stereo values to X coordinates
Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,46 @@
11
//dat_instrument()
22
//returns right minecraft id
33

4-
var instrument = argument0
4+
var instrumentnumber = argument0
55
var str = "minecraft:block.note_block."
6-
7-
switch (instrument) {
8-
case 0:
9-
return str + "harp"
10-
case 1:
11-
return str + "bass"
12-
case 2:
13-
return str + "basedrum"
14-
case 3:
15-
return str + "snare"
16-
case 4:
17-
return str + "hat"
18-
case 5:
19-
return str + "guitar"
20-
case 6:
21-
return str + "flute"
22-
case 7:
23-
return str + "bell"
24-
case 8:
25-
return str + "chime"
26-
case 9:
27-
return str + "xylophone"
28-
case 10:
29-
return str + "iron_xylophone"
30-
case 11:
31-
return str + "cow_bell"
32-
case 12:
33-
return str + "didgeridoo"
34-
case 13:
35-
return str + "bit"
36-
case 14:
37-
return str + "banjo"
38-
case 15:
39-
return str + "pling"
6+
var ins
7+
if instrumentnumber < 16 {
8+
switch (instrumentnumber) {
9+
case 0:
10+
return str + "harp"
11+
case 1:
12+
return str + "bass"
13+
case 2:
14+
return str + "basedrum"
15+
case 3:
16+
return str + "snare"
17+
case 4:
18+
return str + "hat"
19+
case 5:
20+
return str + "guitar"
21+
case 6:
22+
return str + "flute"
23+
case 7:
24+
return str + "bell"
25+
case 8:
26+
return str + "chime"
27+
case 9:
28+
return str + "xylophone"
29+
case 10:
30+
return str + "iron_xylophone"
31+
case 11:
32+
return str + "cow_bell"
33+
case 12:
34+
return str + "didgeridoo"
35+
case 13:
36+
return str + "bit"
37+
case 14:
38+
return str + "banjo"
39+
case 15:
40+
return str + "pling"
41+
}
42+
}
43+
if instrumentnumber >= 16 {
44+
ins = ds_list_find_value(other.instrument_list,instrumentnumber)
45+
return string("minecraft:"+ins.name)
4046
}

0 commit comments

Comments
 (0)