11// branch_export()
2- var a, b, c, d, o
2+ var a, b, c, o
33var fn = string(get_save_filename_ext(" Minecraft Schematics (*.schematic)|*.schematic" , filename_new_ext(filename, " " ), " " , " Export Branch Schematic" ))
44if (fn = " " ) return 0
55o = obj_controller
@@ -80,7 +80,7 @@ for (a = 0; a < sch_exp_polyphony; a ++) {
8080 nblockins[a, ticks] = 0
8181 nblockvel[a, ticks] = 0
8282 }
83- show_debug_message (" WROTE nblocknote" + string (a) + " ," + string (ticks) + " val " + string (nblocknote[a, ticks]))
83+ // show_debug_message("WROTE nblocknote" + string(a) + "," + string(ticks) + " val " + string(nblocknote[a, ticks]))
8484 ticks ++
8585 }
8686}
@@ -107,68 +107,72 @@ for (a = 0; a < sch_exp_polyphony; a ++) { // layer count
107107 noteblockzvel[a, c] = zvel
108108 noteblockxpos[a, c] = xpos
109109 if sch_exp_circuitry = 1 {
110+ if sch_exp_polyphony != 3 {
110111 schematic_fill (mySchematic, lineloc, b, 0 , zvel, b, 0 , sch_exp_circuit_block, sch_exp_circuit_data) // Connects a redstone line to the block
111112 schematic_fill (mySchematic, lineloc + -direc, b, 1 , zvel, b, 1 , 55 , 0 )
113+ } else
114+ schematic_fill (mySchematic, lineloc, b, 0 , noteblockzvel[0 , c], b, 0 , sch_exp_circuit_block, sch_exp_circuit_data) // Connects a redstone line to the block
115+ schematic_fill (mySchematic, lineloc + -direc, b, 1 , noteblockzvel[0 , c], b, 1 , 55 , 0 )
112116 }
113117 }
114118 }
115119 b += 2
116120 }
117121}
118122
119- if sch_exp_velocity = 1 {
123+ if sch_exp_velocity = 1 { // When polyphony is 1 or 2, make velocity independent.
120124 for (a = 0 ; a < sch_exp_polyphony; a ++) {
121125 b = 1
122126 if a = 0 offset = 0 if a = 1 offset = 1 if a = 2 offset = -1
123127 for (c = 0 ; c < range_len; c ++) {
124128 if nblocknote[a, c] != 0 { // if note in array exists on this tick
125129 xpos = range_len * 2 - b // invert x coordinates (b) for NBT data only
126130 var freespace = 0
127- if sch_exp_polyphony > 1 { // Various checks if note blocks conflict.
128- var layer_correction = 0
129- for (d = 0 ; d < sch_exp_polyphony; d ++) { // Check if note blocks in current tick are at different Z pos.
130- var f = noteblockzvel[d, c]
131- for (var i = 1 ; i < sch_exp_polyphony; i++) {
132- if noteblockzvel[i, c] != f { // Adds some redstone next to the noteblock if the velocity is different
133- schematic_cell_set (mySchematic, noteblockzvel[i, c], b, 1 , sch_exp_circuit_block, sch_exp_circuit_data)
134- schematic_cell_set (mySchematic, noteblockzvel[i, c], b, 2 , 55 , 0 )
135- if noteblockzvel[0 , c] > lineloc && noteblockzvel[0 , c] < max (noteblockzvel[1 , c], noteblockzvel[i, c]) layer_correction = 1
136- else if noteblockzvel[0 , c] < lineloc && noteblockzvel[0 , c] > min (noteblockzvel[1 , c], noteblockzvel[i, c]) layer_correction = 1
137- }
138- }
139- }
140- if layer_correction = 1 { // Alter layer 0's position and add connecting redstone.
141- /* if noteblockzvel[0, c] = noteblockzvel[1, c] { // If layer 1 noteblock is blocking layer 0
142- if noteblockzvel[0, c] = noteblockzvel[1, c - 1] { // If the previous tick's layer 1 is not behind layer 0.
143- freespace --
144- } else { // shift the note block over
145- noteblockzvel[0, c] ++
146- freespace ++
147- }
148- } else */ freespace ++
149- schematic_cell_set (mySchematic, noteblockzvel[0 , c], b, 1 , sch_exp_circuit_block, sch_exp_circuit_data)
150- schematic_cell_set (mySchematic, noteblockzvel[0 , c], b, 2 , 55 , 0 )
151- schematic_cell_set (mySchematic, noteblockzvel[0 , c], b + freespace, 1 , 25 , 0 )
152- schematic_cell_set (mySchematic, noteblockzvel[0 , c], b + freespace, 0 , sch_exp_ins_block[nblockins[a, c]], 0 )
153- noteblockx[0 , c] = noteblockxpos[0 , c] - freespace
154- noteblocky[0 , c] = 1
155- noteblockz[0 , c] = noteblockzvel[0 , c]
156- layer_correction_0 = 0
157- freespace = 0
158- }
131+ if sch_exp_polyphony = 2 { // Various checks if note blocks conflict.
132+ var layer_correction = 0
133+ if noteblockzvel[0 , c] != noteblockzvel[1 , c] { // Adds some redstone next to the noteblock if the velocity is different
134+ schematic_cell_set (mySchematic, noteblockzvel[1 , c], b, 1 , sch_exp_circuit_block, sch_exp_circuit_data)
135+ schematic_cell_set (mySchematic, noteblockzvel[1 , c], b, 2 , 55 , 0 )
136+ if noteblockzvel[0 , c] > lineloc && noteblockzvel[0 , c] < noteblockzvel[1 , c] layer_correction = 1
137+ else if noteblockzvel[0 , c] < lineloc && noteblockzvel[0 , c] > noteblockzvel[1 , c] layer_correction = 1
138+ }
139+ if layer_correction = 1 { // Alter layer 0's position and add connecting redstone.
140+ freespace ++
141+ schematic_cell_set (mySchematic, noteblockzvel[0 , c], b, 1 , sch_exp_circuit_block, sch_exp_circuit_data)
142+ schematic_cell_set (mySchematic, noteblockzvel[0 , c], b, 2 , 55 , 0 )
143+ schematic_cell_set (mySchematic, noteblockzvel[0 , c], b + freespace, 1 , 25 , 0 )
144+ schematic_cell_set (mySchematic, noteblockzvel[0 , c], b + freespace, 0 , sch_exp_ins_block[nblockins[a, c]], 0 )
145+ noteblockx[0 , c] = noteblockxpos[0 , c] - freespace
146+ layer_correction = 0
147+ freespace = 0
159148 }
149+ }
150+ if sch_exp_polyphony != 3 {
160151 schematic_cell_set (mySchematic, noteblockzvel[a, c], b + offset, 1 , 25 , 0 )
161152 schematic_cell_set (mySchematic, noteblockzvel[a, c], b + offset, 0 , sch_exp_ins_block[nblockins[a, c]], 0 )
162153 noteblockx[a, c] = noteblockxpos[a, c] - offset
163154 noteblocky[a, c] = 1
164155 noteblockz[a, c] = noteblockzvel[a, c]
156+ }
157+ if sch_exp_polyphony = 3 { // if polyphony = 3 then base all velocity values off layer 0.
158+ if a = 1 var fix = 1 else fix = 0
159+ var shiftblock = 0
160+ if a = 2 {
161+ if noteblockzvel[0 , c] > 17 shiftblock = 1 else shiftblock = -1
162+ fix = 0
163+ }
164+ schematic_cell_set (mySchematic, noteblockzvel[0 , c] + shiftblock, b + fix, 1 , 25 , 0 )
165+ schematic_cell_set (mySchematic, noteblockzvel[0 , c] + shiftblock, b + fix, 0 , sch_exp_ins_block[nblockins[a, c]], 0 )
166+ noteblockx[a, c] = noteblockxpos[0 , c] - fix
167+ noteblocky[a, c] = 1
168+ noteblockz[a, c] = noteblockzvel[0 , c] + shiftblock
169+ }
165170 }
166171 b += 2
167172 }
168173 }
169174}
170175
171- show_debug_message (" total note blocks = " + string(sch_exp_totalnoteblocks))
172176schematic_save (mySchematic, fn);
173177schematic_destroy (mySchematic);
174178schematic_end ();
0 commit comments