dfhack icon indicating copy to clipboard operation
dfhack copied to clipboard

tweak/reaction-gloves interacts poorly with Items::createItem and its callers

Open quietust opened this issue 3 years ago • 0 comments

If the "reaction-gloves" Tweak is enabled, then any custom reaction which tries to produce a single GLOVES item will actually create two or more (with handedness flags automatically set according to the body plan of whoever's performing the reaction).

However, the Items::createItem() function only ever expects to receive one item - if it gets more than one, it errors out and leaves the items floating in limbo (rather than moving them to the floor at the feet of the specified unit).

The scripts gui/create-item and modtools/createitem also expect to get a single item ID back from this function, and they contain extra logic to create matching gloves with appropriate handedness.

Ideally, Items::createItem should return a std::vector<df::item*> (which Lua can hopefully convert into a native array) rather than just a single item ID (or a list of IDs), since it would save consumers of that function the trouble of having to call df.items.find(...) on those IDs (which they currently all do).

quietust avatar Mar 30 '22 19:03 quietust