# 'Select' funq, arrays, widgets

**URL:** <https://forums.unrealengine.com/t/select-funq-arrays-widgets/512240>\
**Category:** Blueprint\
**Tags:** unreal-engine, Array, Widget, UE4-27, question\
**Created:** [April 3, 2022, 11:03pm UTC](https://forums.unrealengine.com/t/select-funq-arrays-widgets/512240 "2022-04-03T23:03:30Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![eromanga](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eromanga](https://forums.unrealengine.com/u/eromanga)\
**Post date:** [April 3, 2022, 11:03pm UTC](https://forums.unrealengine.com/t/select-funq-arrays-widgets/512240/1 "2022-04-03T23:03:30Z")

</div>

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

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/2/0/520922aa096ba9b4cc53992016b888ec93dd11ff.png)

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](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/9/e/79e43c2d880344c80415cdf8cfa7de22d1d1aecf.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/0/4/704b3b0b2ecb285cb4a27590ecc63ae89b3ed74e.png)

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

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [April 4, 2022, 10:16am UTC](https://forums.unrealengine.com/t/select-funq-arrays-widgets/512240/2 "2022-04-04T10:16:34Z")

</div>

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:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/b/5/4b5709f73aadcdd1b36ced259b178d554f489722.png)

Can be pure.

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

---

<div class="post-metadata">

