Hi all! It's been a while since I've sat down to write one of these posts, but here we are. Today's lesson is in worldedit scripts (scary). Simply put, a WE script is a series of consecutive worldedit commands that are automated. This can significantly speed up making things like forests, pastures, fields and meadows. The downside of using a script is that the quality of terrain might not be as good as a hand-made forest for example.
Writing a worldedit script is easy enough, it doesn't take a degree in computer science or anything, only the macro keybind mod and a crazy desire for automation. There are a few things to consider when sitting down to write a script.
Adjacency masks
When implementing adjacency masks in a script, instead of using the '|' symbol, you have to change it to '~'. The reason being that the first symbol signifies the end of a command line. For example if I had this line in a script //replace 35:14&|[22][1][8] 35:4 then the result would be an error, because the [22][1][8] 35:4 will be cut off and sent as a message in chat, so the command makes no sense. By that same logic, at the end of each line you need to include '|' this symbol so you don't have the whole script run as an error.
Wait
In between each line of worldedit commands, you need to include a wait command. The number of seconds this lasts is up to you, but usually 2 is a good shout. This is what a 2 second wait line looks like $${wait(2)}$$|. This ensures that lag is minimised as the script runs, and there isn't a huge spam of commands in rapid succession. This is also helpful when running a script to see if it works, as you can tell roughly which command has gone wrong if theres a longer wait between commands.
Selection
It's important to make sure the selection size is big enough to run the commands.
Once you've written your script, it's now time to run it through. I usually go for about 10-20 lines of command at a time, and paste parts of it and bind it to my keys. This is significant enough to get through it quickly, but not in too big a block that you can't intervene and troubleshoot. More often than not, you will have to troubleshoot your script, because there are bound to be errors along the way, missed gmasks or a mistyped ID. 9/10 of my mistakes when I write scripts is missing a gmask.
Here's an example section from one of my scripts:
//rep 35:12 35:13|
$${wait(2)}$$|
//rep 35:13&~[35:11][1][8] 35:12|
$${wait(2)}$$|
//rep 35:13&~[35:12][1][8] 35:12|
$${wait(2)}$$|
//gmask 35&~[35:0]|
$${wait(2)}$$|
//rep 35:13&~[35:12][1][8] 35:12|
$${wait(2)}$$|
//rep 35:13&~[35:12][1][8] 35:12|
$${wait(2)}$$|
//gmask 35:0|
$${wait(2)}$$|
//rep 35:0&~~~~~~~[35:11][1][8] 35:1|
$${wait(2)}$$|
It's as simple as it looks! It's just a matter of working through it line by line and recording commands as you do them. Now I don't know EVERYTHING about scripts, but I know enough to know how to write my own, so if I have forgotten anything important feel free to add.
Thank you for reading,
- Jake
Writing a worldedit script is easy enough, it doesn't take a degree in computer science or anything, only the macro keybind mod and a crazy desire for automation. There are a few things to consider when sitting down to write a script.
Adjacency masks
When implementing adjacency masks in a script, instead of using the '|' symbol, you have to change it to '~'. The reason being that the first symbol signifies the end of a command line. For example if I had this line in a script //replace 35:14&|[22][1][8] 35:4 then the result would be an error, because the [22][1][8] 35:4 will be cut off and sent as a message in chat, so the command makes no sense. By that same logic, at the end of each line you need to include '|' this symbol so you don't have the whole script run as an error.
Wait
In between each line of worldedit commands, you need to include a wait command. The number of seconds this lasts is up to you, but usually 2 is a good shout. This is what a 2 second wait line looks like $${wait(2)}$$|. This ensures that lag is minimised as the script runs, and there isn't a huge spam of commands in rapid succession. This is also helpful when running a script to see if it works, as you can tell roughly which command has gone wrong if theres a longer wait between commands.
Selection
It's important to make sure the selection size is big enough to run the commands.
Once you've written your script, it's now time to run it through. I usually go for about 10-20 lines of command at a time, and paste parts of it and bind it to my keys. This is significant enough to get through it quickly, but not in too big a block that you can't intervene and troubleshoot. More often than not, you will have to troubleshoot your script, because there are bound to be errors along the way, missed gmasks or a mistyped ID. 9/10 of my mistakes when I write scripts is missing a gmask.
Here's an example section from one of my scripts:
//rep 35:12 35:13|
$${wait(2)}$$|
//rep 35:13&~[35:11][1][8] 35:12|
$${wait(2)}$$|
//rep 35:13&~[35:12][1][8] 35:12|
$${wait(2)}$$|
//gmask 35&~[35:0]|
$${wait(2)}$$|
//rep 35:13&~[35:12][1][8] 35:12|
$${wait(2)}$$|
//rep 35:13&~[35:12][1][8] 35:12|
$${wait(2)}$$|
//gmask 35:0|
$${wait(2)}$$|
//rep 35:0&~~~~~~~[35:11][1][8] 35:1|
$${wait(2)}$$|
It's as simple as it looks! It's just a matter of working through it line by line and recording commands as you do them. Now I don't know EVERYTHING about scripts, but I know enough to know how to write my own, so if I have forgotten anything important feel free to add.
Thank you for reading,
- Jake