Page 1 of 1

Automatic Door Closer

Posted: May 20th, 2020, 11:58 pm
by Berufeng
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.)
Spoiler!

Code: Select all

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

Re: Automatic Door Closer

Posted: May 21st, 2020, 2:23 am
by mcmonkey
Should add a /haste link

Re: Automatic Door Closer

Posted: May 21st, 2020, 3:37 am
by Berufeng
Done. Also added a fix for a compatibility issue with my Decorator Tool script.

Re: Automatic Door Closer

Posted: June 29th, 2020, 7:13 am
by MadElectron
How do I exclude trapdoor from that script?

Re: Automatic Door Closer

Posted: June 30th, 2020, 5:43 pm
by Berufeng
MadElectron wrote:
June 29th, 2020, 7:13 am
How do I exclude trapdoor from that script?
Easiest way would be to add a _ in *door to make it *_door