Functions and Variables

Put duplicated part of your macro into reusable functions, implement as callbacks for image detection, store data into variables

Overview

Hey, you made it. Want to take your macro to the next level?

Functions and Variables is more of a programing thing but it's easy to set up here and you don't really need to know any programing to get started.

In programing, there's an principle called DRY - Don't Repeat Yourself. It means you don't want to write your code more than once.

Programing is an ever changing field, new requests come in every day. If you write something more than once then when you need to change it, you have to change it in multiple places.

One way to solve that is to put duplicated code into something called a function and just call that function every time you need it.

Sometimes there will be a situation where what you need is just a bit different but not completely the same, so you introduce parameters to modify a function behavior depend on the input.

Macro is duplication in nature, the very process of making macro is to look for pattern and try to repeat them.

Take Another Eden for example. You need to go left and right to look for random battle. Do you make a Swipe left/right every time? or it's better to put them into a function called leftRight and just call it whenever you need to go left and right?

It's an rpg so you need to do battle a lot? Would it better to just make a doBattle function and call it whenever you need to battle? You can even pass in the skill to use when you call doBattle to change the skill to use.

The same is applied to Variables with reusability at its core. Function is to reuse behavior whether Variable reuse parameters.

Function can also be used as Callbacks for Image Detection. Learn how to add Function and Variable to your macro is the next step.

© 2024 - Macrorify by KoK-CODE