How do I create a map with tag objects as values?

I tagged a number of objects in my map with an ID tag. Now I want to create a tag with int as a key and the tag as the value, so that in my Verse code I can use that tag to filter out an object with tag functions. Why maps? So that I can dynamically get objects rather than hard coding the tags. But I am getting an error while creating a map with int as a key and tag as the value. If there is any alternative to this problem, please let me know.

Can you store the objects/creative device the tag was attached to instead of the tag itself? You might just need to create a custom struct or class to store in the map that contains the rest of the info you need

Hey @Hakaishin_SENPAI how are you?

As far as I know, you cannot get the tag of an object in Verse. You can only get all the objects with a specified tag.

Keeping this in mind, what you could do is to create an array for each tag you have, and store all the objects with a given tag in the corresponding array. That way you won’t need to filter anything, as all the objects will be grouped only with other objects that have the same tag.

You have the Tags documentation here, but it is a little bit outdated. Now you should use the function “FindCreativeObjectsWithTag” instead of “GetCreativeObjectsWithTag”. The new function returns a generator instead of an array. Here you have a video that explains how to use it.

Hope this helps you!

1 Like