Jump to content


Macros Mod; A Useful Guide To Advanced Scripting(6)

8 replies to this topic
  • Please log in to reply

Poll: Support this post: (29 member(s) have cast votes)

Are you interested in this post?

  1. Yes, please complete it (28 votes [96.55%])

    Percentage of vote: 96.55%

  2. Meh, i don't care (1 votes [3.45%])

    Percentage of vote: 3.45%

  3. Nope, nobody gives a !%#% (0 votes [0.00%])

    Percentage of vote: 0.00%

Vote Guests cannot vote



    Shop Owner

  • Server Donator
  • 132 posts

The Macros mod is one of the most useful mods for Minecraft that help you automate nearly every aspect of the game.
Developed by Mumfrey (check the original post).
I'll be focusing on the "Coding" part only in this post, if you want basic info for installing the mod, use google tongue.png
-- This tutorial will be edited and completed over time.

--I am not liable for any scripts you write/use that might get you banned.
--Written for the 0.15.3 version.

--Refer to my OTHER post for some useful scripts! 
-- For more info on ANY of the commands stated here go to the original mod's website.
--Sorry for my weak English, its my third language.
--The most important part of this tutorial are the examples,also try playing with anything you don't understand for better results.
There are a few things that i plan on covering in this post, i'll list them here for future reference:


Variables are where all the information is stored. They are present in every programming language but are different in each one of them.
Just like languages like C, C++, Java etc, the variables of the scripting language of this mod have different Types. This helps the compiler handle them better and us to code more organized.
Variables in the Macros scripting language have certain Prefixes that we use to declare their type. The types currently supported in this language are:

  • Booleans(Flags): Contains only (Yes/No)/(True/False). Has no prefix.
  • Integers: Contains integral number values, can not contain numbers with decimals. Prefix is '#'.
  • Strings and Chars: Contains anything from one character to a sentence. Prefix is '&'.
  • Arrays: Contains an array of a specific type. For example if we imagine a tower with one Integer on each floor, that whole building is an Array of Integers. Generally used in scripts that require a lot of data to be stored. The prefix is a pair of brackets "[ ]" that contain the number of the array.

You can declare variables with the SET command. In newer versions they can be declared even without this command but i recommend using the command so everything is neat and tidy. Note that player-set variable names can NOT contain Upper-Case letters in this language.


In order for us to let the compiler know we want the value of a specific variable, we need to enclose it in '%' signs, otherwise the compiler won't return the value to us.

__Global Variables
 These are variables that are available on the global scope.
Whenever we set a variable, it only works on the local scope, meaning that we cant use that variable anywhere else. This is good because our variables won't get mixed up this way.
When making GUI's or linking scripts to each other, we need to have variables that work on the global scope. This works similar to the Environmental Variables described in the next part.

 To declare a global variable, all we need to do is add a '@' sign before before the variable prefix and we're done! Please note that it's best to UNSET these variables at the end of our work to prevent any future problems as well as keeping our scripts tidy.

-Example usage:
Imagine we want to save a message in one script and log it in another script that runs later:


__Environmental Variables
These are Global variables containing game and player properties, they come in many different types but they all have the same properties:

  • They can not be edited.
  • They do not have prefixes, but they do need to be used with the '%' sign to get the value as well as brackets if they are arrays.
  • All of them are declared using Upper-Case letters. So they don't get confused with player-set variables.

-Environmental variables list:
**A complete list when you run this script: 


There's a list of most environmental variables hereCheck the example outputs or test for yourself with outputs to discover each type. I'm not going to do it as it would take way too long.
Note that some variables are only available in Iterators; I have not listed them here but will do it when we get there.
-These variables were not listed in the link i provided:
SIGNTEXT:Note that this is an array
HIT_VARIABLE:This one stores the specific property of the block in range, things like the rotation or color(For example HIT_TYPE, HIT_AXIS, etc). More info when we get to the Property Iterator.
COOLDOWN:For items that have cooldowns(like Epearls)

-Some variables are only availbale in Events, more info on that later.

Here are some examples to better understand the usage of these variables:


 Events are special condition checks that can run a script whenever the condition is met. There are currently 20 events available for use(without any custom modules).
Some events have their own special Environmental Variables too!
-Event variables list:
Events have a page with some useful info containing Environmental Variables when you click on them(picture below), but if you're lazy This is a pretty complete list. Note that these two sources supplement each other and are not complete alone. 
These are not mentioned in either of those places for some reason(please tell me if there are more):

Not much to say, just click on an event and put your script right in there!
I'm not really gonna get into this part, the creator of the mod already released these two videos on this and i feel like its more than enough. But just in case those are outdated, here are 2 sources that should have them all:


Conditionals are actually functions themselves, but since they are so important i had to make a section focusing on this part only.
There are 2 kinds of conditionals in this language: Pattern Matching conditionals and IF conditionals(This language does not have Switch/Case conditionals).

  • IF conditionals: These are present in almost all languages, the syntax is different but the purpose is the same. All they do is check a condition and execute something when the condition is met.
  • Pattern matching conditionals: just a derivation of the normal IF conditionals, checks the pattern defined and executes the code if the pattern matches with your input.

The conditional is declared in a line, and anything after that is performed when the condition is met. Conditionals always end with an ENDIF command so that the compiler knows when they end. This is the structure they have:





End Conditional

