# The array of user devices is working with an error.

**URL:** <https://forums.unrealengine.com/t/the-array-of-user-devices-is-working-with-an-error/1171070>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, question, fortnite\
**Created:** [May 19, 2023, 9:24am UTC](https://forums.unrealengine.com/t/the-array-of-user-devices-is-working-with-an-error/1171070 "2023-05-19T09:24:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sovestfn](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sovestfn/32/752162_2.png) [@sovestfn](https://forums.unrealengine.com/u/sovestfn)\
**Post date:** [May 19, 2023, 9:24am UTC](https://forums.unrealengine.com/t/the-array-of-user-devices-is-working-with-an-error/1171070/1 "2023-05-19T09:24:41Z")

</div>

There is a user device (right\_coord\_4\_switch), when placing it, we can specify a sequence of numbers (in the form of an array):

 ![coord2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/0/6/c0619bca52c411f253f1e48daf96c0f09305c0fc.jpeg)

We place several such devices on the map and indicate different sequences of numbers:

 ![coord4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/8/4/3842d0423b2e535b3d19fb12e62b821fe5048ae3.jpeg)

Also, there is a device (switch\_code) in which we can specify previous devices with a sequence of numbers:

 ![coord1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/6/c/46c17bfdfeed1b406a41190bf7e3353cdf4796e4.jpeg)

The code assumes that when interacting with the button, the switch\_code device will bypass all connected right\_coord\_4\_switch devices using a for loop and receive a sequence of numbers from all these devices (I attach the code for both devices).  
However, when running the game and testing, we see that the device right\_coord\_4\_switch with index 0 is empty. In this case, all other devices (with index 1, 2… etc.) are detected correctly:

 ![coord3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/5/8/658a98df211fea44475205519a38876cfa7e961e.jpeg)

When uefn is restarted in the switch\_code device, the element at index 0 is always empty:

 ![coord5](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/1/8/e1882637faf14620b38801fd67c7e7009dff5c62.jpeg)

Tried simpler combinations of custom devices, this situation always happens. With native fortnite devices, this problem does not occur.  
In this regard, the question is - perhaps I incorrectly specified the right\_coord\_4\_switch device class, or are there other errors in the code?  
Help to understand, please!

**Code for right\_coord\_4\_switch :**

```auto

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

right_coord_4_switch<public> := class<final>(creative_device):

    @editable
    Codes<public>:[]int = array{}

```

**Code for switch\_code:**

```auto
using { /Verse.org/Simulation }
using { /Fortnite.com/Devices }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Verse }

switch_code := class(creative_device):

    @editable
    Switchs : []switch_device = array{switch_device{}}
   
    @editable
    RightCodes:[]right_coord_4_switch = array{right_coord_4_switch{}}

    @editable
    CheckCoordButton: button_device = button_device{}

    CheckSwitch(MyAgent : agent) : void =
        for(RightCode : RightCodes):
           Print("code count in device:" + ToString(RightCode.Codes.Length))
             for(Code:RightCode.Codes):
               Print("Number: " + ToString(Code))
            
    OnBegin<override>()<suspends>:void=
        CheckCoordButton.InteractedWithEvent.Subscribe(CheckSwitch)
        Print("device count: " + ToString(RightCodes.Length))

```

---

<div class="post-metadata">

**Author:** ![Patothief](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Patothief](https://forums.unrealengine.com/u/Patothief)\
**Post date:** [May 19, 2023, 7:40pm UTC](https://forums.unrealengine.com/t/the-array-of-user-devices-is-working-with-an-error/1171070/2 "2023-05-19T19:40:36Z")

</div>

> [@sovestfn](#):
>
> ```auto
> @editable
> Switchs : []switch_device = array{switch_device{}}
> 
> ```

Just guessing but do you need to specify class inside the array?

```auto
    @editable
    Switchs : []switch_device = array{}

```

---

<div class="post-metadata">

**Author:** ![PurpleElephant55](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/purpleelephant55/32/698558_2.png) [@PurpleElephant55](https://forums.unrealengine.com/u/PurpleElephant55)\
**Post date:** [May 19, 2023, 10:07pm UTC](https://forums.unrealengine.com/t/the-array-of-user-devices-is-working-with-an-error/1171070/3 "2023-05-19T22:07:24Z")

</div>

Thank you for your report! We would like to look into this further, would you be able to submit a bug report using the form available here? [Fortnite Creative](https://creative.fortnite.com/s/bug-report)

---

<div class="post-metadata">

**Author:** ![sovestfn](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sovestfn/32/752162_2.png) [@sovestfn](https://forums.unrealengine.com/u/sovestfn)\
**Post date:** [May 20, 2023, 1:47pm UTC](https://forums.unrealengine.com/t/the-array-of-user-devices-is-working-with-an-error/1171070/4 "2023-05-20T13:47:00Z")

</div>

> [@sovestfn](#):
>
> `switch_device{}`

Thanks a lot! It works)

Now my code looks like this:

```auto
switch_code := class(creative_device):

    @editable
    Switchs : []switch_device = array{}
   
    @editable
    RightCodes:[]right_coord_4_switch = array{}
#etc

```

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [June 19, 2023, 1:47pm UTC](https://forums.unrealengine.com/t/the-array-of-user-devices-is-working-with-an-error/1171070/5 "2023-06-19T13:47:14Z")

</div>

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