Non-executing Macro: Why doesn't this work?

Apologies for the minimal description, not sure how to put it better in the title.

Anyway, I’m trying to get a better grip on why some things work in Function, but not in Macro.

The goal is to make a simple generic “Next” Macro, where you can input a wildcard Array and Current position, and it returns the “Next” (going back to 0 after reaching the end) element.

So far I came up with this, but it always returns ‘1’:

Any suggestions?

You need the execution pin ( in and out ).

I’m trying to keep it ‘pure’. That’s not possible?

1 Like

You’re getting macros mixed up with functions :slight_smile:

Macros are dirty, they cannot be purified.

For such cthulu spaghettin connections, I do sequence at macro/function entry. Then i store proper result in varible, and feed it to return node at sequence. Makes less off a mess. Also if you can use function use it not macro.

For your macro it would be nicer if you calculated index and that bool value, then just returned results of get. So you could calculate index, store it in variable, then calculate bool value, then got what is in array. with pure function, and using array from input param this could be much more versalite

Or you could use “chooser” (google those for unreal) but chooser would be overkill here. Just gool old boolean algebra of ands xors, ors and nots.

You’re right… I had to use the execution pins.

Funny detail: Without execution pins UE became very unstable and crashed several times trying to read from (what I assume is a) null pointer.

Thanks anyway for confirming that this is the way to go.

1 Like