execute as @a if entity @s[x=50,dx=10,y=10,dy=10,z=50,dz=10] run tp @s 16.0 21 16.0 0 90
tag @a remove MainPlayer
execute as @a[limit=1,sort=arbitrary] run tag @s add MainPlayer
execute as @a[tag=!MainPlayer] if data entity @s Inventory[0] run clear @s
execute if score TutorialScene Game <= 4 Integer as @a[tag=MainPlayer] if data entity @s Inventory[1] run clear @s
execute if score TutorialScene Game > 4 Integer as @a[tag=MainPlayer] if data entity @s Inventory[2] run clear @s
execute if score TutorialScene Game <= 4 Integer as @a[tag=MainPlayer] run item replace entity @s hotbar.8 with carrot_on_a_stick{display:{Name:'{"text":"Next","italic":false}'},CustomModelData:0}
execute if score TutorialScene Game = 5 Integer as @a[tag=MainPlayer] run item replace entity @s hotbar.0 with carrot_on_a_stick{display:{Name:'{"text":"Kill Cell","italic":false,"color":"#FFFF80"}'},CustomModelData:1}
execute if score TutorialScene Game > 5 Integer as @a[tag=MainPlayer] run item replace entity @s hotbar.0 with carrot_on_a_stick{display:{Name:'{"text":"Kill/Birth Cell","italic":false,"color":"#FFFF80"}'},CustomModelData:1}
execute if score TutorialScene Game > 4 Integer if score MayEndTurn Game = 0 Integer as @a[tag=MainPlayer] run item replace entity @s hotbar.1 with minecraft:glass{display:{Name:'{"text":"Can\'t End Turn","italic":false,"color":"red"}'}}
execute if score TutorialScene Game > 4 Integer if score MayEndTurn Game = 1 Integer as @a[tag=MainPlayer] run item replace entity @s hotbar.1 with carrot_on_a_stick{display:{Name:'{"text":"End Turn","italic":false,"color":"red"}'},CustomModelData:0}
execute if score TutorialScene Game = 0 Integer run title @a actionbar [{"text":"How to play the "},{"text":"Game of Life and Death","bold":true}]
execute if score TutorialScene Game = 1 Integer run title @a actionbar [{"text":"Cells die unless they have "},{"text":"exactly 2","bold":true},{"text":" or "},{"text":"3","bold":true},{"text":" neighbors"}]
execute if score TutorialScene Game = 2 Integer run title @a actionbar [{"text":"Dead cells become alive if they have "},{"text":"exactly 3","bold":true},{"text":" neighbors"}]
execute if score TutorialScene Game = 3 Integer if score RenderTimer Timer = 30 Integer run function main:clearboard
execute if score TutorialScene Game = 3 Integer if score RenderTimer Timer = 30 Integer run tag @e[tag=Tutorial2Blue] add Alive
execute if score TutorialScene Game = 3 Integer if score RenderTimer Timer = 30 Integer run tag @e[tag=Tutorial2Red] add Alive
execute if score TutorialScene Game = 3 Integer if score RenderTimer Timer = 30 Integer run tag @e[tag=Tutorial2Red] add Red
execute if score TutorialScene Game = 3 Integer if score RenderTimer Timer = 30 Integer run function main:updateboard
execute if score TutorialScene Game = 3 Integer if score RenderTimer Timer > 30 Integer run title @a actionbar [{"text":"Born cells take the color of the majority of their \"parents\""}]
execute if score TutorialScene Game = 4 Integer if score RenderTimer Timer = 30 Integer run function main:clearboard
execute if score TutorialScene Game = 4 Integer if score RenderTimer Timer = 30 Integer run tag @e[tag=Tutorial3Blue] add Alive
execute if score TutorialScene Game = 4 Integer if score RenderTimer Timer = 30 Integer run tag @e[tag=Tutorial3Red] add Alive
execute if score TutorialScene Game = 4 Integer if score RenderTimer Timer = 30 Integer run tag @e[tag=Tutorial3Red] add Red
execute if score TutorialScene Game = 4 Integer if score RenderTimer Timer = 30 Integer run function main:updateboard
execute if score TutorialScene Game = 4 Integer if score RenderTimer Timer = 30 Integer run scoreboard players add TutorialScene Game 1
execute if score TutorialScene Game = 5 Integer if score BLUE Game > 0 Integer run title @a actionbar [{"text":"Kill all the red cells to continue"}]
execute if score TutorialScene Game = 5 Integer if score BLUE Game = 0 Integer run title @a actionbar [{"text":"Kill all the "},{"text":"RED","bold":true,"color":"red"},{"text":" cells to continue"}]
execute if score TutorialScene Game = 5 Integer if score RenderTimer Timer = 8 Integer run scoreboard players set RSQ Game 0
execute if score TutorialScene Game = 5 Integer if score RenderTimer Timer = 8 Integer run function main:hasredsquare
execute if score TutorialScene Game = 5 Integer if score RenderTimer Timer = 8 Integer if score RSQ Game = 1 Integer run function main:clearboard
execute if score TutorialScene Game = 5 Integer if score RenderTimer Timer = 8 Integer if score RSQ Game = 1 Integer run tag @e[tag=Tutorial3Blue] add Alive
execute if score TutorialScene Game = 5 Integer if score RenderTimer Timer = 8 Integer if score RSQ Game = 1 Integer run tag @e[tag=Tutorial3Red] add Alive
execute if score TutorialScene Game = 5 Integer if score RenderTimer Timer = 8 Integer if score RSQ Game = 1 Integer run tag @e[tag=Tutorial3Red] add Red
execute if score TutorialScene Game = 5 Integer if score RenderTimer Timer = 8 Integer if score RSQ Game = 1 Integer run function main:updateboard
execute if score TutorialScene Game = 5 Integer if score RED Game = 0 Integer if score RenderTimer Timer = 8 Integer run function main:clearboard
execute if score TutorialScene Game = 5 Integer if score RED Game = 0 Integer if score RenderTimer Timer = 8 Integer run tag @e[tag=Tutorial4Blue] add Alive
execute if score TutorialScene Game = 5 Integer if score RED Game = 0 Integer if score RenderTimer Timer = 8 Integer run tag @e[tag=Tutorial4Red] add Alive
execute if score TutorialScene Game = 5 Integer if score RED Game = 0 Integer if score RenderTimer Timer = 8 Integer run tag @e[tag=Tutorial4Red] add Red
execute if score TutorialScene Game = 5 Integer if score RED Game = 0 Integer if score RenderTimer Timer = 8 Integer run scoreboard players add TutorialScene Game 1
execute if score TutorialScene Game = 6 Integer if score RED Game = 0 Integer if score RenderTimer Timer = 8 Integer run function main:updateboard
execute if score TutorialScene Game = 6 Integer if score RenderTimer Timer = 30 Integer run scoreboard players add TutorialScene Game 1
execute if score TutorialScene Game = 6 Integer run scoreboard players set Hint Game 0
execute if score TutorialScene Game = 7 Integer unless score Hint Game = 1 Integer run title @a actionbar [{"text":"You can birth a cell by sacrificing two own cells. Kill all the red cells to continue"}]
execute if score TutorialScene Game = 7 Integer if score Hint Game = 1 Integer run title @a actionbar [{"text":"Kill all the red cells to continue. Hint: Sacrifice one cell of each blue square"}]
execute if score TutorialScene Game = 7 Integer if score BLUE Game < 8 Integer if score RenderTimer Timer = 8 Integer run function main:clearboard
execute if score TutorialScene Game = 7 Integer if score BLUE Game < 8 Integer if score RenderTimer Timer = 8 Integer run tag @e[tag=Tutorial4Blue] add Alive
execute if score TutorialScene Game = 7 Integer if score BLUE Game < 8 Integer if score RenderTimer Timer = 8 Integer run tag @e[tag=Tutorial4Red] add Alive
execute if score TutorialScene Game = 7 Integer if score BLUE Game < 8 Integer if score RenderTimer Timer = 8 Integer run tag @e[tag=Tutorial4Red] add Red
execute if score TutorialScene Game = 7 Integer if score BLUE Game < 8 Integer if score RenderTimer Timer = 8 Integer run scoreboard players set Hint Game 1
execute if score TutorialScene Game = 7 Integer if score BLUE Game < 8 Integer if score RenderTimer Timer = 8 Integer run function main:updateboard
execute if score TutorialScene Game = 7 Integer if score RED Game = 0 Integer if score RenderTimer Timer = 30 Integer run scoreboard players set TutorialScene Game -2
execute if score TutorialScene Game = -2 Integer run title @a actionbar [{"text":"Turns alternate between blue and red (depending on the Turn Order setting)"}]
execute if score TutorialScene Game = -1 Integer run title @a actionbar [{"text":"Whoever wipes out the other color first is the winner!"}]