Optional auto-switch to the best tool for the pointed block (Terraria's "smart cursor" or auto-select). Also add a quick-stack-to-nearby-chests button and inventory sort.
Optional auto-switch to the best tool for the pointed block (Terraria's "smart cursor" or auto-select). Also add a quick-stack-to-nearby-chests button and inventory sort.
claude
added this to the v0.2 Core Feel milestone 2026-11-07 18:27:44 +00:00
Smart tool select: when a dig starts (on_punchnode), the inventory item that digs the node fastest (by core.get_dig_params) is swapped into the wielded slot. 0.4 s after dig is released, the two slots are swapped back if they still hold the same items. The server can't change the selected hotbar slot, so it swaps stacks instead. On by default, with an "Auto-select tools" checkbox on the inventory screen (stored in player meta).
Quick stack: backpack items (slots 11–40) go into chests within 6 nodes that already hold the same item.
Sort: merges partial stacks and orders the backpack (tools, then blocks, then other items, by name). The hotbar is never touched by quick stack or sort.
Tests: 5 selftest cases (tests/inventory.lua): dig times and best-tool choice, swap and swap-back (including no swap-back after the player rearranges), quick stack only into matching chests in range, sort and merge, the controls and toggle. Full suite 65/65, zero ERROR lines.
Needs a hands-on check in the client: the client works out the dig time when the dig starts, so the first block after a swap may still dig at the old tool's speed until the click is repeated. If that feels bad, a follow-up could swap on hover instead, which needs a pointed-node check every step.
Done in f823b33.
**What changed** (`mods/strata_crafting/inventory.lua`)
- **Smart tool select**: when a dig starts (`on_punchnode`), the inventory item that digs the node fastest (by `core.get_dig_params`) is swapped into the wielded slot. 0.4 s after dig is released, the two slots are swapped back if they still hold the same items. The server can't change the selected hotbar slot, so it swaps stacks instead. On by default, with an "Auto-select tools" checkbox on the inventory screen (stored in player meta).
- **Quick stack**: backpack items (slots 11–40) go into chests within 6 nodes that already hold the same item.
- **Sort**: merges partial stacks and orders the backpack (tools, then blocks, then other items, by name). The hotbar is never touched by quick stack or sort.
**Tests**: 5 selftest cases (`tests/inventory.lua`): dig times and best-tool choice, swap and swap-back (including no swap-back after the player rearranges), quick stack only into matching chests in range, sort and merge, the controls and toggle. Full suite 65/65, zero ERROR lines.
**Needs a hands-on check in the client**: the client works out the dig time when the dig starts, so the first block after a swap may still dig at the old tool's speed until the click is repeated. If that feels bad, a follow-up could swap on hover instead, which needs a pointed-node check every step.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Optional auto-switch to the best tool for the pointed block (Terraria's "smart cursor" or auto-select). Also add a quick-stack-to-nearby-chests button and inventory sort.
Done in
f823b33.What changed (
mods/strata_crafting/inventory.lua)on_punchnode), the inventory item that digs the node fastest (bycore.get_dig_params) is swapped into the wielded slot. 0.4 s after dig is released, the two slots are swapped back if they still hold the same items. The server can't change the selected hotbar slot, so it swaps stacks instead. On by default, with an "Auto-select tools" checkbox on the inventory screen (stored in player meta).Tests: 5 selftest cases (
tests/inventory.lua): dig times and best-tool choice, swap and swap-back (including no swap-back after the player rearranges), quick stack only into matching chests in range, sort and merge, the controls and toggle. Full suite 65/65, zero ERROR lines.Needs a hands-on check in the client: the client works out the dig time when the dig starts, so the first block after a swap may still dig at the old tool's speed until the click is repeated. If that feels bad, a follow-up could swap on hover instead, which needs a pointed-node check every step.