The array of user devices is working with an error.

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):

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

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

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:

When uefn is restarted in the switch_code device, the element at index 0 is always empty:

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 :


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:

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))

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

    @editable
    Switchs : []switch_device = array{}
2 Likes

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

2 Likes

Thanks a lot! It works)

Now my code looks like this:

switch_code := class(creative_device):

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

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