diff --git a/docs/Lua API.rst b/docs/Lua API.rst index a4130096b..d7e94b92a 100644 --- a/docs/Lua API.rst +++ b/docs/Lua API.rst @@ -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. +* ``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])`` Returns the string description of the item, as produced by the ``getItemDescription`` diff --git a/docs/changelog.txt b/docs/changelog.txt index 9e4bef7a0..36ac237be 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -38,10 +38,10 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: # Future ## 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 -- 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 diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index 7c3ef965d..1d127930e 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -1766,6 +1766,7 @@ static const LuaWrapper::FunctionReg dfhack_items_module[] = { WRAPM(Items, getContainer), WRAPM(Items, getHolderBuilding), WRAPM(Items, getHolderUnit), + WRAPM(Items, getBookTitle), WRAPM(Items, getDescription), WRAPM(Items, isCasteMaterial), WRAPM(Items, getSubtypeCount), diff --git a/library/include/modules/Items.h b/library/include/modules/Items.h index 838104bfe..33feea222 100644 --- a/library/include/modules/Items.h +++ b/library/include/modules/Items.h @@ -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 /// 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); /// Returns the description string of the item.