# Checking worn items for flag

**URL:** <https://discourse.cataclysmdda.org/t/checking-worn-items-for-flag/10929>\
**Category:** The Toolbox\
**Created:** [November 25, 2015, 12:00pm UTC](https://discourse.cataclysmdda.org/t/checking-worn-items-for-flag/10929 "2015-11-25T12:00:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ygdrad](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/ygdrad/32/14_2.png) [@Ygdrad](https://discourse.cataclysmdda.org/u/Ygdrad)\
**Post date:** [November 25, 2015, 12:00pm UTC](https://discourse.cataclysmdda.org/t/checking-worn-items-for-flag/10929/1 "2015-11-25T12:00:37Z")

</div>

I’ve just started trying to fiddle with the code to contribute to github rather than just pointing out issues and hoping someone both agrees with me and gets around to coding a fix. I’m currently trying to find a way to code something that checks if all items worn on a specific body part have a certain flag. I’ve been looking through the code for hours trying to find an existing example, but have not found any. I’m not overly familiar with the game’s code so I most likely missed it, I was hoping there would be a simple single function with both a body part and flag argument but it seems I am not in luck.

Could any of you more code-savvy people show me some example code that makes sure every piece of armor on a specific body part, for example bp\_torso has a specified flag, for example OVERSIZE?

---

<div class="post-metadata">

**Author:** ![Coolthulhu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/coolthulhu/32/2446_2.png) [@Coolthulhu](https://discourse.cataclysmdda.org/u/Coolthulhu)\
**Post date:** [November 25, 2015, 1:16pm UTC](https://discourse.cataclysmdda.org/t/checking-worn-items-for-flag/10929/2 "2015-11-25T13:16:28Z")

</div>

player::exclusive\_flag\_coverage does that for the entire body at once (returns a bitset).  
You can use it like:

```auto
const auto coverage = g->u.exclusive_flag_coverage( "FLAG_HERE" );
bool torso_covered = coverage[bp_torso];
```

It would be quite easy to copy it and simplify the copy to just return “false” if any item without flag exists a given body part (or set of body parts).

---

<div class="post-metadata">

**Author:** ![Ygdrad](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/ygdrad/32/14_2.png) [@Ygdrad](https://discourse.cataclysmdda.org/u/Ygdrad)\
**Post date:** [November 26, 2015, 12:30am UTC](https://discourse.cataclysmdda.org/t/checking-worn-items-for-flag/10929/3 "2015-11-26T00:30:01Z")

</div>

[quote=“Coolthulhu, post:2, topic:10929”]player::exclusive\_flag\_coverage does that for the entire body at once (returns a bitset).  
You can use it like:

```auto
const auto coverage = g->u.exclusive_flag_coverage( "FLAG_HERE" );
bool torso_covered = coverage[bp_torso];
```

It would be quite easy to copy it and simplify the copy to just return “false” if any item without flag exists a given body part (or set of body parts).[/quote]

Thanks, took some time and a bunch of fiddling since this is my first time doing this, but I’ve got it compiled and working.