**Author:** ![eromanga](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eromanga](https://forums.unrealengine.com/u/eromanga)\
**Post date:** [April 4, 2022, 12:26pm UTC](https://forums.unrealengine.com/t/select-funq-arrays-widgets/512240/3 "2022-04-04T12:26:18Z")

</div>

Thanks for the reply!

I tried both methods, didn’t work ☹

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?

 ![Untitled](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/f/8/af8b446c84951f86812aef5ea65533e2c734c404.png)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [April 4, 2022, 12:45pm UTC](https://forums.unrealengine.com/t/select-funq-arrays-widgets/512240/4 "2022-04-04T12:45:11Z")

</div>

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:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/f/f/6ff5e2a098aa7a10f9f249d5d954cce8e99ae964.png)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [April 4, 2022, 1:02pm UTC](https://forums.unrealengine.com/t/select-funq-arrays-widgets/512240/5 "2022-04-04T13:02:48Z")

</div>

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:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/4/e/24e27a76c0cf0a9a364e1f48bc7cfa06517c454d.png)

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:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/1/b/b1b5ebdcc43eff8fc8a74eb931e1ae4dfbe3a34c.png)

---

<div class="post-metadata">

**Author:** ![eromanga](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eromanga](https://forums.unrealengine.com/u/eromanga)\
**Post date:** [April 4, 2022, 1:29pm UTC](https://forums.unrealengine.com/t/select-funq-arrays-widgets/512240/6 "2022-04-04T13:29:34Z")

</div>

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

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/f/0/cf099b12fa0dca9da570d7aa90edbf3eef69c81d.png)

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 🙂

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [April 4, 2022, 1:37pm UTC](https://forums.unrealengine.com/t/select-funq-arrays-widgets/512240/7 "2022-04-04T13:37:43Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/2/0/520922aa096ba9b4cc53992016b888ec93dd11ff.png)

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

---

<div class="post-metadata">

**Author:** ![eromanga](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eromanga](https://forums.unrealengine.com/u/eromanga)\
**Post date:** [April 4, 2022, 1:39pm UTC](https://forums.unrealengine.com/t/select-funq-arrays-widgets/512240/8 "2022-04-04T13:39:28Z")

</div>

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

> [@Move All Items after one of the Items was used](https://forums.unrealengine.com/t/move-all-items-after-one-of-the-items-was-used/495744/5):
>
> I can’t thank you enough!!! Really! Here is what I could do with all your help!! I’ve used second method since it is easier sweat_smile ! I had a problem where after Items were deleted and put to last slot, when I picked up the same Item again it was appearing in random place because references were taken from ‘Inventory slots’ array And I couldn’t use wrap box array, I tried to get around using additional integers but after some time came up with this final result!! This works fine for me …

first picture is the one

---

<div class="post-metadata">

**Author:** ![eromanga](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eromanga](https://forums.unrealengine.com/u/eromanga)\
**Post date:** [April 4, 2022, 1:42pm UTC](https://forums.unrealengine.com/t/select-funq-arrays-widgets/512240/9 "2022-04-04T13:42:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [April 4, 2022, 1:46pm UTC](https://forums.unrealengine.com/t/select-funq-arrays-widgets/512240/10 "2022-04-04T13:46:03Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/2/f/c2f7f90f74fb72bea19e37bdfe4524376242bbb4.png)

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

---

<div class="post-metadata">

**Author:** ![eromanga](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eromanga](https://forums.unrealengine.com/u/eromanga)\
**Post date:** [April 4, 2022, 1:53pm UTC](https://forums.unrealengine.com/t/select-funq-arrays-widgets/512240/11 "2022-04-04T13:53:23Z")

</div>

No 🙂  
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

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/c/28c4d64f1beb2ee958d86d852b86c03476fba506.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/b/a/3ba238bfa3fead2aca742ddf248714086ee682f0.png)  
And adding items to wrapbox is actually working fine!  

[https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/2/c/62c94ca8ec35e20428f311727cbac777a17a23b8.mp4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/2/c/62c94ca8ec35e20428f311727cbac777a17a23b8.mp4)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [April 4, 2022, 1:56pm UTC](https://forums.unrealengine.com/t/select-funq-arrays-widgets/512240/12 "2022-04-04T13:56:03Z")

</div>

> [@eromanga](#):
>
> No 🙂  
> It shows 0

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

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/7/5/a75c6852da0a901e89b3013194843d6775a9a739.png)

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

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [April 4, 2022, 1:57pm UTC](https://forums.unrealengine.com/t/select-funq-arrays-widgets/512240/13 "2022-04-04T13:57:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![eromanga](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eromanga](https://forums.unrealengine.com/u/eromanga)\
**Post date:** [April 4, 2022, 2:00pm UTC](https://forums.unrealengine.com/t/select-funq-arrays-widgets/512240/14 "2022-04-04T14:00:42Z")

</div>

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)

[https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/a/5/6a527393ff6e834837b17c9ab3464fc582f3af92.mp4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/a/5/6a527393ff6e834837b17c9ab3464fc582f3af92.mp4)

But this is what I’m having when using function

[https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/f/d/afda5a0d40a255c7d736147b543f7558493f69e5.mp4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/f/d/afda5a0d40a255c7d736147b543f7558493f69e5.mp4)

it means that item is not stored in array

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [April 4, 2022, 2:03pm UTC](https://forums.unrealengine.com/t/select-funq-arrays-widgets/512240/15 "2022-04-04T14:03:55Z")

</div>

Can you test with non-pure?

---

<div class="post-metadata">

**Author:** ![eromanga](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eromanga](https://forums.unrealengine.com/u/eromanga)\
**Post date:** [April 4, 2022, 2:04pm UTC](https://forums.unrealengine.com/t/select-funq-arrays-widgets/512240/16 "2022-04-04T14:04:31Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/7/5/a75c6852da0a901e89b3013194843d6775a9a739.png)  
with this funq?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [April 4, 2022, 2:05pm UTC](https://forums.unrealengine.com/t/select-funq-arrays-widgets/512240/17 "2022-04-04T14:05:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![eromanga](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eromanga](https://forums.unrealengine.com/u/eromanga)\
**Post date:** [April 4, 2022, 2:10pm UTC](https://forums.unrealengine.com/t/select-funq-arrays-widgets/512240/18 "2022-04-04T14:10:04Z")

</div>

I did it like this, same problem 😷

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/d/e/0de9099ced9ec14167c26a96f8b1126004cab7e2.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/6/d/e6d99c2f2abaf8d496be011593aed1d09f4e1f11.png)

---

<div class="post-metadata">

**Author:** ![eromanga](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eromanga](https://forums.unrealengine.com/u/eromanga)\
**Post date:** [April 4, 2022, 2:12pm UTC](https://forums.unrealengine.com/t/select-funq-arrays-widgets/512240/19 "2022-04-04T14:12:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [April 4, 2022, 2:14pm UTC](https://forums.unrealengine.com/t/select-funq-arrays-widgets/512240/20 "2022-04-04T14:14:54Z")

</div>

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:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/f/7/1f7b015d3eea9d3cac2e2fa4d193d49d1aea4a56.png)

[Next page](https://forums.unrealengine.com/t/select-funq-arrays-widgets/512240.md?page=2)
