Renaming an item but keeping the 'a'/'an' article in front

Here you can post threads specific to the current release of the core (099)

Moderator: POL Developer

Post Reply
kevin
POL Developer
Posts: 53
Joined: Wed Sep 29, 2010 3:47 pm
Contact:

Renaming an item but keeping the 'a'/'an' article in front

Post by kevin »

Hey guys. So, I noticed that if you rename an item using SetName(), you lose the functionality that single items get prefixed with 'a'/'an' and stacked items remove the 'a'/'an' but get pluralized, eg "a nightsight potion" => "2 nightsight potions". It looks like there is no workaround script-wise. I see this in POL's item.cpp:

Code: Select all

string Item::description() const
{
    if (specific_name())
    {
		return ::format_description( 0, name(), amount_ ); //dave monkeyed with this 2/4/3
    }
    else
    {
        const ItemDesc& id = find_itemdesc( objtype_ );
        if (id.desc.empty())
        {
            return ::format_description( tile_flags( graphic ), tile_desc( graphic ), amount_ );
        }
        else
        {
            return ::format_description( tile_flags( graphic ), id.desc, amount_ );
        }
    }
}
Using SetName() changes an item's specific_name(), resulting in the first code block for the if() running. It loses the tile flags, in turn losing the "a"/"an" prefix for singular items.

This is a problem because distro 097's crafting package renames crafted items to "a/an <material> <item>", and if the item is stackable (eg arrow shafts, lockpicks), you end up getting "2 an arrow shaft". I've somewhat alleviated the problem by not prefix crafted stackable items with the "a"/"an", but this is not optimal. The best functionality would be rename the item to "<material> <item>", but have the core automatically prefix "a/an" if necessary.

I would suggest a code patch for this, yet I'm guessing that the development team is pretty busy with either other POL issues or IRL stuff. So, can I just ask how the development team would fix an issue like this, so I could implement it myself and submit a patch?

Thanks,

Kevin
Developer, Neverlands Reborn
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: Renaming an item but keeping the 'a'/'an' article in fro

Post by Turley »

You can use the %/ plural/singular form also in SetName()
eg
SetName(item, "%/a %nightsight potion");
or
SetName(item, "%/an %arrow shaft");
Post Reply