Propagated getBookTitle to Lua

develop
PatrikLundell 2020-01-26 11:47:47 +01:00
parent 876ac6c056
commit 121497a466
4 changed files with 10 additions and 3 deletions

@ -1292,6 +1292,12 @@ Items module
Returns true *x,y,z* of the item, or *nil* if invalid; may be not equal to item.pos if in inventory. Returns true *x,y,z* of the item, or *nil* if invalid; may be not equal to item.pos if in inventory.
* ``dfhack.items.getBookTitle(item)``
Returns the title of the "book" item, or an empty string if the item isn't a "book" or it doesn't
have a title. A "book" is a codex or a tool item that has page or writings improvements, such as
scrolls and quires.
* ``dfhack.items.getDescription(item, type[, decorate])`` * ``dfhack.items.getDescription(item, type[, decorate])``
Returns the string description of the item, as produced by the ``getItemDescription`` Returns the string description of the item, as produced by the ``getItemDescription``

@ -38,10 +38,10 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
# Future # Future
## Fixes ## Fixes
- `stocks`: fixed display of titles by using the new ``Items::`getTitle`` operation before the original one, issue 1262 - `stocks`: fixed display of titles by using the new ``Items::getBookTitle`` operation before the original one
## API ## API
- Added ``Items::`getTitle`` to get titles of "books". Catches titles buried in improvements, unlike getDescription. - Added ``Items::getBookTitle`` to get titles of "books". Catches titles buried in improvements, unlike getDescription.
# 0.44.12-r3 # 0.44.12-r3

@ -1766,6 +1766,7 @@ static const LuaWrapper::FunctionReg dfhack_items_module[] = {
WRAPM(Items, getContainer), WRAPM(Items, getContainer),
WRAPM(Items, getHolderBuilding), WRAPM(Items, getHolderBuilding),
WRAPM(Items, getHolderUnit), WRAPM(Items, getHolderUnit),
WRAPM(Items, getBookTitle),
WRAPM(Items, getDescription), WRAPM(Items, getDescription),
WRAPM(Items, isCasteMaterial), WRAPM(Items, isCasteMaterial),
WRAPM(Items, getSubtypeCount), WRAPM(Items, getSubtypeCount),

@ -161,7 +161,7 @@ DFHACK_EXPORT df::coord getPosition(df::item *item);
/// Returns the title of a codex or "tool", either as the codex title or as the title of the /// Returns the title of a codex or "tool", either as the codex title or as the title of the
/// first page or writing it has that has a non blank title. An empty string is returned if /// first page or writing it has that has a non blank title. An empty string is returned if
/// no title is found (which is the casee for everything that isn't a "book"). /// no title is found (which is the case for everything that isn't a "book").
DFHACK_EXPORT std::string getBookTitle(df::item *item); DFHACK_EXPORT std::string getBookTitle(df::item *item);
/// Returns the description string of the item. /// Returns the description string of the item.