commit 224d544fc5efe69affdf3de644e044f44b1148b9 parent 97b247cbcc96c4fb934b38051469a9ddb027e885 Author: Peter <peter@minskio.co.uk> Date: Fri, 13 Nov 2026 17:44:18 +0000 Reusable inventory_slot function Diffstat:
| M | functions.sh | | | 20 | ++++++++++++++++++++ |
1 file changed, 20 insertions(+), 0 deletions(-)
diff --git a/functions.sh b/functions.sh @@ -52,6 +52,26 @@ function close_bank() { msleep 200 300 } +function inventory_slot() { + local slot=$1 + local start_x=1751 + local start_y=794 + local col_spacing=42 + local row_spacing=36 + local cols=4 + local rows=7 + if [[ ! $slot =~ ^[0-9]+$ ]] || (( slot < 1 || slot > cols * rows )); then + echo "inventory_slot: slot must be 1-$((cols * rows))" >&2 + return 1 + fi + local index=$((slot - 1)) + local row=$((index / cols)) + local col=$((index % cols)) + local x=$((start_x + col * col_spacing)) + local y=$((start_y + row * row_spacing)) + move_mouse "$x" "$y" 16 16 +} + function move_mouse() { # debug line: printf 'args(%d):' "$#"; printf ' [%q]' "$@"; printf '\n' >&2 local relative=0