'Select' funq, arrays, widgets

Hello! I want to add an item to specefic array based on ‘select’ with enum. It looks like this and works fine.

Now I wanted to have a function because I need to check this several times in my BP, but when I create a function with this code then it stops working, nothing is added and Array is just empty.


image

And I have no Idea why, any thoughts?
Thanks!

I’d like to say that I’ve seen the Select node misbehave in a similar fashion. I’d try feeding it a dummy local array of Consumable first. If that does not help, you may need to do it like so:

Can be pure.

edit: the bottom white execution wire should be connected, too, ofc…

1 Like

Thanks for the reply!

I tried both methods, didn’t work :frowning:

With the picture you’ve sent I had a problem that I want to add components to those arrays, If I use ‘local array’ then my defualt arrays are not being filled and also I didn’t understand this code a little bit. For example I can’t have a node from all three arrays to ‘Output Get’ so there is no point of choosing array with switch or am I getting something wrong?

You do not need 3 arrays - the whole point is to have 1 variable. It should be just a single local array you assign data to - compare it to my example. These 2 function in an identical way:

1 Like

Ok, I think I see what you’re doing and why it potentially wouldn’t work. Blueprints copy a lot of data under the hood and Select + Set by Ref is almost like shooting oneself in the foot - learnt this the hard way.

It did not trigger with me immediately; you can often crash the editor by just trying to:

And using a local variable wouldn’t work, apologies for the confusion.


I’ll have a think regarding how to wrap that in a function, this perhaps:

1 Like

Didn’t know that you can have multiple return nodes :sweat_smile:
Sadly still is not working

This is so strange, I mean if I just do the same thing straight in event graph then everything works fine, this is making me kinda anxious because of similiar problem in the future where something is not working just because it is stored as function :slight_smile:

Can you show more of the graph? Can we see what triggers what and where that struct comes from?

1 Like

You were already helping me with this code :sweat_smile:
So here it is

first picture is the one

Only now ‘Inventory slot array’ is replaced with this select and ‘Food Slot Array’,‘Weapon Slot Array’
Also it perefectly reads info of arrays from function because it is used elsewhere and only when I change this code specifcly where I add something then it works fine. In other places there is no need for this

Could you Print the length of the returned array here? Do you get the expected value?

1 Like

No :slight_smile:
It shows 0
That’s the problem I’m having it just doesn’t add anything but here is something more interesting:

So I need to have the same thing to sort sections and wrapboxes



And adding items to wrapbox is actually working fine!

I would not trust the Select node in this instance but even when you:

image

The length of the array is 0 when you query it right after creating the widget?

1 Like

What if you turn this into a non-pure function and execute it after creating the widget?

1 Like

So this ‘line of code’ is running only when there is a new Item that is not being stored so when I use print string it should show 0 only once for every new item like this (select stored in event graph)

But this is what I’m having when using function

it means that item is not stored in array

Can you test with non-pure?

1 Like

image
with this funq?

Sure, why not. Or wait, managed to replicate it and it does not work, precisely as you explained.

1 Like

I did it like this, same problem :mask:


1 Like

Sorry I didn’t understand what you were trying to say :sweat_smile:

Was just saying that you were right and that it does not work, indeed. I was fully expecting it to work. For now you can use a macro:

1 Like