Paste #106948: Unnamed Denizen Script Paste

Date: 2023/03/05 15:21:44 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


    - foreach <[initial_branch_tiles]> as:i_tile:

      - define has_root False

      - define branched_tiles <list[]>

      - define center <[i_tile].center.flag[build.center]>
      - define type <[center].flag[build.type]>

      - define branched_tiles <[branched_tiles].include[<[i_tile]>]>

      #if root, everything connected to this structure is fine
      - if <proc[is_root].context[<[center]>|<[type]>]>:
        - foreach next

      - define nearby_tiles <[center].find_blocks_flagged[build.structure].within[5].parse[flag[build.structure]].deduplicate>
      - define connected_tiles <[nearby_tiles].filter[intersects[<[i_tile]>]]>

      - while <[connected_tiles].any> && !<player.has_flag[test]>:

        - define branched_tiles <[branched_tiles].include[<[connected_tiles]>]>
        - define new_connected_tiles <list[]>

        - foreach <[connected_tiles]> as:c_tile:

          - define center <[c_tile].center.flag[build.center]>
          - define type <[center].flag[build.type]>

          #if it's a root, then everything is chilling
          - if <proc[is_root].context[<[center]>|<[type]>]>:
            - define has_root True
            - while stop

          #this time, the nearby tiles will INCLUDE its own tile
          - define nearby_tiles <[center].find_blocks_flagged[build.structure].within[5].parse[flag[build.structure]].deduplicate>
          - define next_tiles <[nearby_tiles].filter[intersects[<[c_tile]>]]>

          - define connected_tiles <[connected_tiles].include[<[next_tiles]>]>

        - define connected_tiles <[connected_tiles].deduplicate>

      - if <[has_root]>:
        - foreach next

      - narrate "remove <[branched_tiles].size> tiles"