I'm looking for a nice and very simple addon that automatically keybinds the last questitem used to a key of your choosing. Lets say i use [Random Questitem] manually by clicking on it from my inventory. This addon/macro would automatically keybind this to a key, for example X to make it faster than having to manually click it from the bags all the time. There are a few addons that can do this, like QuestItemBar (http://www.wowace.com/addons/questitembar/), but this is a bit too heavy for my needs.
Nice, keep it simple though, it doesn't have to scan for questitems other than when you actually use one. Also, ingame options isn't exactly needed, you could set the keybinding of your choosing in a simple LUA setting.
It is a simple solution and it is currently using LibQuestItem. I don't know if there is another better solution to this problem. But I could not find a event like ITEM_USED or something similar (maybe I didn't look good enough) so I'm listening for UNIT_SPELLCAST_SUCCEEDED and using the spellID to reverse lookup the item in LibQuestItem.
So basically, if someone know how to get a itemID or name of an item when it is used please tell me.
The whole addon.
local frame = CreateFrame("QuestItemKeyboundFrame")
QuestItemKeybound = LibStub("AceAddon-3.0"):NewAddon(frame, "QuestItemKeybound", "AceEvent-3.0")
local LQI = LibStub("LibQuestItem-1.0", true)
--SETTINGS
local keyToBind = "ALT-Q"
local displayChatMessage = true
--SETTINGS
function QuestItemKeybound:OnEnable()
self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
end
function QuestItemKeybound:UNIT_SPELLCAST_SUCCEEDED(_, unitID, spell)
if unitID and unitID == "player" then
local spellItem = LQI.questItemSpells[spell]
if spellItem then
local itemName = GetItemInfo(spellItem)
SetOverrideBindingItem(self, true, keyToBind, itemName)
if displayChatMessage then
print("QuestItemKeyBound: Bind item "..itemName.." to key "..keyToBind..".")
end
end
end
end
Some taint when using questitems in combat (similar to QuestItemBar):
1x <event>ADDON_ACTION_BLOCKED:AddOn 'QuestItemKeybound' tried to call the protected function 'SetOverrideBindingItem()'.
<in C code>: in function `SetOverrideBindingItem'
QuestItemKeybound-v0.1\Core.lua:22: in function `?'
CallbackHandler-1.0-6 (Ace3):147: in function <...Ons\Ace3\CallbackHandler-1.0\CallbackHandler-1.0.lua:147>
<string>:"safecall Dispatcher[5]":4: in function <[string "safecall Dispatcher[5]"]:4>
<in C code>: ?
<string>:"safecall Dispatcher[5]":13: in function `?'
CallbackHandler-1.0-6 (Ace3):92: in function `Fire'
AceEvent-3.0-3 (Ace3):120: in function <Ace3\AceEvent-3.0\AceEvent-3.0.lua:119>
---
Possible to completely ignore any quest item scanning in combat perhaps? Also, this happens even if the item i'm using is allready keybinded.
i wonder if using a savedvar for the config would be better than editing the core.lua file. editing the code would make updates a drag (you'd have to reassure the updater it's okay to over-write and then go in and reapply your config). using a savedvar, you could just edit it to change your settings. or even set the values with /script commands (/script QuestItemKeyBindDB.keyToBind = "ALT-Q").
It is a simple solution and it is currently using LibQuestItem. I don't know if there is another better solution to this problem. But I could not find a event like ITEM_USED or something similar (maybe I didn't look good enough) so I'm listening for UNIT_SPELLCAST_SUCCEEDED and using the spellID to reverse lookup the item in LibQuestItem.
So basically, if someone know how to get a itemID or name of an item when it is used please tell me.
The whole addon.
1x <event>ADDON_ACTION_BLOCKED:AddOn 'QuestItemKeybound' tried to call the protected function 'SetOverrideBindingItem()'.
<in C code>: in function `SetOverrideBindingItem'
QuestItemKeybound-v0.1\Core.lua:22: in function `?'
CallbackHandler-1.0-6 (Ace3):147: in function <...Ons\Ace3\CallbackHandler-1.0\CallbackHandler-1.0.lua:147>
<string>:"safecall Dispatcher[5]":4: in function <[string "safecall Dispatcher[5]"]:4>
<in C code>: ?
<string>:"safecall Dispatcher[5]":13: in function `?'
CallbackHandler-1.0-6 (Ace3):92: in function `Fire'
AceEvent-3.0-3 (Ace3):120: in function <Ace3\AceEvent-3.0\AceEvent-3.0.lua:119>
---
Possible to completely ignore any quest item scanning in combat perhaps? Also, this happens even if the item i'm using is allready keybinded.
Try r5, should be fixed. If you use a quest item during combat it should be bound after combat.
Note: There are no item scans during combat. The bug was because SetOverrideBindingItem() is a protected function.
$.02