- D1 Meta Docs - Denizen Script -
Home Page / Pi to one million places / Contact mcmonkey / Donate / Paste Scripts / Denizen Help /
You are browsing as a guest.
Login | Register








The script repo is an archive of historical scripts. For modern scripts, or to post your own, please use the Scripts forum section.





Staff Pick: WorldGuard Region to Notable Cuboids


By GrandPartyMask
Created: 2018/06/04 15:04:01 UTC-07:00 (3 years and 186 days ago)
Edited: 2019/05/26 06:11:02 UTC-07:00 (2 years and 195 days ago)
Likes: 0

Staff pick as of: 2018/11/06 19:50:38 UTC-08:00 (3 years and 31 days ago)
Denizen Version: 1.0.2
Script Version: 2
Description:

A script meant to create notable cuboids of every existing WorldGuard region. It will automatically run whenever a region is added, deleted, removed, or loaded/reloaded.

Alternatively, the task script "worldguard_regions_to_notable_cuboids" can be run to force the notable cuboids to update according to the currently existing regions per world.

All notable cuboids follow this template:
wgregion_W_<world name>_R_<region name>

UPDATES:
- 26 May 2019: Updated to match latest syntax.
- 26 May 2019: Continued support for this script via this repo is tenuous. A GitHub repo will be set up soon with this script, among others.


Download script | View raw 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
46
47
48
49
50
51
52
53
54
55
5500


# ----| USAGE

# The script will automatically look for new and removed regions whenever you
# use the WorldGuard "/region" command. All regions are then converted to
# notable cuboids.

# If you wish to manually convert regions, you can run the task script
# "worldguard_regions_to_notable_cuboids"

# All notable cuboids created by this script will have names following this
# template:
# wgregion_W_<world name>_R_<region name>

# You can then use these new notable regions in events, commands, tags, etc.



worldguard_regions_to_notable_cuboids:
    type: task
    debug: false
    speed: 0
    script:
    - flag server worldguard_to_notable_cuboids:!
    - foreach <server.list_worlds> as:w:
        - foreach <[w].list_regions> as:r:
            - note <[r].cuboid> as:wgregion_W_<[w].name>_R_<[r].id>
            - flag server worldguard_to_notable_cuboids:->:<[r]>
    - foreach <server.list_notables[cuboids].filter[starts_with[cu@wgregion_]].exclude[<server.flag[worldguard_to_notable_cuboids].as_list>]>:
        - note remove as:<[value]>

worldguard_regions_to_notable_cuboids_evts:
    type: world
    debug: false
    events:
        on rg|region command:
        - wait 1t
        - if "<list[define|create|d|remove|rem|delete|del|redefine|update|move|load|reload].contains[<context.raw_args.trim.before]>]>":
            - define rg_list li@
            - foreach <server.list_worlds>:
                - define rg_list <[rg_list].include[<[value].list_regions>]>
            - define add li@
            - foreach <[rg_list].exclude[<server.flag[worldguard_to_notable_cuboids]||li@>]>:
                - note <[value].cuboid> as:wgregion_W_<[value].world.name>_R_<[value].id>
                - define add <[add].include[<[value]>]>
            - define sub li@
            - foreach <server.flag[worldguard_to_notable_cuboids].as_list.exclude[<[rg_list]>]||li@>:
                - note remove as:wgregion_W_<[value].world.name>_R_<[value].id>
                - define sub <[sub].include[<[value]>]>
            - define new_list <server.flag[worldguard_to_notable_cuboids].as_list.exclude[<[sub]>].include[<[add]>]||<[add]>>
            - flag server worldguard_to_notable_cuboids:!
            - flag server worldguard_to_notable_cuboids:|:<[new_list]>







View History