Loop over devices by devicename

Hello forum,

let’s say I have three Devices called Device1, Device2, Device3.
I would like to have a trigger device that would be triggered by all three devices, but instead of writing this…

    @editable 
    Device1: creative_prop = creative_prop{}
    Device2: creative_prop = creative_prop{}
    Device3: creative_prop = creative_prop{}

    @editable 
    Trigger : trigger_device = trigger_device{}

    OnBegin<override>()<suspends>:void=
        Trigger.TriggeredEvent.Subscribe(MyFunc())

… is something like the following code possible … ?

    @editable 
    Device[1-3]: creative_prop = creative_prop{}

    @editable 
    Trigger : trigger_device = trigger_device{}

    OnBegin<override>()<suspends>:void=
        Device[1-3].TriggeredEvent.Subscribe(MyFunc())

And how do I reference them in Verse without the Device Manager? If I write Device1 in Verse, it is not recognizing the Device. Let’s say I place 200 devices into the map, do I really to go through the hassle of writing seperate lines for each of them?

What do I want to achieve? I want to create a collectible system. I have 200 pickups (=VFX Powerup Device). If someone walks above them, I want to change the class index of that instigator (player/actor). So I thought I would put a trigger device into the game and then subscribe to all VFX Powerup devices dynamically. Even if I remove or add a new VFX Powerup device the Verse code would not change.

1 Like

ChatGPT combining pythong and Verse is cute

Excuse me LAMA, but I really did not use ChatGPT, but yes, I know how it looks like. But still, do you have a helping answer to my question? Or is it just not possible?

1 Like

Turn it into Devices : []trigger_device = array{}

Turn it into

for(Device:Devices):
   Device.TriggeredEvent.Subscribe(MyFunc())

Thanks Mineblo for this quick answer. The solution will loop over all devices, but not those with specific indexnumbers (1-3).
I have now found gameplay tags. Which will allow me to loop over my specified devices. Next step requires to return the name of the current device. I have now something like this:

myVFXDevice := class(tag){}

OnBegin<override>()<suspends>:void=
        Pickups := FindCreativeObjectsWithTag(myVFXDevice{})
        
        for (TaggedActor : Pickups, Pickup := powerup_device[TaggedActor]):
            Pickup.GetName()

The problem now here is, that such thing as GetName() does not exist. I would like to get the name of each device like “Device1”, because I need to sort my list.

for(Device:array{Devices[1],Devices[2],Devices[3]}):
    Device.TriggeredEvent.Subscribe(MyFunc())

Mb I assumed it was ChatGPT because of the undocumented syntax you tried to use

To know which class to switch your player too, you’d need to add additional tags to your collectibles, but if you want to switch to 200 different classes then you’re probably doing something wrong

So I can’t access (read/write) the “Selected Class” property of VFX Devices within verse right? I couldn’t find a get/set-function within the documentation. Is this even the correct documentation of VFX Powerup devices?

Thanks mineblo for the quick help!
Those documents don’t mention a function to set the property “Selected class” to a VFX device. Within UEFN you can assign a specific class to to a VFX device, so that only players with a specific class can pickup/see the spawn of the VFX collectible. That’s what I need, but I want to access that variable from within Verse Code, because I want to do it dynamically.

Here is what I want to achieve in the end:
I have a list of n VFX Powerup devices. They all spawn some collectible coins for example. Now imagine I have two players on that map. They can collect those coins. But individually. So if one player is picking up a coin, the other one will still be able to pick up the first coin. But if player 1 is collecting coin 1, then coin 1 will invisible for player1 (that’s why I want to use the “Selected Class” property) and coin 2 will become visible then. Yes you can do that all manually without versecode, just within UEFN, but that works only for small numbers of coins. Imagine I have placed 200 coins. I don’t want to create 200 classes manually as well and assign event listeners manually and so on. I need dynamic creation.

I’d recommend to use the https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-collectible-object-devices-in-fortnite-creative
Which supports hiding collected coins per person

That’s a good idea for the hiding per person. But how do I hide coin1 for player1 after pickup without hiding it for player2?

You are helping so fast, that is really awesome. I am honestly gratefull!


Set this setting on the device to self

Ok, that’s a solution for all items that have been collected, but not for the items that will be collected, correct? (I know I didn’t mention this requirement before, I’m really sorry)
I only want to show one coin per person, the coins that have been collected, as well as those that will be collected need to be hidden to a player, except the next coin (but per player!).
Why do I want to do this? Because I want to create a “guide”-like coin. That will give the player a hint where to go next. If player has reach position 1 (coin 1), the next coin appears. But only the next one, because otherwise the whole map will be spammed full of coins.

I don’t know what solution to give, try messing around with respawn setting maybe

I think custom classes would be an option If It was somehow possible to assign a class to a device from within verse. Because then I would just assign a class to each coin and increase the players class by one, if the player is collecting a coin. This way automatically all coins are unvisible except of the one that is matching the class of the player.

Do you know how to read/write to “Allowed Class” of VFX Powerup device or Collectible device from with verse code?

I have created this :link: Feature request: Verse access to more device attributes

IMO the whole allowed class/team thing need to be reworked, it’s stupid how people use classes and teams for random things that shouldn’t require classes and teams :smiley:

Coming back on your issue, I think you’re better off doing your own collectible device based on switch_devices (which you can show/hide on a per player basis)

Hope this helps

Last time I tried to use a lot of switches for per client visiblity I realized that the device itself even with custom meshes has really low render distance

You can change the SM component of the switch to change that :eyes:

So you mean I should inherit the class and create a own creative_class based on the parent class? I am pretty new to this. I am afraid I don’t even know how to begin with that or where to search. If you know any proper tutorial it would really help a lot!

1 Like