I have an array of NPC Spawners. This array has duplicates of the same spawner. I would like to subscribe to the EliminatedEvent event for each spawner only once.
As such, I have created an additional array for spawn devices that I have already tracked.
Currently I have:
var trackedSpawnDevices : []npc_spawner_device = array{}
for (SpawnDevice : WaveData):
if (trackedSpawnDevices.Find[SpawnDevice]):
Print("Already here!")
else:
set trackedSpawnDevices += array{SpawnDevice}
SpawnDevice.EliminatedEvent.Subscribe(OnNPCEliminated)
However, I get an error when I try to find the SpawnDevice in the array with Find:
This function parameter expects a value of type tuple(comparable,comparable), but this argument is an incompatible value of type tuple(npc_spawner_device,npc_spawner_device).
I presume this means that I cannot find a device in an array this way. I then tried to loop through the array manually and check if the current item in the array is the same as the one I am checking, but it gives me a similar error.
Have been tinkering with this over the past week and have still not made any progress. I have attempted further tries at my earlier implementation as well as deduping the array at its creation rather than later on.
Without some form of .Find or .AddUnique, I am at a loss.
I also sought help from the Developer Assistant; however, it keeps offering solutions that either do not appear to exist in Verse or do not work for devices.
Hello @mikufromgatlin, currently, Creative Devices are not comparable, so unfortunately, Find won’t work, however, the easiest solution is to create your own <unique> wrapper class, something like: