Skip to content

Commit cf8ef59

Browse files
committed
Datapack export added option to let other players in radius hear music too
1 parent 7df6237 commit cf8ef59

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

scripts/control_create/control_create.gml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,9 @@ dat_obj = ""
276276
dat_tempo = 0
277277
dat_source = "block"
278278
dat_includelocked = 0
279+
dat_enableradius = 0
280+
dat_radius = 16
281+
dat_radiusvalue = 0
279282

280283
// Settings
281284
load_settings()

scripts/dat_generate/dat_generate.gml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//Generate_song(name)
1+
//dat_generate(name)
22
//Returns: string
33
var o, objective, str, note, instrument, pitch, tick, source, name
44
o = obj_controller
@@ -17,7 +17,8 @@ for (a = 0; a <= o.enda; a ++) {
1717
pitch = dat_pitch(o.song_key[a, b])
1818

1919
//Add command to result
20-
str += "playsound "+ instrument +" "+source+" @s[scores={"+objective+"="+string(tick)+"}] ~ ~ ~ 1000000 "+ string(pitch) + br
20+
if(o.dat_enableradius) str += "execute at @s[scores={"+objective+"="+string(tick)+"}] run playsound "+ instrument +" "+source+" @a ~ ~ ~ " + string(o.dat_radiusvalue) + " " + string(pitch) + br
21+
else str += "playsound "+ instrument +" "+source+" @s[scores={"+objective+"="+string(tick)+"}] ~ ~ ~ 1 "+ string(pitch) + " 1" + br
2122
}
2223
}
2324
}

scripts/datapack_export/datapack_export.gml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ with (new(obj_dummy2)) {
6161
buffer_delete(file)
6262

6363
//tick.mcfunction
64-
inputString = "execute as @a[tag=play" + randomId + "] at @s run function " + name + ":playing"
64+
if(o.dat_enableradius) inputString = "execute as @a[tag=play" + randomId + "] run function " + name + ":playing"
65+
else inputString = "execute as @a[tag=play" + randomId + "] at @s run function " + name + ":playing"
6566
file = buffer_create(string_length(inputString), buffer_fixed, 1)
6667
buffer_write(file,buffer_text,inputString)
6768
buffer_export(file,functiondir + "tick.mcfunction")

scripts/draw_window_datapack_export/draw_window_datapack_export.gml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,21 @@ if (draw_radiobox(x1 + 212, y1 + 305, dat_tempo = 5, "4 ticks / second", "Genera
3838
if (draw_radiobox(x1 + 212, y1 + 325, dat_tempo = 6, "3.33 ticks / second", "Generate song at 3.33 ticks / second")) dat_tempo = 6
3939
if (draw_radiobox(x1 + 212, y1 + 345, dat_tempo = 7, "2.86 ticks / second", "Generate song at 2.86 ticks / second")) dat_tempo = 7
4040
if (draw_radiobox(x1 + 212, y1 + 365, dat_tempo = 8, "2.5 ticks / second", "Generate song at 2.5 ticks / second")) dat_tempo = 8
41-
41+
42+
//Locked layers
4243
if (draw_checkbox(x1 + 390, y1 + 225, dat_includelocked, "Include locked layers", "Whether to include locked layers in the Datapack.")) dat_includelocked=!dat_includelocked
4344

45+
//Radius
46+
if (draw_checkbox(x1 + 390, y1 + 250, dat_enableradius, "Nearby players hear"+br+"music too", "Whether to let all players in a given radius"+br+"hear the music as well")) dat_enableradius = !dat_enableradius
47+
if(dat_enableradius) {
48+
dat_radius = median(16, draw_dragvalue(3, x1 + 500, y1 + 285, dat_radius, 2),100000)
49+
dat_radiusvalue = 1 + (dat_radius - 16) * 0.06
50+
}
51+
else draw_set_color(c_gray) draw_text(x1 + 500, y1 + 285, dat_radius)
52+
draw_text(x1 + 390, y1 + 285, "Radius (in blocks):")
53+
popup_set_window(x1 + 390, y1 + 281, 125, 21, "The radius of which players will hear the music")
54+
draw_theme_color()
55+
4456
//Submit button
4557
if (draw_button2(x1 + 470, y1 + 368, 72, "Export", false)) {
4658
if(string_replace_all(dat_name," ", "") != "" ){

0 commit comments

Comments
 (0)