Iron Chef

Note: This AddOn is not currently being updated. It should still work overall (probably until Cataclysm changes a lot of things). Unfortunately I have not been playing WoW as regularly and I do not have the time to update my AddOns. If you have any questions, please email me at wikwocket@gmail.com.

This AddOn equips your Chef's Hat when you open your cooking window. Wearing the Chef's Hat now speeds up your cooking, so this mod will help you wear the appropriate attire when you enter Kitchen Stadium!

When you open your Cooking window, Iron Chef will help by:
* Equipping your Chef's Hat if found (and turning on helm display)
* Changing your title to "Chef" if you are a Chef

When you close the Cooking window, it will restore your hat and title to their pre-cooking values.

Iron Chef will only work properly out of combat, since it has to equip your Chef's Hat. If you're cooking in combat, let's just say you have some bigger fish to fry.

A la cuisine!

I hope you find this mod useful. Feedback and suggestions are always welcome!

I wanted to post here that the Iron Chef AddOn is not currently being updated. It should still work overall (probably until Cataclysm changes a lot of things). Unfortunately I have not been playing WoW as regularly and I do not have the time to update my AddOns.

Thank you to everyone who reads or posts in these comments threads, especially to those who have submitted feature ideas and bug fixes. You're the reason the WoW community is so great!

I was hoping to find an addon to equip my chef's hat while cooking since I can never remember to do it myself. I also noticed from the Change Log that you were looking for efficiency, so I thought I'd help you out somewhat. Given your level of experience from reviewing your coding practices I'm assuming that you may have missed some API and syntax practice which make life much easier. Please don't take this post the wrong way, I do not mean to offend. I do, however, want to see other authors using good code practices. =)

Code:

local function HaveItem(name)
-- check bags (doesn't check bank or keyring)
for i = NUM_BAG_FRAMES, 0, -1 do
for j = GetContainerNumSlots(i), 1, -1 do
if (GetItemInfo(GetContainerItemLink(i, j) or "") == name) then
return true;
end
end
end
return false;
end

This code would be useful in the absence of GetItemCount. You would still need to check if GetItemCount(46349) > 0 due to lua not equating 0 to nil or false.

You could combine the logic and nil checks to form a single if statement which saves a small amount of memory and processing time. Something along the lines of:

Code:

If not IsTradeSkillLinked() and GetTradeSkillLine() == "Cooking" then

You could also replace HaveItem with the aforementioned GetItemCount. Since the numeric slot ID of "HeadSlot" is always 1, you can replace:

Code:

GetInventoryItemLink("player", GetInventorySlotInfo("HeadSlot"))

with:

Code:

GetInventoryItemLink("player", 1)

Also:

Code:

if (not oldHatLink) then oldHatLink = ""

This changes oldHatLink to a string if it's nil, which is not needed. In lua, you can nil check variables simply by doing:

Code:

if Variable then -- works if 'Variable' is not nil or false
if not Variable then -- works if 'Variable' is nil or false

Also, you do not have to clear the cursor. I don't think anyone will have an item on their cursor when they open a tradeskill window since it clears the cursor itself to click it =). If you're having issues such as that, it may be due to the changes of EquipItemByName. In 3.3, if you're in combat, it sends the item information to the cursor rather than equipping it. This can be remedied by querying InCombatLockdown.

Code:

if not InCombatLockdown() then -- ClearCursor() no longer needed!

This should be enough information to cover everything. I don't think I missed any other issues. Lastly, here is an example of only equipping or unequipping the chef's hat:

Code:

local AddOn = CreateFrame("Frame")
local Cache
AddOn:RegisterEvent("TRADE_SKILL_SHOW")
AddOn:RegisterEvent("TRADE_SKILL_CLOSE")
AddOn:SetScript("OnEvent", function(self, Event)
if Event == "TRADE_SKILL_SHOW" and not InCombatLockdown() and not IsTradeSkillLinked() and GetTradeSkillLine() == "Cooking" and GetItemCount(46349) > 0 then
Cache = GetInventoryItemLink("player", 1)
EquipItemByName(46349)
elseif Event == "TRADE_SKILL_CLOSE" and Cache and not InCombatLockdown() then
EquipItemByName(Cache)
Cache = nil
end
end)
-- Note, this keeps the Chef's Hat equipped if you had nothing in your head
-- slot to begin with.

That is rather odd. Are you saying you have the Chef title, but the mod does not display it, and instead displays no title while cooking? If so, can you verify this by turning on display of your own character name and title and then trying it? Thanks!

Originally posted by twinsx2dad It doesn't give me the "Chef" title. It removes my title, then reinstates it after I close my skill window.

Originally posted by Wikwocket This seems to be the same issue pquayle reported below, where you have a mod that opens your tradeskills when you log out. Maybe it is a mod like altaholic or something, that is making sure it knows what recipes all of your characters know?

At any rate, if you or pquayle can post and let me know which mod does that, I can add a check to Iron Chef so that it does not swap your Chef's Hat in when that mod opens the tradeskill window.

Yes that might ve the case cause im using altaholic as well!
Ill switch off and try it to see if the error persists

Originally posted by TuLe Whenever i logout from the game the chefs hat is automaticaly equiped..

This seems to be the same issue pquayle reported below, where you have a mod that opens your tradeskills when you log out. Maybe it is a mod like altaholic or something, that is making sure it knows what recipes all of your characters know?

At any rate, if you or pquayle can post and let me know which mod does that, I can add a check to Iron Chef so that it does not swap your Chef's Hat in when that mod opens the tradeskill window.

Been using this addon on for a week now and i love it BUT... i found a nasty bug. Whenever i logout from the game the chefs hat is automaticaly equiped.. Now whenever i look my armory i got that stylish hat on... Is this fixed now?

Originally posted by Gryphon I have preemptively installed the addon, I am about halfway to getting the chef's hat on my main and other characters are still a little ways off. Would it be possible to check for the achievement first and if not completed do not run the rest of the addon?

I'll look into it. However bear in mind this is a very lightweight addon as it is (2 kb). There are basically 2 functions, one that runs when you open a tradeskill (which immediately bails out if it's not cooking or you don't have a Chef's Hat), and one that runs when you close a tradeskill.

In adding such a check, I would have to be careful not to add more memory usage than I am saving!