The main issue with your approach is that the ‘Get IMG Map’ node is called in each iteration of the loop, creating the entire array each time. It would be better to cache all the arrays before the loop starts.
Do you mean that in each loop it will call all of them and not just the index that the loop generates for the array, is that it?
Technically this loop will only happen once when the widget starts, after that it will not be executed until the widget starts again!
I did it this way because I need to obtain the information in a controlled and precise way!
The loop will happen 4x and will call the array index, I don’t understand why I would do it differently because anyway I need the arrays in a fixed way and not dynamically, so I can’t see it any differently!!!
Yes, it will be called in each iteration, and each input pins. You don’t need to change your approach; just call Get IMG Map before the loop and save those arrays in local variables. Then, you can use them within the loop.
Technically, in your function, you used multiple find functions within a map, which means it will be executed each time. This is not optimal.
I have attached a better example to show you how many times it would be running
Well, it seems the same to me, but I think that when using make array and a pure function, it will create all the information again every time it is called, in this case 4 times!
But when creating variables before the loop, the information remains fixed and you get the variable that was previously ready!
Basically, this is what I’m doing, the logical part is almost ready.
This is a map module that will work on any character or NPC, showing the actor’s position on the map.
It can be attached to Characters, Maps, Items…
You can use it on any actor in the scene just by placing the module on it!
Yes, exactly, I’m sure it has been called more than four times.
Just add a PrintString in the pure function to see how many times it will be called. But with caching the array, it would be good. good job!