From 5c3fb6b52139dd6552ba53c7726d705f6bb6245f Mon Sep 17 00:00:00 2001 From: Vitaly Date: Fri, 18 Aug 2023 05:00:49 +0300 Subject: [PATCH] fix slot switch when not active --- src/menus/components/hotbar.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/menus/components/hotbar.js b/src/menus/components/hotbar.js index cd07debf..d347b4f9 100644 --- a/src/menus/components/hotbar.js +++ b/src/menus/components/hotbar.js @@ -1,5 +1,6 @@ const { LitElement, html, css } = require('lit') const invsprite = require('../../invsprite.json') +const { isGameActive } = require('../../globalState') class Hotbar extends LitElement { static get styles () { @@ -111,11 +112,13 @@ class Hotbar extends LitElement { this.reloadHotbarSelected(0) document.addEventListener('wheel', (e) => { + if (!isGameActive(true)) return const newSlot = ((this.bot.quickBarSlot + Math.sign(e.deltaY)) % 9 + 9) % 9 this.reloadHotbarSelected(newSlot) }) document.addEventListener('keydown', (e) => { + if (!isGameActive(true)) return const numPressed = +(e.code.match(/Digit(\d)/)?.[1] ?? -1) if (numPressed < 1 || numPressed > 9) return this.reloadHotbarSelected(numPressed - 1)