local inv = require("inventory_utils") local player = require("player") -- Config start local keybind = 88 -- (X key) -- https://www.glfw.org/docs/latest/group__keys.html https://www.glfw.org/docs/3.3/group__buttons.html local delay_back_min = 3 local delay_back_max = 5 -- Config end local last_slot = nil local function get_healing_wand() local item = inv.findItemInHotbar("WAND_OF_ATONEMENT") if not item then item = inv.findItemInHotbar("WAND_OF_RESTORATION") end if not item then item = inv.findItemInHotbar("WAND_OF_MENDING") end if not item then item = inv.findItemInHotbar("WAND_OF_HEALING") end return item end local pressed = false local tick = 0 registerKeyEvent(function(key, action) if action == "Press" and key == keybind then local item = get_healing_wand() if item then last_slot = player.input.getSelectedSlot() player.input.setSelectedSlot(item) player.input.useItem() pressed = true tick = math.random(delay_back_min, delay_back_max) end end end) registerClientTick(function() if pressed then if tick <= 0 then player.input.setSelectedSlot(last_slot) pressed = false else tick = tick - 1 end end end)