Functions and Macros. A small guide from a noob

Hi folks!

Once im getting into the blueprint depper and depper started to realize how to start to use the functions and macros.

These two are pretty similar at first look but very different at the end this are the main diferences.

Functions- Really usefull to maintain your bp organized, can contain another functions;variables;Macros;etc…
Cant contain latent “functions” like timers. so if you need to have an delayed function for example you need
to trigger it with the delay function. Good to update bunch of functions in a fly with one execution order.

Macros- Macro is an prefabricated math or flow control node that you can make by yourself.
Can be called in functions until they dont have latent functions like timers.

Examples of engine macros are: all the loops; Do N; Do Once; etc…
Note: Engine inherited macros can be opened and seen how it works. but i wont recommend mod anything until you know what are you doing!

A good example of a “personal” macro is this one
http://i1380.photobucket.com/albums/ah198/Krzysztof_Kantoch/bool%20comparator_zpsj1qqfqhw.jpg

This one is easy as hell basically. when all the booleans are true it executes the top pin if at least one is not true it ill execute the else pin.
Its important to notice that the “== boll math node” wich is used works comparing both variables and sending true if so. adding one extra math node with forced true.
Asures that only when all the boleans are true the top pin is executed. if you would need to get something when some group of bools are false you just need to change the “force node”

This kind of macro is usefull for any kind of mision or objetives system for example

Another example i did is pretty more complex.
http://i1380.photobucket.com/albums/ah198/Krzysztof_Kantoch/12%20comparator_zpsq6eiqd3r.jpg

Pastebin wont generates the link for me dont know why. Probably some size issue

Basicaly its an macro wich takes 12 variables and check wich one is greater and executes the corespondant pin. In case of draw it executes the lowest pin (for example if 2 and 4 were draw the 4 will be executed).
Its possbile to do so nearly automaticaly with an array but this one is simplest for what i need to achieve. doing it by array you need to worry abot index and need to create the exe pin for each array element if you want to do very different things depending on wich one is the highest.
In the way i solved it it directly executes the highest int pin. Lookss a little scary but its easy

If have any sugestion or im wrong in something tell me.
And hope its usefull to someone!!!

Uh use loops and arrays, and enums and structs.

For eg firs macro can be done with 1 array of boolean, and foreach loop.

Or just array and check if it contains true or false.

Yeah, what about the situation when you need 13 variables? Would you create a new macro? You really want to use loops for that kind of stuff.

The second graph is nothing short of scary :slight_smile:

Kind of looks like a network switch