Hotbar QoL: smart tool select and quick stack #19

Closed
opened 2026-11-07 18:27:44 +00:00 by claude · 1 comment
Member

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
claude added the area/ui-hud
priority
low
type
feature
labels 2026-11-07 18:27:44 +00:00
eric added this to the Strata Roadmap project 2026-11-07 18:36:27 +00:00
eric moved this to To Do in Strata Roadmap on 2026-11-07 18:37:23 +00:00
eric closed this issue 2026-11-11 17:12:40 +00:00
Author
Member

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.

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.
Sign in to join this conversation.