Hi,
The main general difference is that Attributes can hold more complex data than Tags (which is just a name and an optional category). Also Tags are shared between objects whereas Attributes always are unique to a given object.
The example with outdoor rooms is a good one. You can of course do it both ways. If all the meteor does is to be shown visually to a player, then getting all players in outdoor rooms is a good way to not waste echoing to empty rooms. If you want to perform some sort of action (maybe new monsters appear in all outdoor rooms as the meteor passes?) you obviously want to get all relevant outdoor rooms.
Let's assume the outdoor rooms are tagged with a tag with key "outdoors" and category "room_type". I recommend giving a category since that helps to avoid clashes. The default None-category is also a category in itself, so if you specify a category you must give the category whenever you search for the tag in the future, or it will not be found!
To get all outdoor rooms:
outdoor_rooms = Room.objects.get_by_tag("outdoors", category="room_type")
(note that the return is a queryset so you can keep querying with it). To get all outdoor rooms with a player in them:
outdoor_rooms_with_players = outdoor_rooms.filter(locations_set__db_typeclass_path="typeclasses.characters.Character")
(instead of a specific typeclass-path, you can also use a list of valid character typeclasses and subclasses in a similar way we discussed in a previous post). To check if an object
myroom has a given tag you can simply use the
.tags handler, which sits on every typeclassed object. It tracks all tags on that object and allows you to add, remove and, yes, check if the tag is there.
is_outdoors = myroom.tags.get("outdoors", category="room_type")
Hope that helps!
.
Griatch