-
-
Notifications
You must be signed in to change notification settings - Fork 1
Patterns
Patterns can also be extremely useful. They can start fairly simple, representing just a single block, but can be quite complex too, representing a group of blocks, each with their own weights and block data. They're what WorldEdit (and FAWE) use to set blocks in just about any regard.
If you've used WorldEdit's //set
or //replace
command, you'd be familiar with the concept of these already, even if you don't know it. In the first command there, the argument you provide is actually a pattern. As an example, in the command //set 50%stone,50%oak_planks
the 50%stone,50%oak_planks
part is the pattern, which represents, as you may have guessed, equal parts stone and oak planks. In skript-worldedit, you can use these same powerful patterns!
You'll see patterns pop up pretty often whenever you're doing anything that requires setting blocks (keep an eye out for the worldeditpattern
type), so it's important you know how this addon handles them. Anywhere that you can use a pattern, skript-worldedit will allow you to use an itemtype, string, or pattern. Let's have a look at how each one is used:
use we to set blocks in {region} to stone itemtype
use we to set blocks in {region} to "stone" string
use we to set blocks in {region} to {pattern} pattern
In the first example, we used stone
(the itemtype) as the pattern. To make this work, skript-worldedit just takes the itemtype, checks if its a block, gets its block data as a string, and parses it as a pattern. These kinds of patterns allow for only one block to be used.
In the second example, we used "stone"
(the string) instead. This does the exact same thing as the first, but skips straight to the parsing. This approach is how you can provide WorldEdit patterns in their string form for maximum customizability (multiple blocks, multiple weights, multiple block datas).
In the third example, we just used a pattern directly. These can be obtained via the pattern expression, and it just does all the verifying and parsing before Skript gets to the actual block setting.
That should pretty much cover how patterns are handled in skript-worldedit. This wiki won't act as a guide on patterns in general, because the WorldEdit pattern docs cover them in detail already; I really recommend giving their wiki a read if there's anything you're wondering about!
Warning
Don't use the clipboard pattern type! This relies on the player who's running the command to have a clipboard set, and seeing as there is no player when getting and using patterns in skript-worldedit, this will almost certainly result in errors, or at the very least unintuitive.