import os

scale = 12000
scaleVar = 1000

g = open("C:/Users/chris/AppData/Roaming/.minecraft/saves/Parkour With Me_new/datapacks/Recorder/data/main/functions/recorder/record.mcfunction", "w+")

for i in range(scale):
    f = open("C:/Users/chris/AppData/Roaming/.minecraft/saves/Parkour With Me_new/datapacks\Recorder/data/main/functions/recorder/setter/"+str(i)+".mcfunction", "w+")
    
    f.write("execute store result score @e[type=armor_stand,limit=1,sort=nearest, tag=Record] record_"+str(i)+"_x run data get entity @p[tag=recording] Pos[0] "+str(scaleVar)+"\n")
    f.write("execute store result score @e[type=armor_stand,limit=1,sort=nearest, tag=Record] record_"+str(i)+"_y run data get entity @p[tag=recording] Pos[1] "+str(scaleVar)+"\n")
    f.write("execute store result score @e[type=armor_stand,limit=1,sort=nearest, tag=Record] record_"+str(i)+"_z run data get entity @p[tag=recording] Pos[2] "+str(scaleVar)+"\n")
    f.write("execute store result score @e[type=armor_stand,limit=1,sort=nearest, tag=Record] record_"+str(i)+"_u run data get entity @p[tag=recording] Rotation[0] "+str(scaleVar)+"\n")
    f.write("execute store result score @e[type=armor_stand,limit=1,sort=nearest, tag=Record] record_"+str(i)+"_v run data get entity @p[tag=recording] Rotation[1] "+str(scaleVar)+"\n")
    f.write("execute if entity @p[scores={Walking=1..}] run scoreboard players set @e[type=armor_stand,limit=1,sort=nearest, tag=Record] record_"+str(i)+"_w 1\n")
    f.write("execute if entity @p[scores={Running=1..}] run scoreboard players set @e[type=armor_stand,limit=1,sort=nearest, tag=Record] record_"+str(i)+"_w 1\n")
    f.write("execute if entity @p[scores={Running=0,Walking=0}] run scoreboard players set @e[type=armor_stand, limit=1,sort=nearest, tag=Record] record_"+str(i)+"_w 0\n")
    f.write("execute if entity @p[scores={Hit=1..}] run scoreboard players set @e[type=armor_stand, limit=1,sort=nearest, tag=Record] record_"+str(i)+"_h 1\n")
    f.write("execute if entity @p[scores={Hit=0}] run scoreboard players set @e[type=armor_stand, limit=1,sort=nearest, tag=Record] record_"+str(i)+"_h 0\n")

    f.close()

    g.write("execute if entity @a[scores={record_step="+str(i)+"}] run function main:recorder/setter/"+str(i)+"\n")


g.write("execute as @a[scores={record_step=-1},tag=recording] at @s run summon minecraft:armor_stand ~ ~ ~ {Invisible:1,CustomName:\"\\\"RecordArmorStand\\\"\",NoGravity:1,ShowArm:1,Tags:[\"Record\"],DisabledSlots:2039583}\n")
g.write("execute as @a[scores={record_step=-1},tag=recording] at @s run scoreboard players set @e[type=armor_stand,distance=..1,name=\"RecordArmorStand\"] record_sequence 0\n")
g.write("scoreboard players add @a[tag=recording] record_step 1\n")
g.write("scoreboard players set @a[tag=recording] Walking 0\n")
g.write("scoreboard players set @a[tag=recording] Running 0\n")
g.write("scoreboard players set @a[tag=recording] Hit 0\n")
g.write("execute if entity @a[scores={record_step="+str(scale)+"},tag=recording] run function main:recorder/stop\n")

g.close()
    
    
            
