Skip to content

Commit ed7253d

Browse files
committed
add fine pitch to command block schematic
1 parent c6dca47 commit ed7253d

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

scripts/schematic_export/schematic_export.gml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function schematic_export() {
22
// schematic_export()
33
var fn, a, b, c, d, p, xx, yy, zz, len, wid, hei, o, chestx, chesty, chestz, signx, signy, signz, nblocks, layers, cyy, y1, insnum, ins;
4-
var REPEATER, TORCHON, TORCHOFF, WIRE, LADDER, RAIL, POWEREDRAIL, noteblocks, noteblockx, noteblocky, noteblockz, noteblocknote, noteblockins;
4+
var REPEATER, TORCHON, TORCHOFF, WIRE, LADDER, RAIL, POWEREDRAIL, noteblocks, noteblockx, noteblocky, noteblockz, noteblocknote, noteblockins, noteblockpit;
55
if (!structure) fn = string(get_save_filename_ext("Minecraft Schematics (*.schematic)|*.schematic", filename_new_ext(filename, "") + ".schematic", "", "Export Schematic"))
66
else fn = string(get_save_filename_ext("Minecraft Structures (*.nbt)|*.nbt", filename_new_ext(string_replace_all(string_lower(filename), " ", "_"), "") + ".nbt", "", "Export Schematic"))
77
if (fn = "") return 0
@@ -204,15 +204,18 @@ function schematic_export() {
204204
if ((o.song_key[a, b] > 32 && o.song_key[a, b] < 58) || (o.command_block && o.song_key[a, b] >= 9 && o.song_key[a, b] <= 81)) {
205205
nblockins[nblocks] = ds_list_find_index(other.instrument_list, o.song_ins[a, b])
206206
nblockkey[nblocks] = o.song_key[a, b]
207+
nblockpit[nblocks] = o.song_pit[a, b]
207208
nblocks += 1
208209
} else if (!o.sch_exp_compress) {
209210
nblockins[nblocks] = -1
210211
nblockkey[nblocks] = 0
212+
nblockpit[nblocks] = 0
211213
nblocks += 1
212214
}
213215
} else if (!o.sch_exp_compress) {
214216
nblockins[nblocks] = -1
215217
nblockkey[nblocks] = 0
218+
nblockpit[nblocks] = 0
216219
nblocks += 1
217220
}
218221
}
@@ -239,6 +242,7 @@ function schematic_export() {
239242
noteblockz[noteblocks] = b * 3 + 1
240243
noteblocknote[noteblocks] = nblockkey[nblocks] - 33
241244
noteblockins[noteblocks] = nblockins[nblocks]
245+
noteblockpit[noteblocks] = nblockpit[nblocks]
242246
noteblocks += 1
243247
}
244248
nblocks -= 1
@@ -252,6 +256,7 @@ function schematic_export() {
252256
noteblockz[noteblocks] = b * 3 + 1
253257
noteblocknote[noteblocks] = nblockkey[nblocks] - 33
254258
noteblockins[noteblocks] = nblockins[nblocks]
259+
noteblockpit[noteblocks] = nblockpit[nblocks]
255260
noteblocks += 1
256261
}
257262
nblocks -= 1
@@ -265,6 +270,7 @@ function schematic_export() {
265270
noteblockz[noteblocks] = b * 3 + 2
266271
noteblocknote[noteblocks] = nblockkey[nblocks] - 33
267272
noteblockins[noteblocks] = nblockins[nblocks]
273+
noteblockpit[noteblocks] = nblockpit[nblocks]
268274
noteblocks += 1
269275
}
270276
nblocks -= 1
@@ -278,6 +284,7 @@ function schematic_export() {
278284
noteblockz[noteblocks] = b * 3 + 2
279285
noteblocknote[noteblocks] = nblockkey[nblocks] - 33
280286
noteblockins[noteblocks] = nblockins[nblocks]
287+
noteblockpit[noteblocks] = nblockpit[nblocks]
281288
noteblocks += 1
282289
}
283290
nblocks -= 1
@@ -450,7 +457,7 @@ function schematic_export() {
450457
signz = hei - 1
451458
xx = 1
452459
yy = wid - 7
453-
var rep, dir, nblocks, nblockins, nblockkey, turn;
460+
var rep, dir, nblocks, nblockins, nblockkey, nblockpit, turn;
454461
rep = 0
455462
dir = -1 // 1 or -1
456463
for (a = 0; a <= o.enda; a += 1) {
@@ -464,15 +471,18 @@ function schematic_export() {
464471
if ((o.song_key[a, b] > 32 && o.song_key[a, b] < 58) || (o.command_block && o.song_key[a, b] >= 9 && o.song_key[a, b] <= 81)) {
465472
nblockins[nblocks] = ds_list_find_index(other.instrument_list, o.song_ins[a, b])
466473
nblockkey[nblocks] = o.song_key[a, b]
474+
nblockpit[nblocks] = o.song_pit[a, b]
467475
nblocks += 1
468476
} else if (!o.sch_exp_compress) {
469477
nblockins[nblocks] = -1
470478
nblockkey[nblocks] = 0
479+
nblockpit[nblocks] = 0
471480
nblocks += 1
472481
}
473482
} else if (!o.sch_exp_compress) {
474483
nblockins[nblocks] = -1
475484
nblockkey[nblocks] = 0
485+
nblockpit[nblocks] = 0
476486
nblocks += 1
477487
}
478488
}
@@ -499,6 +509,7 @@ function schematic_export() {
499509
noteblockz[noteblocks] = b * 3 + 1
500510
noteblocknote[noteblocks] = nblockkey[nblocks] - 33
501511
noteblockins[noteblocks] = nblockins[nblocks]
512+
noteblockpit[noteblocks] = nblockpit[nblocks]
502513
noteblocks += 1
503514
}
504515
nblocks -= 1
@@ -512,6 +523,7 @@ function schematic_export() {
512523
noteblockz[noteblocks] = b * 3 + 1
513524
noteblocknote[noteblocks] = nblockkey[nblocks] - 33
514525
noteblockins[noteblocks] = nblockins[nblocks]
526+
noteblockpit[noteblocks] = nblockpit[nblocks]
515527
noteblocks += 1
516528
}
517529
nblocks -= 1
@@ -525,6 +537,7 @@ function schematic_export() {
525537
noteblockz[noteblocks] = b * 3 + 2
526538
noteblocknote[noteblocks] = nblockkey[nblocks] - 33
527539
noteblockins[noteblocks] = nblockins[nblocks]
540+
noteblockpit[noteblocks] = nblockpit[nblocks]
528541
noteblocks += 1
529542
}
530543
nblocks -= 1
@@ -538,6 +551,7 @@ function schematic_export() {
538551
noteblockz[noteblocks] = b * 3 + 2
539552
noteblocknote[noteblocks] = nblockkey[nblocks] - 33
540553
noteblockins[noteblocks] = nblockins[nblocks]
554+
noteblockpit[noteblocks] = nblockpit[nblocks]
541555
noteblocks += 1
542556
}
543557
nblocks -= 1
@@ -936,10 +950,10 @@ function schematic_export() {
936950
if (o.command_block) {
937951
TAG_Compound("nbt")
938952
soundname = dat_instrument(noteblockins[a])
939-
soundpitch = dat_pitch(noteblocknote[a] + 33)
953+
soundpitch = dat_pitch(noteblocknote[a] + 33 + noteblockpit[a] / 100)
940954
if (noteblocknote[a] < 0) soundname += "_-1"
941955
else if (noteblocknote[a] > 24) soundname += "_1"
942-
TAG_String("Command", "playsound "+ soundname +" block @a ~ ~ ~ 3 " + string(dat_pitch(noteblocknote[a] + 33)))
956+
TAG_String("Command", "playsound "+ soundname +" block @a ~ ~ ~ 3 " + string(soundpitch))
943957
TAG_Byte("TrackOutput", 0)
944958
TAG_Byte("powered", 0)
945959
TAG_Byte("auto", 0)

0 commit comments

Comments
 (0)