Skip to content

Commit

Permalink
misc: Allow importing Musescore 4 files
Browse files Browse the repository at this point in the history
  • Loading branch information
IoeCmcomc committed Feb 16, 2023
1 parent 29f39e1 commit f217b11
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,7 @@ def makeFolderTree(inp, a=[]):
"""execute as @e[type=armor_stand, tag=WNBS_Marker, name=\"{inst}-{order}\"] at @s positioned ~ ~-1 ~ if block ~ ~ ~ minecraft:note_block[instrument={instname}] run setblock ~ ~ ~ minecraft:note_block[instrument={instname},note={key}] replace
execute as @e[type=armor_stand, tag=WNBS_Marker, name=\"{inst}-{order}\"] at @s positioned ~ ~-1 ~ if block ~ ~ ~ minecraft:note_block[instrument={instname}] run fill ^ ^ ^-1 ^ ^ ^-1 minecraft:redstone_block replace minecraft:air
execute as @e[type=armor_stand, tag=WNBS_Marker, name=\"{inst}-{order}\"] at @s positioned ~ ~-1 ~ if block ~ ~ ~ minecraft:note_block[instrument={instname}] run fill ^ ^ ^-1 ^ ^ ^-1 minecraft:air replace minecraft:redstone_block
""".format(obj=scoreObj, tick=tick, inst=note.inst, order=instLayers[note['inst']].index(note['layer']), instname=instruments[note.inst].sound_id, key=max(33, min(57, note.key)) - 33)
""".format(obj=scoreObj, tick=tick, inst=note.inst, order=instLayers[note.inst].index(note.layer), instname=instruments[note.inst].sound_id, key=max(33, min(57, note.key)) - 33)
if tick < length-1:
text += "scoreboard players set @s {}_t {}".format(
scoreObj, tick)
Expand Down Expand Up @@ -1349,30 +1349,30 @@ def makeFolderTree(inp, a=[]):
try:
if len(colNotes[min1]) > 0:
text += "execute as @s[scores={{{0}={1}..{2}, {0}_t=..{3}}}] run function {4}:notes/{5}\n".format(
scoreObj, min1*80, (max1+1)*80+40, min1-1, bname, min1)
scoreObj, min1*80, (max1+1)*80+160, min1-1, bname, min1)
except KeyError:
break
pass
if min2 <= length:
try:
if len(colNotes[min2]) > 0:
text += "execute as @s[scores={{{0}={1}..{2}, {0}_t=..{3}}}] run function {4}:notes/{5}".format(
scoreObj, min2*80, (max2+1)*80+40, min2-1, bname, min2)
scoreObj, min2*80, (max2+1)*80+160, min2-1, bname, min2)
except KeyError:
break
pass
else: # Don't play yet, refine the search
for i in range(min1, min(max1, length)+1):
try:
if len(colNotes[i]) > 0:
text += "execute as @s[scores={{{}={}..{}}}] run function {}:tree/{}_{}\n".format(
scoreObj, min1*80, (max1+1)*80+40, bname, min1, max1)
scoreObj, min1*80, (max1+1)*80+160, bname, min1, max1)
break
except KeyError:
break
for i in range(min2, min(max2, length)+1):
try:
if len(colNotes[i]) > 0:
text += "execute as @s[scores={{{}={}..{}}}] run function {}:tree/{}_{}".format(
scoreObj, min2*80, (max2+2)*80+40, bname, min2, max2)
scoreObj, min2*80, (max2+2)*80+160, bname, min2, max2)
break
except KeyError:
break
Expand Down
2 changes: 1 addition & 1 deletion musescore2nbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ async def musescore2nbs(filepath: str, expandMultiplier=1, autoExpand=True, dial
raise FileError("This file isn't a MuseScore file")

if version := xml.findtext('programVersion'):
if not version.startswith('3'):
if not (version.startswith('3') or version.startswith('4')):
raise NotImplementedError("This file is created by a older version of MuseScore. Please use MuseScore 3 to re-save the files before importing.")

nbs: NbsSong = NbsSong()
Expand Down

0 comments on commit f217b11

Please sign in to comment.