Dealing with item names and item flags

I am looking into make some clothing “foldable” or “packable”, such as sleeping bags and blankets.

I notice that, while sewing, there is this piece of code for adding an item flag :

Is there an opposite function that removes flags? I would remove the tag “FOLDABLE” and add the tag “FOLDED” if that were the case.

Can I also use this method to “remove” names of items and add new names? I would like to prepend names with "packed ", so a packed sleeping bag would go from being named “sleeping bag” to “packed sleeping bag”.

Afraid not, the way we currently have of doing that is to add two items to represent the packed and unpacked versions, and add an iuse function to toggle between the two. Take a look at rad_badge() at the bottom of iuse.cpp for an example of how it works. (you’d want your function to detect which item it is and either pack or unpack)

If it becomes something we want to do across a lot of items (there are only like… 3 or 4 that do it right now), we can add an optional “transforms_to” item attribute that lets you toggle between the item types and is settable from within the JSON file. I’m not sure that we can do it with a settable flag, even if we have per-item flags, because how much compression you get out of something being “packed” changes based on the item.

If you also want one of the forms to have it’s own iuse function, e.g. to deploy a sleeping bag on the ground, which you might want, things get a bit more complicated… OTOH, seems like makeing the sleeping bag wearable might be a good option, so it might be a moot issue… for now.

I think a “transforms_to” would be a great addition, seeing how everything that currently has two states seems to be two different items. Then again, that might get complicated quickly.

I successfully added a compressed space blanket that needed to be unpacked. I was just looking for a more general solution rather than adding an extra item for each packable item.

Which then makes me wonder if it is worth it at all!

edit : I may simply have sleeping bags be “rollable”, so they would be that much better than a blanket.

edit2 : yeah, I am going to want to add the ability to remove tags. I feel like it’s only logical, if we can add them after all. Now to find out where their insertion is coded…

Pretty sure item_tags is implemented as a std::setstd::string. If I’m not mistaken, for item& it, you’ll want

it.item_tags.erase("FOO")

At least, that should work for tags that that specific item has (such as FIT). Not sure how that interacts with tags that the itype has (such as FOLDABLE, or… VARSIZE, is the thing that corresponds to FIT?).

Thanks Soron, narc informed me in the IR. With his help, I have a folding system up and running :slight_smile: A few outstanding issues, but it will be ready to merge soon!

If you’re interested : https://github.com/Shoes01/Cataclysm-DDA/compare/master...folding