Paste #64921: DoubleDoors

Date: 2020/02/03 15:11:58 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


doubledoors:
    type: world
    events:
        on player right clicks *door using hand:
        - determine passively cancelled
        - define 1x1:<context.location.center.relative[1,0,1]>
        - define -1x-1:<context.location.center.relative[-1,0,-1]>
        - define doors:<cuboid[<[1x1]>|<[-1x-1]>].blocks[<context.location.material>].exclude[<context.location>]>

        - if <[doors].is_empty>:
            - switch <context.location> state:toggle
            - stop

        - narrate <context.location.material.direction>

        - foreach <[doors]>:
            - if <context.location.material.direction> == <[value].material.direction>:
                - switch <[value]>|<context.location> state:toggle
                - stop

            - choose <context.location.material.direction>:
                - case north:
                    - if <[value]> == <context.location.add[1,0,1]> && <[value].material.direction> == east:
                        - switch <[value]>|<context.location> state:toggle
                        - stop
                    - else <[value]> == <context.location.add[-1,0,1]> && <[value].material.direction> == west:
                        - switch <[value]>|<context.location> state:toggle
                        - stop
                - case south:
                    - if <[value]> == <context.location.add[1,0,-1]> && <[value].material.direction> == east:
                        - switch <[value]>|<context.location> state:toggle
                        - stop
                    - else <[value]> == <context.location.add[-1,0,-1]> && <[value].material.direction> == west:
                        - switch <[value]>|<context.location> state:toggle
                        - stop
                - case east:
                    - if <[value]> == <context.location.add[-1,0,1]> && <[value].material.direction> == north:
                        - switch <[value]>|<context.location> state:toggle
                        - stop
                    - else <[value]> == <context.location.add[-1,0,-1]> && <[value].material.direction> == south:
                        - switch <[value]>|<context.location> state:toggle
                        - stop
                - case west:
                    - if <[value]>|<[value].material.direction> == <context.location.add[1,0,-1]>|north:
                        - switch <[value]>|<context.location> state:toggle
                        - stop
                    - else <[value]>|<[value].material.direction> == <context.location.add[1,0,1]>|south:
                        - switch <[value]>|<context.location> state:toggle
                        - stop