Date: 2023/03/05 15:21:44 UTC-08:00
Type: Denizen Script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
- 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"