Macros

Macros are a powerful feature that allow you to automate commands. Simply put, a macro is a collection of commands that you specify, which can be run from a single keyword. Macros also have the ability to include parameters, which can be plugged into the command values when it runs.

Creating a macro involves running the command 'macro define [name] {arg1} ... {argN}'. (Square brackets denote required terms, curly braces denote optional terms)

Let's take a look at an example. We're going to create a macro that changes the age of a mob. First, run

macro define setAge age

setAge is the name of our macro, and age is our only parameter. Next we define what commands will be run with this macro.

edit Age %age
save
done

Notice how instead of specifying an age, we put in our age parameter by using the % sign. This means whenever the macro is run, the argument passed into our age parameter will be substituted into the edit Age command. Finally, run

create

and our macro is finished.

To test it out, we can right click a villager for instance and then run

m setAge -9999

When you hit enter, the villager will be a baby and you'll be automatically exited from edit mode. If you don't want this to happen, just omit the 'done' command when creating the macro. You'll also notice you can use 'm' as an alias for 'macro'. This works when defining macros and of course when running them.

Now if we want to turn the villager back into an adult, we can enter edit mode again and run the macro with a different argument

/nbt
<right click the baby villager>
m setAge 10

Setting the age to a positive number will turn the villager back into an adult.

You can have as many commands contained within your macro as you want and as many parameters as you want. Keep in mind you need to enter them in the correct order when running the macro. Also remember you need to put a % sign before referencing the parameter inside a command. However you don't need to type the % when you're first defining the macro with 'macro define [name] {arg}'

If you're including parameters with your macro, be sure to give them descriptive names. This will make it obvious at a glance what you have to type in without having to comb through the commands and figure out what to put in.

You can view all macros with 'macro' or its alias 'm'

You can remove a macro with 'm remove [name]'

If you need to backup or edit the macro files manually, the config file is in the plugin directory under macros.yml.

Have fun and post your own macros if you've discovered some interesting uses for them!


Comments

Posts Quoted:
Reply
Clear All Quotes