-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Combine stacks of coins, make combine work in adventure mode #1227
base: master
Are you sure you want to change the base?
Conversation
…o the now wrong inventory due to item removals)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionality looks good. Main thing I was concerned about is coins max stacking at 500 (which is what you've done). Some of the user feedback could be improved though.
can you synthesize this with sent keystrokes? |
Added docs for `combine item`
The thing is, when you press the "examine" button, the inventory is still technically 'open'. But I can't send the 'inventory' keystroke from the screen that's examining the item, meaning I'd have to create a hook to wait on the user to come back to the inventory to refresh it. Alternatively, I would re-generate the inventory myself from code in the background but I'm sure to miss something. Therefore the safest route is to simply close the inventory interface and tell the user that happened. |
Generally, closing a widget in the way you're doing it isn't safe and can cause memory leaks. Toady hasn't provided us a way to close stuff while calling the proper destructors. |
@@ -39,6 +41,8 @@ Commands | |||
Search all stockpiles. | |||
``here`` | |||
Search the currently selected stockpile. | |||
``item`` | |||
Search the currently selected item. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by "item" do you mean "container"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any item that could contain anything, yeah
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, I would suggest naming the option container
. Moreover, I would like to see an option inventory
, that will go through the selected unit's inventory. If removing inventory_items
turns out to be complicated, restricting this to the containers found in the inventory should be sufficient.
if dfhack.world.isAdventureMode() and df.global.game.main_interface.adventure.inventory.open then | ||
-- refresh the inventory to prevent stale item references | ||
print('!! closed adventure mode inventory screen to prevent stale item references !!') | ||
df.global.game.main_interface.adventure.inventory.open = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why can't we send LEAVESCREEN here? If we're in a "details" screen, we can send LEAVESCREEN twice, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gui.simulateInput(dfhack.gui.getDFViewscreen(), 'LEAVESCREEN')
and then if you're not back at the default adventurer view (use dfhack.gui.matchFocusString
), then send it again
I just ran this on my adventurer's backpack
The problem with this result is that I have gold and silver coins from several different civilizations. Combining coins solely based on their material is just fundamentally wrong. I think it is sufficient to check whether the coins have the same
|
One possible solution is to change the check for crafted items (around line 200) to: elseif item:isCrafted() then
if df.item_type[stack_type.type_id] == 'COIN' then
comp_key = ('%s+%d'):format(stack_type.type_id, item.coin_batch)
elseif item:getQuality() == df.item_quality.Masterful then
comp_key = ('%s+%s+%s+%s+%s'):format(stack_type.type_id, item.mat_type, item.mat_index, item:getQuality(), item:getMaker())
else
comp_key = ('%s+%s+%s+%s'):format(stack_type.type_id, item.mat_type, item.mat_index, item:getQuality())
end
else (why can one only provide suggestions for code that has actually been changed...) |
hear hear |
Might add an option for combining coins of different years. Civs definitely need to remain separate because it impacts ability to trade them, IIRC. |
Seems like you should be able to just stack all items on a tile. Fort mode says it's restricted to a stockpile, but it'd be handy to just use it anywhere. (Targeting a container mostly does this, but it's a different view mode.) |
Allow combine to work in adventure mode and also combine stacks of coins
Note that it's safer to use the (z) -> Items tab to combine stacks currently, as doing so from the (i)nventory will not update the interface to reflect the change until you quit out of the inventory and come back. Currently, this is resolved by closing the inventory interface, prompting the player to bring it up manually themselves.