# © Spark Universe, 2023
# authors: destruc7i0n
# description: p5 pet taming loop
# called by: 

scoreboard players add @s[scores={tut_timer=..60}] tut_timer 1
scoreboard players add @s[scores={tut_timer=100..}] tut_timer 1

execute if score @s tut_timer matches 1 run tp @p[tag=instance_player] ~ ~ ~ 0 0

execute if score @s tut_timer matches 60 run function spark/tutorial/p5/spawn_pets
execute if score @s tut_timer matches 60 run scoreboard players set @p[tag=instance_player] SS_ui_tutorial 6
# execute if score @s tut_timer matches 60 run playsound mob.villager.haggle @p[tag=instance_player]

execute if score @s tut_timer matches 61 if entity @p[tag=instance_player,tag=tamer] run scoreboard players set @s tut_timer 100

# handle when player tames a pet
execute if entity @p[tag=instance_player,tag=tamer] as @e[tag=tutorial_pet] at @s if score @s tut = .tut_player_id player_id run function spark/tutorial/p5/on_pet_chosen

execute if score @s tut_timer matches 100 run scoreboard players set @p[tag=instance_player] SS_ui_tutorial 0

execute if score @s tut_timer matches 140 run function spark/tutorial/p5/next