Here i'll explain each segment:
(Inputs/optional Inputs not listed here, check this for that)

  • IF:Checks if the condition is met.
  • IIF:Checks if the condition is met, and Echoes(inputs)something in chat depending on the output.
  • ELSEUsed after IF's, runs other actions if out main conditions didn't meet.
  • ELSEIF: Used after an IF, similar to using separate IF's but exits all IF's if one of their conditions are met. This makes the code faster and more organized.
  • IFCONTAINS: Checks if the specified strings contains a specific text and runs actions if the condition is met.
  • IFBEGINSWITH: Checks if the specified string begins with a specific text and runs actions if the condition is met.
  • IFENDSWITHChecks if the specified string ends with a specific text and runs actions if the condition is met.
  • IFMATCHES: Checks if the specified string matches our specific text exactly and runs actions if the condition is met.

Can be anything from a boolean to a mathematical equation. However there are a few important things we need to pay attention to:

  • There's a huge difference between '==' and '=' operators. '=' is an assignment operator, we use this to declare variables. for example(#var = 10) is used to assign 10 to #var. '==' however is an equality operator, we use them wherever we check conditions. for example(%#var% == 10) checks if the value of #var is 10.
  • Using these operators incorrectly does work in most cases, but in my experience it's better to use them correctly to prevent issues.
  • When we use booleans as conditions, instead of doing (%bool%==TRUE) and (%bool%==FALSE) we can use (bool) and (!bool) to make it easier.
  • If we want to add more than one condition, we can use the '||' and '&&' operators. '||' is the same as the OR operator. '&&' is the AND operator. Note that when we use these operators, each condition needs to be enclosed in parentheses(examples below). 

Can be any command or even more conditionals(more on commands later)
-Ending the Conditional:
It's obligatory for us to use the ENDIF command after all our conditionals otherwise the code will not work.

  •  Check if someone is saying banana in chat!
  • Check if you're holding the RMB and LMB together.
  • Input a number, check if its more or equal to 10
  • Input two numbers, check if they equal to 100 when multiplied
  • Check your health, warn you depending on how low it is

__Loops and Iterators
Loops are a set of actions that will be repeatedly executed until a certain condition is met.
Iterators can be defined simply as "objects" or "lists" of various data that can be accessed through loops and iterated over.


The general shape of loops are almost the same in every language. 
They consist of a loop command, that iterates over a loop condition until the end condition is met, there are a few loop commands that are slightly different in functionality:


 *Conditions in loops are just like in conditionals, read those above.

Most of them are written here, and the rest is written below(copied from the mod's website):
Note that each Iterator has its own set of variables that can be used in the loop where it's used.

  • RUNNING iterator to iterate over running macros, provides MACROID, MACRONAME, MACROTIME
  • CONTROLS iterator to iterate over existing controls, provides CONTROLID, CONTROLNAME and CONTROLTYPE variables(more info on the mod's website)

-Breaking out:

You can break out of any loop with the "BREAK" command, this is very useful when you want to break out of a loop in a specific part of it or is special conditions(case by case).

This only breaks out of the loop it was written in.

Unfortunately, this language doesn't support CONTINUE or GOTO commands.


*Side note:

A really useful command for loops is the "UNSAFE" command, it lets you modify the execution rate at which the loop(or any part of the script) is ran. End UNSAFE blocks with the ENDUNSAFE command.



  •  The typical layout for scripts that loop infinitely until the binding key is pressed again: 
  • Check enchantments on all items in inventory and pick the first item from the left that has mending.
  • Log your FPS into chat until the 0 key is pressed, cleans chat to prevent spam issues(can be used for GUI's in different manners)




Commands are the revolutionary part of this mod. They allow you to automatize and customize a lot of aspects in the game in the easiest and fastest way.

The best way of learning how commands work is to experiment with them yourself, so don't stand around and wait for others to tell you how to work with them without experimenting first.



Commands usually require an input, however, they can provide outputs and have options or flags that we can enable or disable when needed.

The general shape of commands is as followed:


Command(Input/outputs/condition checks)

Look at examples for better understanding..


-Commands list:

There is a list of commands on the mod GUI itself.


I'm not sure if it's a complete list, but i recommend checking the mod's change logs to see the newer commands, as well as more complete info on commands that might seem complicated to you.



I was too lazy to think of more.. will add later though

  • Go through your hotbar inventory, shoot snowballs if there are any.
  • Looks at the block you are facing if there is any, and walks to it. This script is only to demonstrate some uses of commands(its not stable). Automatically stops the script if it takes too long.



Edited by UniversAll, 04 December 2017 - 07:30 PM.

  • LordGeokal, PrinceKush, Eazbi and 15 others like this



    Shop Owner

  • Server Donator
  • 132 posts




    Diamond Monger

  • Server Donator
  • 622 posts
i am really excited to build scripts my own, i knew basic programming, so this wont be difficult at all!, thank any way


= [  Solaris   ::   Dozers   ::   Raphael   ::   Legendary  ] =



    Shop Owner

  • Server Donator
  • 132 posts

Minor update, 

also if u have any suggestions for some example scripts i could write for next parts, write it here.

Edited by UniversAll, 16 November 2017 - 05:55 PM.



    Shop Owner

  • Server Donator
  • 132 posts

Updated again,


if u have any suggestions for some example scripts i could write for next parts, write it here.



    Shop Owner

  • Server Donator
  • 132 posts

Updated and fixed a few things, feel free to ask questions



    Shop Owner

  • Server Donator
  • 132 posts


added another part

suggestions wont hurt :/



    Poor Merchant

  • Server Donator
  • 3,263 posts

Following this, thank you. :)

Posted Image



    Diamond Monger

  • Server Donator
  • 903 posts

wow so long....gj universall


let's see if I can make some macros on ma own

FK Signatures!!

Also tagged with one or more of these keywords: macros, scripts

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users