tag @a remove inControl
tag @s add inControl

tp @s ~ ~ ~ 180 46

#i like to be bold
kill @e[type=!player,tag=!nokill]

#set visual times for ranks
execute unless score #tutorial bestMoves matches 1.. run scoreboard players reset Best moveCount
execute if score #tutorial bestMoves matches 1.. run scoreboard players operation Best moveCount = #tutorial bestMoves
execute if score global math matches -12345 run scoreboard players operation You moveCount = #tutorial gameMoves
execute unless score global math matches -12345 run scoreboard players set You moveCount 0
scoreboard players set S moveCount 430
scoreboard players set A moveCount 860
scoreboard players set B moveCount 1720
scoreboard players set C moveCount 3440

scoreboard players set global char_set_x 6
scoreboard players set global char_set_y 81
scoreboard players set global char_set_z 17
scoreboard players set global char_set_face 7
scoreboard players set @s faceDirection 7

scoreboard players set global wonGame 0
scoreboard players set #tutorial wonGame 0
scoreboard players set #tutorial gameTime 0
scoreboard players set #tutorial gameMoves 0
scoreboard players set global exitEnabled 0

scoreboard players set global currentLevel 1001
scoreboard players set global puzzleSet 2
scoreboard players set global levelExitValue 1002
function bd:levels/_reload_level

#reset save data, unless continuing from previous save
execute unless score global math matches -12345 run clone 17 8 1 30 8 14 1 8 1

#puzzle-set save data exists
#DISABLED, tutorial does not save any data
#setblock 13 8 2 redstone_block

#any save data exists
setblock 2 4 18 redstone_block

execute as @a at @s run playsound minecraft:block.beacon.activate master @s ~ ~100000 ~ 1000000 1.7
tellraw @a[tag=!inControl] ["",{"selector":"@s","color":"#FFAA00"},{"text":" has started a new game!"}]
tellraw @s ["",{"text":"Started a new game!","color":"#FFAA00"}]
tellraw @a ["",{"text":"Puzzle set: ","color":"white"},{"text":"Tutorial","color":"aqua"}]

execute if score global math matches -12345 run tellraw @s ["",{"text":" > Continuing from previous save data.","color":"#33AA33","italic":true}]
execute if score global math matches -99999 run tellraw @s ["",{"text":" > Previous save data was erased.","color":"#AA3333","italic":true}]

tp @a[tag=!inControl,x=21,y=58,z=10,dx=12,dy=12,dz=12] 37 82 29 90 10