# Light Switch
execute as @e[tag=interaction,name=light_switch_bathroom] if data entity @s interaction run execute as @e[tag=bathroom,name=light_switch,nbt={item:{id:"minecraft:coal",Count:1b,tag:{CustomModelData:65}}}] at @s run function slender:scripts/interactions/light_switch/bathroom_on

execute as @e[tag=interaction,name=light_switch_bathroom] if data entity @s interaction run execute as @e[tag=bathroom,name=light_switch,nbt={item:{id:"minecraft:coal",Count:1b,tag:{CustomModelData:64}}}] at @s run function slender:scripts/interactions/light_switch/bathroom_off

execute as @e[tag=interaction,name=light_switch_bedroom] if data entity @s interaction run execute as @e[tag=bedroom,name=light_switch,nbt={item:{id:"minecraft:coal",Count:1b,tag:{CustomModelData:65}}}] at @s run function slender:scripts/interactions/light_switch/bedroom_on
execute as @e[tag=interaction,name=light_switch_bedroom] if data entity @s interaction run execute as @e[tag=bedroom,name=light_switch,nbt={item:{id:"minecraft:coal",Count:1b,tag:{CustomModelData:64}}}] at @s run function slender:scripts/interactions/light_switch/bedroom_off

execute as @e[tag=interaction,name=light_switch_hallway] if data entity @s interaction run execute as @e[tag=hallway,name=light_switch,nbt={item:{id:"minecraft:coal",Count:1b,tag:{CustomModelData:65}}}] at @s run function slender:scripts/interactions/light_switch/hallway_on
execute as @e[tag=interaction,name=light_switch_hallway] if data entity @s interaction run execute as @e[tag=hallway,name=light_switch,nbt={item:{id:"minecraft:coal",Count:1b,tag:{CustomModelData:64}}}] at @s run function slender:scripts/interactions/light_switch/hallway_off

execute as @e[tag=interaction,name=light_switch_kitchen] if data entity @s interaction run execute as @e[tag=kitchen,name=light_switch,nbt={item:{id:"minecraft:coal",Count:1b,tag:{CustomModelData:65}}}] at @s run function slender:scripts/interactions/light_switch/kitchen_on
execute as @e[tag=interaction,name=light_switch_kitchen] if data entity @s interaction run execute as @e[tag=kitchen,name=light_switch,nbt={item:{id:"minecraft:coal",Count:1b,tag:{CustomModelData:64}}}] at @s run function slender:scripts/interactions/light_switch/kitchen_off

execute as @e[tag=light_switch_blocked,type=interaction] if data entity @s interaction run function slender:scripts/interactions/first_dress


# Elevator Button
execute at @p if entity @e[type=interaction,tag=elevator_button,distance=..2] if score el_button_allow map matches 1 if score interact_elevator info matches 1 run title @a actionbar ["",{"text":"[Right Click]","bold":true,"color":"green"},{"text":" to call the elevator"}]
execute at @p if entity @e[type=interaction,tag=elevator_button,distance=2..2.2] if score el_button_allow map matches 1 if score interact_elevator info matches 1 run title @a actionbar ""
execute as @e[type=interaction,tag=elevator_button,name=lobby] if score el_button_allow map matches 1 if data entity @s interaction run function slender:scripts/interactions/elevator/lobby
execute as @e[type=interaction,tag=elevator_button,name=1] if score el_button_allow map matches 1 if data entity @s interaction run function slender:scripts/interactions/elevator/elevator1


# Fuse Panel

execute if score fuse_section scenes matches 50 if score obj_fuse map matches 3 as @e[type=interaction,tag=fuse_panel] if data entity @s interaction run function slender:scripts/interactions/fuse_panel
execute if score fuse_section scenes matches 50 if score obj_fuse map matches 3 at @p if entity @e[type=interaction,tag=fuse_panel,distance=..2] run title @a actionbar ["",{"text":"[Right Click]","bold":true,"color":"green"},{"text":" to put into Fuse Box"}]
execute if score fuse_section scenes matches 50 if score obj_fuse map matches 3 at @p if entity @e[type=interaction,tag=fuse_panel,distance=2..2.2] run title @a actionbar ""

# Vents

execute at @p if entity @e[type=interaction,tag=vent1,distance=..2] run title @a actionbar ["",{"text":"[Right Click]","bold":true,"color":"green"},{"text":" to enter the vent"}]
execute at @p if entity @e[type=interaction,tag=vent3,distance=..2] run title @a actionbar ["",{"text":"[Right Click]","bold":true,"color":"green"},{"text":" to enter the vent"}]
execute at @p if entity @e[type=interaction,tag=vent6,distance=..2] run title @a actionbar ["",{"text":"[Right Click]","bold":true,"color":"green"},{"text":" to enter the vent"}]

