swarm-game / swarm

Resource gathering + programming game
Other
820 stars 51 forks source link

Change `tagmembers` to return a list #1997

Open byorgey opened 4 days ago

byorgey commented 4 days ago

The tagmembers command, as implemented in #1635 , currently has type

tagmembers : Text -> Int -> Cmd (Int * Text)

i.e. it takes an entity name and an index, and returns a pair of the total number of tags for that entity plus the tag with the given index. As discussed at https://github.com/swarm-game/swarm/pull/1635#pullrequestreview-1738733440 , now that we have #1894 , we should consider changing it to simply return a list, i.e.

tagmembers : Text -> Cmd (rec l. Unit + Text * l)

This would also require updating the code for any scenarios which use the tags feature.

On the one hand, this would mean tagmembers would now require slightly more capabilities to use, but it would require less code to use and enable the use of standard list functions. It also means that it would no longer crash when called on an entity with no tags.