# Additional parameters on Suscribe or at least know which device triggered an event

**URL:** <https://forums.unrealengine.com/t/additional-parameters-on-suscribe-or-at-least-know-which-device-triggered-an-event/867815>\
**Category:** Devices\
**Tags:** fortnite-creative, unreal-editor-for-fortnite, question, fortnite\
**Created:** [April 7, 2023, 2:35am UTC](https://forums.unrealengine.com/t/additional-parameters-on-suscribe-or-at-least-know-which-device-triggered-an-event/867815 "2023-04-07T02:35:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![K-MUS](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@K-MUS](https://forums.unrealengine.com/u/K-MUS)\
**Post date:** [April 7, 2023, 2:35am UTC](https://forums.unrealengine.com/t/additional-parameters-on-suscribe-or-at-least-know-which-device-triggered-an-event/867815/1 "2023-04-07T02:35:26Z")

</div>

I have this code. An array of buttons and when a button is pressed I want to display in a hud\_message\_device which button was pressed.

```auto
# A Verse-authored creative device that can be placed in a level
UI_Announcer := class(creative_device):
    
    @editable
    HudMessageDevice : hud_message_device = hud_message_device{} 

    @editable
    Waypoints : []button_device = array{} 

    # Runs when the device is started in a running game
    OnBegin<override>()<suspends>:void=
    
        for( Waypoint: Waypoints):
            Waypoint.InteractedWithEvent.Subscribe(OnButtonInteractedWith)

    OnButtonInteractedWith(Player:agent):void= 
        Print("button pressed")
        HudMessageDevice.SetText(SetMessage("Button XXX pressed"))
        HudMessageDevice.Show()
        
    SetMessage<localizes>(MyMessage:string) : message = { "{MyMessage}" }

```

Can we add customer parameters on suscribe or at least in function OnButtonInteractedWith know which button was pressed beside knowing which player ?

---

<div class="post-metadata">

**Author:** ![Incredulous\_Hulk](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/incredulous_hulk/32/924210_2.png) [@Incredulous\_Hulk](https://forums.unrealengine.com/u/Incredulous_Hulk)\
**Post date:** [April 7, 2023, 5:28pm UTC](https://forums.unrealengine.com/t/additional-parameters-on-suscribe-or-at-least-know-which-device-triggered-an-event/867815/2 "2023-04-07T17:28:22Z")

</div>

Hey @K-MUS,

There are a couple ways to do this in Verse. Here is one way using the concurrency system.

```auto
# A Verse-authored creative device that can be placed in a level
UI_Announcer := class(creative_device):
    
    @editable
    HudMessageDevice:hud_message_device = hud_message_device{} 

    @editable
    Waypoints:[]button_device = array{} 

    # Runs when the device is started in a running game
    OnBegin<override>()<suspends>:void =
        for (I->Waypoint: Waypoints):
            OnButtonInteractedWith(Waypoint, I)

    OnButtonInteractedWith(Button:button, ButtonIndex:int)<suspends>:void = 
        # Suspends this function until Button.InteractedWithEvent is signaled
        Agent:agent = Button.InteractedWithEvent.Await()

        # ALTERNATIVE: If you don't care about the Agent:agent that triggered the button you can just await the event
        # Button.InteractedWithEvent.Await()

        # The inputs to the function are still around, so we can reference them after the InteractedWith event occurs
        Print("Button {ButtonIndex} pressed")
        HudMessageDevice.SetText(SetMessage("Button {ButtonIndex} pressed"))
        HudMessageDevice.Show()
        
    SetMessage<localizes>(MyMessage:string) : message = { "{MyMessage}" }

```

---

<div class="post-metadata">

**Author:** ![K-MUS](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@K-MUS](https://forums.unrealengine.com/u/K-MUS)\
**Post date:** [April 10, 2023, 12:44am UTC](https://forums.unrealengine.com/t/additional-parameters-on-suscribe-or-at-least-know-which-device-triggered-an-event/867815/3 "2023-04-10T00:44:12Z")

</div>

Thanks, that’ll work.

Is there a way of getting the name of the device in the editor. Because in this way I will get the index number as they where put in the array in the editor.

---

<div class="post-metadata">

**Author:** ![BrendannnD](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BrendannnD](https://forums.unrealengine.com/u/BrendannnD)\
**Post date:** [April 10, 2023, 4:54am UTC](https://forums.unrealengine.com/t/additional-parameters-on-suscribe-or-at-least-know-which-device-triggered-an-event/867815/4 "2023-04-10T04:54:55Z")

</div>

[Guide to Event Subscribing with Additional Parameters (Handler Functions)](https://forums.unrealengine.com/t/guide-to-event-subscribing-with-additional-parameters-handler-functions/793925) I’ve written a guide that provides an alternate way to subscribe with additional parameters

---

<div class="post-metadata">

**Author:** ![Incredulous\_Hulk](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/incredulous_hulk/32/924210_2.png) [@Incredulous\_Hulk](https://forums.unrealengine.com/u/Incredulous_Hulk)\
**Post date:** [April 10, 2023, 5:25pm UTC](https://forums.unrealengine.com/t/additional-parameters-on-suscribe-or-at-least-know-which-device-triggered-an-event/867815/5 "2023-04-10T17:25:56Z")

</div>

> Is there a way of getting the name of the device in the editor. Because in this way I will get the index number as they where put in the array in the editor.

There is currently no way to get the editor display name for a device in Verse code.

---

<div class="post-metadata">

**Author:** ![K-MUS](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@K-MUS](https://forums.unrealengine.com/u/K-MUS)\
**Post date:** [April 11, 2023, 1:05am UTC](https://forums.unrealengine.com/t/additional-parameters-on-suscribe-or-at-least-know-which-device-triggered-an-event/867815/6 "2023-04-11T01:05:37Z")

</div>

Thanks, this is exactly what I was looking for.