execute at @p if entity @e[type=interaction,tag=vent2,distance=..1] run title @a actionbar ["",{"text":"[Right Click]","bold":true,"color":"green"},{"text":" to exit the vent"}]
execute at @p if entity @e[type=interaction,tag=vent4,distance=..1] run title @a actionbar ["",{"text":"[Right Click]","bold":true,"color":"green"},{"text":" to exit the vent"}]
execute at @p if entity @e[type=interaction,tag=vent5,distance=..1] run title @a actionbar ["",{"text":"[Right Click]","bold":true,"color":"green"},{"text":" to exit the vent"}]

execute at @p if entity @e[type=interaction,tag=vent1,distance=2..2.2] run title @a actionbar ""
execute at @p if entity @e[type=interaction,tag=vent2,distance=1..1.2] run title @a actionbar ""
execute at @p if entity @e[type=interaction,tag=vent3,distance=2..2.2] run title @a actionbar ""
execute at @p if entity @e[type=interaction,tag=vent4,distance=1..1.2] run title @a actionbar ""
execute at @p if entity @e[type=interaction,tag=vent5,distance=1..1.2] run title @a actionbar ""
execute at @p if entity @e[type=interaction,tag=vent6,distance=2..2.2] run title @a actionbar ""

execute at @p if entity @e[type=interaction,tag=vent1,distance=..2] as @e[type=interaction,tag=vent1] if data entity @s interaction run function slender:scripts/interactions/vent1
execute at @p if entity @e[type=interaction,tag=vent2,distance=..1] as @e[type=interaction,tag=vent2] if data entity @s interaction run function slender:scripts/interactions/vent2
execute at @p if entity @e[type=interaction,tag=vent3,distance=..2] as @e[type=interaction,tag=vent3] if data entity @s interaction run function slender:scripts/interactions/vent3
execute at @p if entity @e[type=interaction,tag=vent4,distance=..1] as @e[type=interaction,tag=vent4] if data entity @s interaction run function slender:scripts/interactions/vent4
execute at @p if entity @e[type=interaction,tag=vent5,distance=..1] as @e[type=interaction,tag=vent5] if data entity @s interaction run function slender:scripts/interactions/vent5
execute at @p if entity @e[type=interaction,tag=vent6,distance=..2] as @e[type=interaction,tag=vent6] if data entity @s interaction run function slender:scripts/interactions/vent6

# Vent Open with hammer
execute at @p if entity @e[type=interaction,tag=vent_open,distance=..3] if score hammer info matches 2 run title @a actionbar ["",{"text":"[Right Click]","bold":true,"color":"green"},{"text":" to break the vent"}]
execute as @e[type=interaction,tag=vent_open] if data entity @s interaction if score hammer info matches 2 run scoreboard players set vent_breaking map 50

execute as @e[type=interaction,tag=vent_open] if data entity @s interaction if score hammer info matches 0 run title @a actionbar [{"text":"I need something to break this open"}]


# Notebook (Chat)

execute at @p if entity @e[type=interaction,tag=notebook,distance=..2] if score interact_notebook info matches 1 run title @a actionbar ["",{"text":"[Right Click]","bold":true,"color":"green"},{"text":" to view the conversation"}]
execute at @p if entity @e[type=interaction,tag=notebook,distance=2..2.2] if score interact_notebook info matches 1 run title @a actionbar ""

execute as @e[type=interaction,tag=notebook] if data entity @s interaction if score interact_notebook info matches 1 run function slender:scripts/interactions/notebook

# Vending Machine

execute at @p if entity @e[type=interaction,tag=vending_machine1,distance=..2] if score interact_machine info matches 1 run title @a actionbar ["",{"text":"[Right Click]","bold":true,"color":"green"},{"text":" to drop coins into it"}]
execute at @p if entity @e[type=interaction,tag=vending_machine1,distance=2..2.2] if score interact_machine info matches 1 run title @a actionbar ""

execute at @p if entity @e[type=interaction,tag=vending_machine1,distance=..2] if score interact_machine info matches 2 run title @a actionbar ["",{"text":"[Right Click]","bold":true,"color":"green"},{"text":" pick the snack"}]
execute at @p if entity @e[type=interaction,tag=vending_machine1,distance=2..2.2] if score interact_machine info matches 2 run title @a actionbar ""

execute as @e[type=interaction,tag=vending_machine1] if data entity @s interaction run function slender:scripts/interactions/vending_machine

# Collectibles
    # Fuse
    execute as @e[type=interaction,tag=fuse1] if data entity @s interaction if score obj_fuse map matches 0..3 run function slender:scripts/interactions/collects/fuse1
    execute as @e[type=interaction,tag=fuse2] if data entity @s interaction if score obj_fuse map matches 0..3 run function slender:scripts/interactions/collects/fuse2
    execute as @e[type=interaction,tag=fuse3] if data entity @s interaction if score obj_fuse map matches 0..3 run function slender:scripts/interactions/collects/fuse3

    #Keys
    execute as @e[type=interaction,tag=key1] if data entity @s interaction run function slender:scripts/interactions/collects/key1
    execute as @e[type=interaction,tag=key2] if data entity @s interaction run function slender:scripts/interactions/collects/key2
    execute as @e[type=interaction,tag=key3] if data entity @s interaction run function slender:scripts/interactions/collects/key3

    #Hammer
    execute as @e[type=interaction,tag=hammer] if data entity @s interaction run function slender:scripts/interactions/collects/hammer


