# Passing Which Device in an array signaled an event

**URL:** <https://forums.unrealengine.com/t/passing-which-device-in-an-array-signaled-an-event/1635410>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [January 22, 2024, 11:10pm UTC](https://forums.unrealengine.com/t/passing-which-device-in-an-array-signaled-an-event/1635410 "2024-01-22T23:10:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeremy\_Choud](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jeremy_choud/32/907645_2.png) [@Jeremy\_Choud](https://forums.unrealengine.com/u/Jeremy_Choud)\
**Post date:** [January 22, 2024, 11:10pm UTC](https://forums.unrealengine.com/t/passing-which-device-in-an-array-signaled-an-event/1635410/1 "2024-01-22T23:10:26Z")

</div>

I’m trying to figure out which device in an array signaled an event but can’t find a nifty way to pass an agent into function after the device in the array gets signaled.

Anyone have a nifty solution to this?

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

    @editable Muts : []mutator_zone_device = array{}
    var mutindex : []int = array{}
    var count : int = 0

    # Runs when the device is started in a running game
    OnBegin<override>()<suspends>:void=
        InitializeArray()

    InitializeArray():void=
        for(device:Muts):
            set mutindex = mutindex + array{count}
            set count = count + 1

    IdentifyMut():void=
        for(i:mutindex):
            index := i
            if(Mut := Muts[i]):
                Mut.AgentEntersEvent.Subscribe(PassDevice( **AgentWouldGoHere** , index))

    PassDevice(Agent:agent, mutzone:int):void=
        block:

```

---

<div class="post-metadata">

**Author:** ![NebojsaStrbac997](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NebojsaStrbac997](https://forums.unrealengine.com/u/NebojsaStrbac997)\
**Post date:** [January 23, 2024, 9:08am UTC](https://forums.unrealengine.com/t/passing-which-device-in-an-array-signaled-an-event/1635410/2 "2024-01-23T09:08:35Z")

</div>

I usually add a utils.verse file and include this:

```auto
using { /Verse.org/Simulation }
 
(Listenable : listenable(agent)).SubscribeAgent(OutputFunc : tuple(agent, t)->void, ExtraData : t where t:type) : cancelable =
    Wrapper := wrapper_agent(t){ExtraData := ExtraData, OutputFunc := OutputFunc}
    Listenable.Subscribe(Wrapper.InputFunc)
 
wrapper_agent(t : type) := class():
    ExtraData : t;
    OutputFunc : tuple(agent, t) -> void
    InputFunc(Agent : agent):void = OutputFunc(Agent, ExtraData)
 

```

Then you could do this:

```auto
Mut.AgentEntersEvent.SubscribeAgent(PassDevice, index)

PassDevice(Agent:agent, mutzone:int):void=
    block:

```

The SubscribeAgent allow you to pass an aditional param to the subscribe method

---

<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:** [February 22, 2024, 9:09am UTC](https://forums.unrealengine.com/t/passing-which-device-in-an-array-signaled-an-event/1635410/3 "2024-02-22T09:09:31Z")

</div>

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