Skip to content

Creating a Region

Patrick Miller edited this page Jun 24, 2024 · 5 revisions

skript-worldguard allows you to create the three region types provided by WorldGuard: global regions, cuboid regions, and polygonal regions. On this page, we'll cover how you can create each of those regions.

Creating a Global Region

A global region is the simplest to create. All you need is a name (also referred to as "ID") and a world.

Tip

Not sure what counts as a valid region ID? Read up on Region IDs here: https://github.com/APickledWalrus/skript-worldguard/wiki/Determining-a-Valid-Region-ID

The syntax for creating a global region is:

create [a] [:temporary] global [worldguard] region [named] %string% in %world%

Note

If you create a temporary region, the region will be deleted when the server restarts.

While the syntax looks long, it is simple to put together. Let's say you wanted to make a simple command for an admin to create a global region. First, we can build off the command example on the region ID wiki page. It looks like:

command /createregion <text>:
  trigger:
    if arg-1 is not a valid region id:
      send "<red>Region IDs may only contain letters, numbers, underscores, commas, single quotation marks, dashes, pluses, forward slashes." to player

Now, with this syntax, we can add an else statement to this command:

command /createregion <text>:
  trigger:
    if arg-1 is not a valid region id:
      send "<red>Region IDs may only contain letters, numbers, underscores, commas, single quotation marks, dashes, pluses, forward slashes." to player
    else:
      create a global region named arg-1 in the player's world

After running this command with the argument custom_global_region, you can see a new region appears in WorldGuard's region list command. Here's what it looks like in-game:

image

Creating a Cuboid Region

Cuboid regions are the the region type most are familiar with. It has two corner points that form a box. While it takes some more information to create cuboid regions, it is still quite simple.

The syntax for creating a cuboid region is:

create [a] [:temporary] [cuboid|rectangular] [worldguard] region [named] %string% [in %-world%] (between|from) %location% (to|and) %location%

Tip

You may have noticed that you don't need to specify a world. This is because the location parameters may already contain a world. If you're sure the locations you're putting in the effect have a world, you don't need to specify it. It's important that both locations have the same world too. If the world of the two locations don't match, or if they don't have a world, the effect will silently fail.

Let's go back to that command from above. This time though, we can use the cuboid region syntax instead of the global region syntax. It might look something like this:

command /createregion <text>:
  trigger:
    if arg-1 is not a valid region id:
      send "<red>Region IDs may only contain letters, numbers, underscores, commas, single quotation marks, dashes, pluses, forward slashes." to player
    else:
      create a cuboid region named arg-1 between {point1::%player's uuid%} and {point2::%player's uuid%}

This command could be combined with another to set {point1::%player's uuid%} and {point2::%player's uuid%} to the player's location.

Creating a Polygonal Region

Last up is a polygonal region. These are the most complicated regions WorldGuard offers, as they aren't limited to just a box. Polygonal regions are made up of many points, which allows the user to create some interestingly shaped regions. Every polygonal region has at least 3 points. Below, I'm going to showcase a standard polygonal region.

Most importantly, the syntax for creating a polygonal region is:

create [a] [:temporary] polygonal [worldguard] region [named] %string% [in %-world%] with [a] min[imum] height of %number% and [a] max[imum] height of %number% with [the] points %locations%

Just like cuboid regions, polygonal regions do not require a world to be specified as long as every point shares the same world. However, there's some new things here. Since polygonal regions have many points, you are required to supply a list of them (at least 3). The minimum and maximum height of polygonal regions aren't based on the points either. Instead, you have to specify the minimum and maximum point (the y-levels) that the region should cover.

Once again referencing the command from above, we can try and fill out this syntax. We're going to modify it though to support our minimum and maximum points. It might look something like:

command /createregion <text> <number> <number>:
  trigger:
    if arg-1 is not a valid region id:
      send "<red>Region IDs may only contain letters, numbers, underscores, commas, single quotation marks, dashes, pluses, forward slashes." to player
    else:
      create a polygonal region named arg-1 with a minimum height of arg-2 and a maximum height of arg-3 with the points {points::*}

command /addpoint:
  trigger:
    add player's location to {points::*}

The points list would be a list of the points for this region. You could make a command that adds the player's current location to the list, like the one shown above. If the points list doesn't contain at least 3 points, the effect will silently fail.

Here's an example of some points that will make up a polygonal region:

image

In-game, with the region created and filled in, it looks like:

image

As you can tell, if the points are a little misaligned, you might end up with undesirable results.


That's about all there is to creating regions with skript-worldguard. Make sure to check out the other pages listed in the sidebar to learn about what you can do with your brand new regions!