# Doors
    #Locked and Jammed
    execute as @e[type=interaction,tag=door_locked] if data entity @s interaction run function slender:scripts/interactions/door/door_locked
    execute as @e[type=interaction,tag=door_jammed] if data entity @s interaction run function slender:scripts/interactions/door/door_jammed
    execute as @e[type=interaction,tag=door_blocked2] if data entity @s interaction run function slender:scripts/interactions/door/door_locked
    execute as @e[type=interaction,tag=door_jammed2] if data entity @s interaction run function slender:scripts/interactions/door/door_jammed

    execute as @e[type=interaction,tag=door_unlockable1] if data entity @s interaction if score key1 info matches 0 run function slender:scripts/interactions/door/door_locked
    execute as @e[type=interaction,tag=door_unlockable2] if data entity @s interaction if score key2 info matches 0 run function slender:scripts/interactions/door/door_locked
    execute as @e[type=interaction,tag=door_unlockable3] if data entity @s interaction if score key3 info matches 0 run function slender:scripts/interactions/door/door_locked

    #Blocked door before wearing the suit
    execute as @e[type=interaction,tag=door_blocked1] if data entity @s interaction run function slender:scripts/interactions/first_dress
    

    #Unlock the door

    execute at @p if entity @e[type=interaction,tag=door_unlockable1,distance=..2] if score key1 info matches 1 run title @a actionbar ["",{"text":"[Right Click]","bold":true,"color":"green"},{"text":" to unlock the door"}]
    execute at @p if entity @e[type=interaction,tag=door_unlockable2,distance=..2] if score key2 info matches 1 run title @a actionbar ["",{"text":"[Right Click]","bold":true,"color":"green"},{"text":" to unlock the door"}]
    execute at @p if entity @e[type=interaction,tag=door_unlockable3,distance=..2] if score key3 info matches 1 run title @a actionbar ["",{"text":"[Right Click]","bold":true,"color":"green"},{"text":" to unlock the door"}]

    execute at @p if entity @e[type=interaction,tag=door_unlockable4,distance=..2] run title @a actionbar ["",{"text":"[Right Click]","bold":true,"color":"green"},{"text":" to unlock the door"}]

    execute at @p if entity @e[type=interaction,tag=door_unlockable1,distance=2..2.2] if score key1 info matches 1 run title @a actionbar ""
    execute at @p if entity @e[type=interaction,tag=door_unlockable2,distance=2..2.2] if score key2 info matches 1 run title @a actionbar ""
    execute at @p if entity @e[type=interaction,tag=door_unlockable3,distance=2..2.2] if score key3 info matches 1 run title @a actionbar ""
    execute at @p if entity @e[type=interaction,tag=door_unlockable4,distance=2..2.2] run title @a actionbar ""

    execute as @e[type=interaction,tag=door_unlockable1] if data entity @s interaction if score key1 info matches 1 run function slender:scripts/interactions/door/door_unlock1
    execute as @e[type=interaction,tag=door_unlockable2] if data entity @s interaction if score key2 info matches 1 run function slender:scripts/interactions/door/door_unlock2
    execute as @e[type=interaction,tag=door_unlockable3] if data entity @s interaction if score key3 info matches 1 run function slender:scripts/interactions/door/door_unlock3
    execute as @e[type=interaction,tag=door_unlockable4] if data entity @s interaction run function slender:scripts/interactions/door/door_unlock4

    # Apartment Door
    execute as @e[type=interaction,tag=apartment_door] if data entity @s interaction run function slender:scripts/interactions/door/apartment_door

# Closet
    execute as @e[type=interaction,tag=closet] if data entity @s interaction if score intro1 scenes matches 371 run function slender:scripts/interactions/closet

# Infos
    execute as @p[x=-10,y=13,z=-37,distance=..1] at @s run title @a actionbar ["",{"text":"[Jump]","bold":true,"color":"green"},{"text":" to climb"}]
    execute as @p[x=-10,y=13,z=-37,distance=1..1.2] at @s run title @a actionbar ""

    execute as @e[type=interaction,tag=vending_machine2] if data entity @s interaction run execute as @e[name=vending_machine,x=1,y=61,z=-61,distance=..1,nbt={item:{id:"minecraft:coal",Count:1b,tag:{CustomModelData:81}}}] run title @a actionbar {"text":"Vending machine is empty.","bold":true}

    execute as @e[type=interaction,tag=wc_female4] if data entity @s interaction run title @a actionbar {"text":"I shouldn't go there.","bold":true}
    execute as @e[type=interaction,tag=wc_female3] if data entity @s interaction run title @a actionbar {"text":"I shouldn't go there.","bold":true}
    execute as @e[type=interaction,tag=wc_female1] if data entity @s interaction run title @a actionbar {"text":"I shouldn't go there.","bold":true}
    


execute as @e[type=interaction] at @s run data remove entity @s interaction