execute if score @s left.hold matches 1.. as @n[type=item_display,tag=note.left] run function funkalot:notesystem/playnote {key:left}
execute if score @s down.hold matches 1.. as @n[type=item_display,tag=note.down] run function funkalot:notesystem/playnote {key:down}
execute if score @s space.hold matches 1.. as @n[type=item_display,tag=note.space] run function funkalot:notesystem/playnote {key:space}
execute if score @s up.hold matches 1.. as @n[type=item_display,tag=note.up] run function funkalot:notesystem/playnote {key:up}
execute if score @s right.hold matches 1.. as @n[type=item_display,tag=note.right] run function funkalot:notesystem/playnote {key:right}
execute if score @s left.hold matches 0 run data merge entity @n[type=item_display,tag=note.left] {start_interpolation:0,transformation:{translation:[0.0f,0.5f,0.0f]},item:{id:"minecraft:stone",count:1,components:{"minecraft:item_model":"funkalot:input/left"}}}
execute if score @s down.hold matches 0 run data merge entity @n[type=item_display,tag=note.down] {start_interpolation:0,transformation:{translation:[0.0f,0.5f,0.0f]},item:{id:"minecraft:stone",count:1,components:{"minecraft:item_model":"funkalot:input/down"}}}
execute if score @s space.hold matches 0 run data merge entity @n[type=item_display,tag=note.space] {start_interpolation:0,transformation:{translation:[0.0f,0.5f,0.0f]},item:{id:"minecraft:stone",count:1,components:{"minecraft:item_model":"funkalot:input/space"}}}
execute if score @s up.hold matches 0 run data merge entity @n[type=item_display,tag=note.up] {start_interpolation:0,transformation:{translation:[0.0f,0.5f,0.0f]},item:{id:"minecraft:stone",count:1,components:{"minecraft:item_model":"funkalot:input/up"}}}
execute if score @s right.hold matches 0 run data merge entity @n[type=item_display,tag=note.right] {start_interpolation:0,transformation:{translation:[0.0f,0.5f,0.0f]},item:{id:"minecraft:stone",count:1,components:{"minecraft:item_model":"funkalot:input/right"}}}

function funkalot:notesystem/process/health
function funkalot:notesystem/process/score

execute if score @s health matches ..0 run function funkalot:lost/lose

function funkalot:notesystem/checkend with storage funkalot:current song

execute store result storage funkalot:current song.timeline int 1 run scoreboard players add @s timeline 1
execute if score @s timeline matches -76 run function funkalot:notesystem/appear
execute if score @s timeline matches -71 run function funkalot:notesystem/help
execute if score @s timeline matches -60 run title @s title "3"
execute as @s[scores={timeline=-60}] at @s run playsound minecraft:ui.button.click ui @a[tag=playing] ~ ~ ~ 0.5 1.2
execute if score @s timeline matches -40 run title @s title "2"
execute as @s[scores={timeline=-40}] at @s run playsound minecraft:ui.button.click ui @a[tag=playing] ~ ~ ~ 0.5 1.2
execute if score @s timeline matches -20 run title @s title "1"
execute as @s[scores={timeline=-20}] at @s run playsound minecraft:ui.button.click ui @a[tag=playing] ~ ~ ~ 0.5 1.2
execute if score @s timeline matches -10 as @e[tag=help,type=text_display] run function funkalot:notesystem/help.close
execute if score @s timeline matches 0 run title @s title " "
execute if score @s timeline matches 0 run function funkalot:playsong with storage funkalot:current song

execute as @e[tag=help,scores={score.appear=1}] run function funkalot:notesystem/help.close
scoreboard players remove @e[tag=help,scores={score.appear=1..}] score.appear 1

execute if entity @s[tag=record] run return run function funkalot:recording with storage funkalot:current song

execute store result storage funkalot:current song.spawnpos double 0.01 run data get storage funkalot:current song.blockspertick 8000
function funkalot:notesystem/checknote with storage funkalot:current song