Automatic Door Closer

Berufeng

Member
Jan 29, 2020
18
0
0
Were you born in a barn? If so, please do not download this script.

This is a simple little script that automatically closes doors when you walk away and, like a heathen, forget to close them.

Haste Link: https://one.denizenscript.com/haste/69373

(Or click the spoiler for the script.)
Code:
Door_Closer:
  type: world
  debug: false
  events:
    after player right clicks *door|*_gate priority:2:
      - if !<context.location.material.switched>:
        - stop
      - wait 2s
      - waituntil <context.location.find.entities[player].within[3].size.is[==].to[0]>
      - if <context.location.material.switched>:
        - switch <context.location> state:off
        - choose <context.location.material.name.after_last[_]>:
          - case door:
            - playsound <context.location> BLOCK_WOODEN_DOOR_CLOSE
          - case trapdoor:
            - playsound <context.location> BLOCK_WOODEN_TRAPDOOR_CLOSE
          - case gate:
            - playsound <context.location> BLOCK_FENCE_GATE_CLOSE