Skip to content

Commit c67e262

Browse files
author
ShinkoNet
committed
More bugfixes for 3 polyphony branches.
and a few gui changes for the export window.
1 parent b0d3c41 commit c67e262

File tree

2 files changed

+73
-40
lines changed

2 files changed

+73
-40
lines changed

scripts/branch_export/branch_export.gml

Lines changed: 68 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ sellayer = real(sch_br_layer3) - 1
222222
for (a = 0; a <= (b - 1) * 2; a++) {
223223
if a % 2 == 0 {
224224
if nblockkey[z, nblocks] != 0 {
225+
var nudge = 0
225226
if sch_exp_velocity = 0 {
226227
if z = 1 {
227228
schematic_cell_set(mySchematic, lineloc + 1, a + 2, 1, 25, 0)
@@ -242,45 +243,43 @@ sellayer = real(sch_br_layer3) - 1
242243
zvel = round(32 - nblockvel[z, nblocks]/100 * 32)
243244
if zvel >= 15 && zvel <= 17 zvel = 14
244245
if sch_exp_circuitry = 1 {
245-
schematic_fill(mySchematic, lineloc, a + 2, 0, zvel, a + 2, 0, sch_exp_circuit_block, sch_exp_circuit_data) // Connects a redstone line to the block
246-
schematic_cell_set(mySchematic, zvel, a + 2, 1, sch_exp_circuit_block, sch_exp_circuit_data)
247-
schematic_cell_set(mySchematic, zvel, a + 2, 2, 55, 0)
248-
if zvel > 16 {
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-
}
246+
schematic_fill(mySchematic, lineloc, a + 2, 0, zvel, a + 2, 0, sch_exp_circuit_block, sch_exp_circuit_data) // Connects a redstone line to the block
247+
schematic_cell_set(mySchematic, zvel, a + 2, 1, sch_exp_circuit_block, sch_exp_circuit_data)
248+
schematic_cell_set(mySchematic, zvel, a + 2, 2, 55, 0)
249+
}
250+
if zvel > 16 {
251+
var c
252+
for (c = lineloc + 1; c <= zvel; c++) {
253+
if (schematic_block_get(mySchematic, zvel + (c - zvel), a + 2, 1) = 0) {
254+
schematic_block_set(mySchematic, zvel + (c - zvel), a + 2, 1, 55)
254255
}
255-
}
256-
if zvel < 16 {
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-
}
256+
}
257+
nudge = 1
258+
}
259+
if zvel < 16 {
260+
var c
261+
for (c = lineloc - 1; c >= zvel; c--) {
262+
if (schematic_block_get(mySchematic, zvel + (c - zvel), a + 2, 1) = 0) {
263+
schematic_block_set(mySchematic, zvel + (c - zvel), a + 2, 1, 55)
262264
}
263265
}
266+
nudge = -1
264267
}
265-
if sch_br_layer2 != 0 && z = 1 {
266-
schematic_cell_set(mySchematic, zvel, a + 3, 1, 25, 0)
267-
schematic_cell_set(mySchematic, zvel, a + 3, 2, 0, 0)
268-
schematic_cell_set(mySchematic, zvel, a + 3, 0, sch_exp_ins_block[nblockins[z, nblocks]], 0)
269-
noteblockx[z, nblocks] = a + 3
270-
} else if sch_br_layer3 != 0 && z = 2 {
268+
if (schematic_block_get(mySchematic, zvel, a + 1, 1) = 25) {
269+
schematic_cell_set(mySchematic, zvel + nudge, a + 2, 1, 25, 0)
270+
schematic_cell_set(mySchematic, zvel + nudge, a + 2, 2, 0, 0)
271+
schematic_cell_set(mySchematic, zvel + nudge, a + 2, 0, sch_exp_ins_block[nblockins[z, nblocks]], 0)
272+
schematic_cell_set(mySchematic, zvel + nudge, a + 1, 0, sch_exp_ins_block[nblockins[z, nblocks]], 0)
273+
noteblockx[z, nblocks] = a + 2
274+
noteblockz[z, nblocks] = zvel + nudge
275+
show_debug_message("found blocked pos end of line")
276+
} else {
271277
schematic_cell_set(mySchematic, zvel, a + 1, 1, 25, 0)
272278
schematic_cell_set(mySchematic, zvel, a + 1, 2, 0, 0)
273279
schematic_cell_set(mySchematic, zvel, a + 1, 0, sch_exp_ins_block[nblockins[z, nblocks]], 0)
274-
275-
noteblockx[z, nblocks] = a + 1
276-
} else {
277-
schematic_cell_set(mySchematic, zvel, a + 2, 1, 25, 0)
278-
schematic_cell_set(mySchematic, zvel, a + 2, 2, 0, 0)
279-
schematic_cell_set(mySchematic, zvel, a + 2, 0, sch_exp_ins_block[nblockins[z, nblocks]], 0)
280-
281-
noteblockx[z, nblocks] = a + 2
280+
noteblockx[z, nblocks] = a + 1
281+
noteblockz[z, nblocks] = zvel
282282
}
283-
noteblockz[z, nblocks] = zvel
284283
}
285284
noteblocky[z, nblocks] = 1
286285
noteblocknote[z, nblocks] = nblockkey[z, nblocks] - 33
@@ -378,19 +377,35 @@ sellayer = real(sch_br_layer1) - 1
378377
if sch_exp_circuitry = 1 {
379378
schematic_fill(mySchematic, lineloc, a + 2, 0, zvel, a + 2, 0, sch_exp_circuit_block, sch_exp_circuit_data) // Connects a redstone line to the block
380379
if zvel > 16 {
380+
nudge = 1
381+
var d
381382
var c
382383
for (c = lineloc + 1; c <= zvel; c++) {
383384
if (schematic_block_get(mySchematic, zvel + (c - zvel) - 1, a + 2, 1) = 0) {
384385
schematic_block_set(mySchematic, zvel + (c - zvel) - 1, a + 2, 1, 55)
385386
}
387+
if (schematic_block_get(mySchematic, zvel + (c - zvel) + 1, a + 2, 1) = 25) {
388+
schematic_cell_set(mySchematic, zvel + (c - zvel) + 1, a + 1, 1, sch_exp_circuit_block, sch_exp_circuit_data)
389+
schematic_cell_set(mySchematic, zvel + (c - zvel) + 1, a + 2, 1, 25, 0)
390+
schematic_cell_set(mySchematic, zvel + (c - zvel) + 1, a + 2, 2, 0, 0)
391+
schematic_block_set(mySchematic, zvel + (c - zvel) + 1, a + 2, 2, 55)
392+
}
386393
}
387394
}
388395
if zvel < 16 {
396+
nudge = -1
389397
var c
398+
var d
390399
for (c = lineloc - 1; c >= zvel; c--) {
391400
if (schematic_block_get(mySchematic, zvel + (c - zvel) + 1, a + 2, 1) = 0) {
392401
schematic_block_set(mySchematic, zvel + (c - zvel) + 1, a + 2, 1, 55)
393402
}
403+
if (schematic_block_get(mySchematic, zvel + (c - zvel) + 1, a + 2, 1) = 25) {
404+
schematic_cell_set(mySchematic, zvel + (c - zvel) + 1, a + 1, 1, 25, 0)
405+
schematic_cell_set(mySchematic, zvel + (c - zvel) + 1, a + 1, 2, 0, 0)
406+
schematic_cell_set(mySchematic, zvel + (c - zvel) + 1, a + 2, 1, sch_exp_circuit_block, sch_exp_circuit_data)
407+
schematic_block_set(mySchematic, zvel + (c - zvel) + 1, a + 2, 2, 55)
408+
}
394409
}
395410
}
396411
}
@@ -413,18 +428,18 @@ sellayer = real(sch_br_layer1) - 1
413428
schematic_cell_set(mySchematic, zvel, a + 3, 2, 0, 0)
414429
schematic_cell_set(mySchematic, zvel, a + 3, 0, sch_exp_ins_block[nblockins[z, nblocks]], 0)
415430
noteblockx[z, nblocks] = a + 3
416-
} else if (schematic_block_get(mySchematic, zvel, a + 3, 1) = 25) && (schematic_block_get(mySchematic, zvel, a + 1, 1) = 0) {
431+
} else if (schematic_block_get(mySchematic, zvel, a + 3, 1) = 25) && (schematic_block_get(mySchematic, zvel, a + 1, 1) = 0) && (schematic_block_get(mySchematic, zvel + nudge, a + 1, 1) != 0) {
417432
schematic_cell_set(mySchematic, zvel, a + 1, 1, 25, 0)
418433
schematic_cell_set(mySchematic, zvel, a + 1, 2, 0, 0)
419434
schematic_cell_set(mySchematic, zvel, a + 1, 0, sch_exp_ins_block[nblockins[z, nblocks]], 0)
420435
noteblockx[z, nblocks] = a + 1
421-
show_debug_message("note block in way")
422-
} else if (schematic_block_get(mySchematic, zvel, a + 1, 1) = 25) && (schematic_block_get(mySchematic, zvel, a + 3, 1) = 0) {
436+
//show_debug_message("note block in way")
437+
} else if (schematic_block_get(mySchematic, zvel, a + 1, 1) = 25) && (schematic_block_get(mySchematic, zvel, a + 3, 1) = 0) && (schematic_block_get(mySchematic, zvel + nudge, a + 1, 1) != 0) {
423438
schematic_cell_set(mySchematic, zvel, a + 3, 1, 25, 0)
424439
schematic_cell_set(mySchematic, zvel, a + 3, 2, 0, 0)
425440
schematic_cell_set(mySchematic, zvel, a + 3, 0, sch_exp_ins_block[nblockins[z, nblocks]], 0)
426441
noteblockx[z, nblocks] = a + 3
427-
show_debug_message("note block in way")
442+
//show_debug_message("note block in way")
428443
} else {
429444
schematic_cell_set(mySchematic, zvel, a + 2, 1, 25, 0)
430445
schematic_cell_set(mySchematic, zvel, a + 2, 2, 0, 0)
@@ -472,11 +487,28 @@ for (a = rangestart; a <= rangeend; a ++) {
472487
}
473488
}
474489
}
490+
entries = rangeend - rangestart
491+
for (c = 0; c < sch_exp_chords; c ++) { // Corrections hack
492+
for (a = 0; a <= entries; a ++) {
493+
if (schematic_block_get(mySchematic, noteblockz[c, a], noteblockx[c, a], 1) = 25) {
494+
schematic_block_set(mySchematic, noteblockz[c, a], noteblockx[c, a], 2, 0)
495+
}
496+
if (schematic_block_get(mySchematic, noteblockz[c, a], noteblockx[c, a], 1) = sch_exp_circuit_block) {
497+
noteblockx[c, a] -= 1
498+
}
499+
if (schematic_block_get(mySchematic, noteblockz[c, a], noteblockx[c, a] - 1, 1) = sch_exp_circuit_block) || (schematic_block_get(mySchematic, noteblockz[c, a], noteblockx[c, a] - 1, 1) = 0) {
500+
if (schematic_block_get(mySchematic, noteblockz[c, a], noteblockx[c, a] - 1, 0) != sch_exp_circuit_block) {
501+
schematic_block_set(mySchematic, noteblockz[c, a], noteblockx[c, a] - 1, 1, 0)
502+
schematic_block_set(mySchematic, noteblockz[c, a], noteblockx[c, a] - 1, 0, 0)
503+
}
504+
}
505+
}
506+
}
507+
475508
show_debug_message(sch_layer1)
476509
show_debug_message(sch_layer2)
477510
show_debug_message(sch_layer3)
478511
show_debug_message(noteblocks)
479-
entries = rangeend - rangestart
480512
schematic_save(mySchematic, fn, entries, noteblocks);
481513
schematic_destroy(mySchematic);
482514
schematic_end();

scripts/draw_window_branch_export/draw_window_branch_export.gml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,13 @@ if (selected_tab_sch = 0) {
9393
if (draw_checkbox(x1 + 170, y1 + 300, sch_exp_velocity, "Enable Velocity", "Whether to position the note blocks differently due to their velocity.\nIt's recommended that each layer's velocity should be the same when polyphony is higher than 1.")) sch_exp_velocity=!sch_exp_velocity
9494
if sch_exp_velocity = 1 var schwidth = 32 else schwidth = 1
9595
if (draw_checkbox(x1 + 170, y1 + 320, sch_exp_circuitry, "Export Circuitry", "Whether to export the ground, repeaters, and redstone.")) sch_exp_circuitry=!sch_exp_circuitry
96-
if (draw_checkbox(x1 + 170, y1 + 340, sch_exp_vertical, "Vertical (TO DO)", "Tick this if you want the note blocks to fade vertically.")) sch_exp_vertical=!sch_exp_vertical
9796
draw_text(x1 + 380, y1 + 240 + 16, "Size:")
9897
draw_set_halign(fa_right)
9998
draw_text(x1 + 520, y1 + 240 + 16, string(enda * 2 + 4) + "x" + string(2) + "x" + string(schwidth))
10099
draw_set_halign(fa_left)
101100
draw_text(x1 + 380, y1 + 280, "Range:")
102-
sch_exp_range_start = median(0, draw_dragvalue(19, x1 + 380, y1 + 300, sch_exp_range_start, 1), enda)
103-
sch_exp_range_end = median(0, draw_dragvalue(21, x1 + 420, y1 + 300, sch_exp_range_end, 1), enda)
101+
sch_exp_range_start = draw_inputbox(25,x1 + 380, y1 + 300,40,sch_exp_range_start,"Start Tick")
102+
sch_exp_range_end = draw_inputbox(26,x1 + 425, y1 + 300,40,sch_exp_range_end,"End Tick")
104103
draw_set_halign(fa_left)
105104
} else {
106105
if (theme = 1) {
@@ -171,9 +170,11 @@ if (draw_button2(x1 + 470, y1 + 368, 72, "Export") && wmenu = 0) {
171170
if (sch_exp_totalblocks[sch_exp_includelocked] <= 0) {
172171
message("There are no blocks to export!", "Branch export")
173172
} else if sch_exp_range_start > sch_exp_range_end {
174-
message("Starting range must be lower than ending range!", "Branch export")
173+
message("Starting tick must be lower than ending tick!", "Branch export")
175174
} else if sch_exp_range_end = 0 {
176175
message("Please enter a range!", "Branch export")
176+
} else if sch_exp_range_end > enda {
177+
message("The ending tick is larger than the song!\nThe size of the song is " + string(enda) + ".", "Branch export")
177178
}
178179
else {
179180
branch_export()

0 commit comments

Comments
 (0)