Problem obtaining the reference of an array

Hello everyone, I am having a problem when passing my inventory content array from one function to another, I have a function that, depending on which inventory is empty, returns that inventory to be able to use it in the add new item function, when I use the available content variable and add the item, it never ends up being added to that inventory, however if I place the reference directly from the component variable it works, I hope you can help me, thanks and sorry for my English

This is find empty slot function, that selects the inventory array where the item will go

This is the function of adding the item, which, as I said, if I place the content variable that comes from the find slot function, the item is never added, but if I drag, for example, the main content or second, the item will be added.

1 Like

I know it might be a local variable, but did you mean to connect this?

Also, because of this condition

image

the code immediately jumps into the second loop without checking the rest of the array for the requested item.

You actually don’t need to connect function parameters since they automatically become nodes

1 Like

That’s nice and confusing, especially as it’s not in the local variables list… :rofl:

1 Like

Yes I also don’t particularly like that the nodes have no distinction from regular nodes.

1 Like

How are you supposed to know if you accidentally picked up a variable from the main graph? :slight_smile:

( which you can do, btw )

I would be better if you only had access to things you’d explicitly passed in.

Strict naming conventions is the only way to avoid confusion I think.

1 Like

Yes the ItemID variable is the entry node, then I have already solved the loop by setting it to enter the second loop just as it completes the first. but I still have the same problem.
Below I put a video so you can see the behavior, if I select the content that comes from the function it does not add the item, however if I place the variable directly it works.

Yes, I can confirm that passing an array reference like this, doesn’t work :slight_smile:

Just looking into it…

Spectacular, it doesn’t even work with by reference

I would use a custom event to choose the array, and scrap the function.

wow that doesn’t sound good for my inventory :smiley:
Is there a way to pass my array reference? I need to access an inventory or another

Everything’s hunky dory if you do something with the array inside the function

Then, the reference comes out of the other end correctly.

Does it mean that in the function of finding the slot, create some node related to that array, for example, where I pointed?

You’re going to have to experiment. But I think you’ll find that if you make the update inside the function, it will work. So, this

image

inside the function.

I’ve been looking at it a bit more, I think it’s by design. You can’t pass an array reference out of a function. See the parameters

Note the missing ‘by reference’ on the output.

( Same with all variable types )

1 Like

You’re right!! I just saw it. You cannot pass an array reference, too bad.
I will then have to incorporate several functions in it to be able to access

thank you so much

1 Like

This has always been the case, and kinda makes sense. I put it down to the weather melting my brain.

Also, it is possible in CPP…

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.