Skip to content

Commit fc7295d

Browse files
author
ShinkoNet
committed
Added range and more chord bugfixing
1 parent 1db7037 commit fc7295d

File tree

3 files changed

+60
-28
lines changed

3 files changed

+60
-28
lines changed

scripts/branch_export/branch_export.gml

Lines changed: 53 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ show_debug_message("rangestart " + string(rangestart))
1515
show_debug_message("rangeend " + string(rangeend))
1616
show_debug_message("enda " + string(enda))
1717
tags = 0
18-
sch_len = rangeend * 2 + 4
18+
sch_len = (rangeend - rangestart) * 2 + 4
1919
schematic_size(mySchematic, 3, sch_len, 2 )
2020
if sch_exp_velocity = 1 schematic_size(mySchematic, 33, sch_len, 2 )
2121
if sch_exp_chords > 1 && sch_exp_velocity = 1 schematic_size(mySchematic, 33, sch_len, 3 )
@@ -35,7 +35,7 @@ var sellayer = real(sch_br_layer2) - 1
3535

3636
// Repeater Pattern on top
3737

38-
for (a = 0; a <= rangeend * 2; a++) {
38+
for (a = 0; a <= (rangeend - rangestart) * 2; a++) {
3939
if a % 2 == 1 {
4040
schematic_cell_set(mySchematic, lineloc, a + 2, 1, 93, 3)
4141
} else {
@@ -47,7 +47,7 @@ var sellayer = real(sch_br_layer2) - 1
4747
// Add Note Blocks to Array
4848
nblocks = 0
4949

50-
for (a = 0; a <= rangeend; a ++) {
50+
for (a = rangestart; a <= rangeend; a ++) {
5151
if (o.song_exists[a, sellayer]) {
5252
if (o.song_key[a, sellayer] > 32 && o.song_key[a, sellayer] < 58) {
5353
if sch_exp_stereo = 4 { // Add all note blocks
@@ -86,7 +86,7 @@ var sellayer = real(sch_br_layer2) - 1
8686
b = nblocks
8787
nblocks = 0
8888

89-
for (a = 0; a <= rangeend * 2; a++) {
89+
for (a = 0; a <= (b - 1) * 2; a++) {
9090
if a % 2 == 0 {
9191
if nblockkey[z, nblocks] != 0 {
9292
if sch_exp_velocity = 0 {
@@ -113,10 +113,20 @@ var sellayer = real(sch_br_layer2) - 1
113113
schematic_cell_set(mySchematic, zvel, a + 2, 1, sch_exp_circuit_block, sch_exp_circuit_data)
114114
schematic_cell_set(mySchematic, zvel, a + 2, 2, 55, 0)
115115
if zvel > 16 {
116-
schematic_fill(mySchematic, lineloc + 1, a + 2, 1, zvel - 1, a + 2, 1, 55, 0)
116+
var c
117+
for (c = lineloc + 1; c <= zvel; c++) {
118+
if (schematic_block_get(mySchematic, zvel + (c - zvel), a + 2, 1) = 0) {
119+
schematic_block_set(mySchematic, zvel + (c - zvel), a + 2, 1, 55)
120+
}
121+
}
117122
}
118123
if zvel < 16 {
119-
schematic_fill(mySchematic, lineloc - 1, a + 2, 1, zvel + 1, a + 2, 1, 55, 0)
124+
var c
125+
for (c = lineloc - 1; c >= zvel; c--) {
126+
if (schematic_block_get(mySchematic, zvel + (c - zvel), a + 2, 1) = 0) {
127+
schematic_block_set(mySchematic, zvel + (c - zvel), a + 2, 1, 55)
128+
}
129+
}
120130
}
121131
}
122132
if sch_br_layer2 != 0 && z = 1 {
@@ -158,7 +168,7 @@ sellayer = real(sch_br_layer3) - 1
158168

159169
// Repeater Pattern on top
160170

161-
for (a = 0; a <= rangeend * 2; a++) {
171+
for (a = 0; a <= (rangeend - rangestart) * 2; a++) {
162172
if a % 2 == 1 {
163173
schematic_cell_set(mySchematic, lineloc, a + 2, 1, 93, 3)
164174
} else {
@@ -170,7 +180,7 @@ sellayer = real(sch_br_layer3) - 1
170180
// Add Note Blocks to Array
171181
nblocks = 0
172182

173-
for (a = 0; a <= rangeend; a ++) {
183+
for (a = rangestart; a <= rangeend; a ++) {
174184
if (o.song_exists[a, sellayer]) {
175185
if (o.song_key[a, sellayer] > 32 && o.song_key[a, sellayer] < 58) {
176186
if sch_exp_stereo = 4 { // Add all note blocks
@@ -209,7 +219,7 @@ sellayer = real(sch_br_layer3) - 1
209219
b = nblocks
210220
nblocks = 0
211221

212-
for (a = 0; a <= rangeend * 2; a++) {
222+
for (a = 0; a <= (b - 1) * 2; a++) {
213223
if a % 2 == 0 {
214224
if nblockkey[z, nblocks] != 0 {
215225
if sch_exp_velocity = 0 {
@@ -236,10 +246,20 @@ sellayer = real(sch_br_layer3) - 1
236246
schematic_cell_set(mySchematic, zvel, a + 2, 1, sch_exp_circuit_block, sch_exp_circuit_data)
237247
schematic_cell_set(mySchematic, zvel, a + 2, 2, 55, 0)
238248
if zvel > 16 {
239-
schematic_fill(mySchematic, lineloc + 1, a + 2, 1, zvel - 1, a + 2, 1, 55, 0)
249+
var c
250+
for (c = lineloc + 1; c <= zvel; c++) {
251+
if (schematic_block_get(mySchematic, zvel + (c - zvel), a + 2, 1) = 0) {
252+
schematic_block_set(mySchematic, zvel + (c - zvel), a + 2, 1, 55)
253+
}
254+
}
240255
}
241256
if zvel < 16 {
242-
schematic_fill(mySchematic, lineloc - 1, a + 2, 1, zvel + 1, a + 2, 1, 55, 0)
257+
var c
258+
for (c = lineloc - 1; c >= zvel; c--) {
259+
if (schematic_block_get(mySchematic, zvel + (c - zvel), a + 2, 1) = 0) {
260+
schematic_block_set(mySchematic, zvel + (c - zvel), a + 2, 1, 55)
261+
}
262+
}
243263
}
244264
}
245265
if sch_br_layer2 != 0 && z = 1 {
@@ -281,7 +301,7 @@ sellayer = real(sch_br_layer1) - 1
281301

282302
// Repeater Pattern on top
283303

284-
for (a = 0; a <= rangeend * 2; a++) {
304+
for (a = 0; a <= (rangeend - rangestart) * 2; a++) {
285305
if a % 2 == 1 {
286306
schematic_cell_set(mySchematic, lineloc, a + 2, 1, 93, 3)
287307
} else {
@@ -293,7 +313,7 @@ sellayer = real(sch_br_layer1) - 1
293313
// Add Note Blocks to Array
294314
nblocks = 0
295315

296-
for (a = 0; a <= rangeend; a ++) {
316+
for (a = rangestart; a <= rangeend; a ++) {
297317
if (o.song_exists[a, sellayer]) {
298318
if (o.song_key[a, sellayer] > 32 && o.song_key[a, sellayer] < 58) {
299319
if sch_exp_stereo = 4 { // Add all note blocks
@@ -333,7 +353,7 @@ sellayer = real(sch_br_layer1) - 1
333353
b = nblocks
334354
nblocks = 0
335355

336-
for (a = 0; a <= rangeend * 2; a++) {
356+
for (a = 0; a <= (b - 1) * 2; a++) {
337357
if a % 2 == 0 {
338358
if nblockkey[z, nblocks] != 0 {
339359
if sch_exp_velocity = 0 {
@@ -360,16 +380,16 @@ sellayer = real(sch_br_layer1) - 1
360380
if zvel > 16 {
361381
var c
362382
for (c = lineloc + 1; c <= zvel; c++) {
363-
if (schematic_block_get(mySchematic, zvel + (c - zvel), a + 2, 1) = 0) {
364-
schematic_block_set(mySchematic, zvel + (c - zvel), a + 2, 1, 55)
383+
if (schematic_block_get(mySchematic, zvel + (c - zvel) - 1, a + 2, 1) = 0) {
384+
schematic_block_set(mySchematic, zvel + (c - zvel) - 1, a + 2, 1, 55)
365385
}
366386
}
367387
}
368388
if zvel < 16 {
369389
var c
370390
for (c = lineloc - 1; c >= zvel; c--) {
371-
if (schematic_block_get(mySchematic, zvel + (c - zvel), a + 2, 1) = 0) {
372-
schematic_block_set(mySchematic, zvel + (c - zvel), a + 2, 1, 55)
391+
if (schematic_block_get(mySchematic, zvel + (c - zvel) + 1, a + 2, 1) = 0) {
392+
schematic_block_set(mySchematic, zvel + (c - zvel) + 1, a + 2, 1, 55)
373393
}
374394
}
375395
}
@@ -386,11 +406,20 @@ sellayer = real(sch_br_layer1) - 1
386406

387407
noteblockx[z, nblocks] = a + 1
388408
} else {
389-
schematic_cell_set(mySchematic, zvel, a + 2, 1, 25, 0)
390-
schematic_cell_set(mySchematic, zvel, a + 2, 2, 0, 0)
391-
schematic_cell_set(mySchematic, zvel, a + 2, 0, sch_exp_ins_block[nblockins[z, nblocks]], 0)
409+
if (schematic_block_get(mySchematic, zvel, a + 2, 1) = 55) { // stop the note block blocking other notes further down the branch
410+
schematic_cell_set(mySchematic, zvel, a + 2, 1, sch_exp_circuit_block, sch_exp_circuit_data)
411+
schematic_block_set(mySchematic, zvel, a + 2, 2, 55)
412+
schematic_cell_set(mySchematic, zvel, a + 3, 1, 25, 0)
413+
schematic_cell_set(mySchematic, zvel, a + 3, 2, 0, 0)
414+
schematic_cell_set(mySchematic, zvel, a + 3, 0, sch_exp_ins_block[nblockins[z, nblocks]], 0)
415+
noteblockx[z, nblocks] = a + 3
416+
} else {
417+
schematic_cell_set(mySchematic, zvel, a + 2, 1, 25, 0)
418+
schematic_cell_set(mySchematic, zvel, a + 2, 2, 0, 0)
419+
schematic_cell_set(mySchematic, zvel, a + 2, 0, sch_exp_ins_block[nblockins[z, nblocks]], 0)
392420

393-
noteblockx[z, nblocks] = a + 2
421+
noteblockx[z, nblocks] = a + 2
422+
}
394423
}
395424
noteblockz[z, nblocks] = zvel
396425
}
@@ -405,7 +434,7 @@ sellayer = real(sch_br_layer1) - 1
405434
////////////////////////////////////////////////////
406435
var noteblocks = 0
407436

408-
for (a = 0; a <= rangeend; a ++) {
437+
for (a = rangestart; a <= rangeend; a ++) {
409438
if sch_exp_chords = 1 {
410439
if o.song_exists[a, real(sch_br_layer1) - 1] {
411440
noteblocks++
@@ -435,7 +464,7 @@ show_debug_message(sch_layer1)
435464
show_debug_message(sch_layer2)
436465
show_debug_message(sch_layer3)
437466
show_debug_message(noteblocks)
438-
entries = 0
467+
entries = rangeend - rangestart
439468
schematic_save(mySchematic, fn, entries, noteblocks);
440469
schematic_destroy(mySchematic);
441470
schematic_end();

scripts/draw_window_branch_export/draw_window_branch_export.gml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,11 @@ if (selected_tab_sch = 0) {
169169
}
170170
if (draw_button2(x1 + 470, y1 + 368, 72, "Export") && wmenu = 0) {
171171
if (sch_exp_totalblocks[sch_exp_includelocked] <= 0) {
172-
message("There are no blocks to export!", "Schematic export")
173-
} else {
172+
message("There are no blocks to export!", "Branch export")
173+
} else if sch_exp_range_start > sch_exp_range_end {
174+
message("Starting range must be lower than ending range!", "Branch export")
175+
}
176+
else {
174177
branch_export()
175178
}
176179
}

scripts/schematic_save/schematic_save.gml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ nbt_tag_compound(file, "Schematic") {
2727
nbt_tag_list(file, "Entities", 10, 0);
2828
nbt_tag_list(file, "TileEntities", 10, noteblocks);
2929
for (z = 0; z < sch_exp_chords; z ++) {
30-
for (a = 0; a < sch_exp_range_end; a ++) {
30+
for (a = 0; a <= entries; a ++) {
3131
if nblockkey[z, a] != 0 {
3232
nbt_tag_string(file, "id", "minecraft:noteblock")
33-
nbt_tag_int(file, "x", - noteblockx[z, a] + sch_exp_range_end * 2 + 3) // why the hell does this work
33+
nbt_tag_int(file, "x", - noteblockx[z, a] + (sch_exp_range_end - sch_exp_range_start) * 2 + 3) // why the hell does this work
3434
nbt_tag_int(file, "y", noteblocky[z, a])
3535
nbt_tag_int(file, "z", noteblockz[z, a])
3636
nbt_tag_byte(file, "note", noteblocknote[z, a])

0 commit comments

Comments
 (0)