Apart from that, there is an actual syntax error in your code. This isn't valid Lua:
lua Code:
if RepairProfession == "Engineering" then
CastSpellByName("Field Repair Bot 74A") or CastSpellByName("Field Repair Bot 110G") or CastSpellByName("MOLL-E") or CastSpellByName("Scrapbot") or CastSpellByName("Jeeves")
else
That second line would only be valid if it started with a variable assignment ("local x =") or a keyword like "if" or "return".
I assume your intention was "try each of these and cast the first one that's available". Not only is (as Vlad already said) that not allowed -- you can't call CastSpellByName in an addon for any actual spell (only for professions, but there are better ways to open the tradeskill UI that you should use instead of that) -- but even if it was allowed, you couldn't do it that way. You'd need to do something like this instead:
lua Code:
if RepairProfession == "Engineering" then
if GetItemCount("Field Repair Bot 74A") > 0 and GetItemCooldown(123) == 0 then
CastSpellByName("Field Repair Bot 74A")
elseif GetItemCount("Field Repair Bot 110G") > 0 and GetItemCooldown(456) == 0 then
CastSpellByName("Field Repair Bot 110G")
elseif GetItemCount("MOLL-E") > 0 and GetItemCooldown(789) == 0 then
CastSpellByName("MOLL-E")
elseif GetItemCount("Scrapbot") > 0 and GetItemCooldown(852) == 0 then
CastSpellByName("Scrapbot")
elseif GetItemCount("Jeeves") > 0 and GetItemCooldown(159) == 0 then
CastSpellByName("Jeeves")
end
else
or you could make a table instead:
lua Code:
local EngineeringRepairItems = {
-- note these are random numbers,
-- not the actual item IDs.
123,
456,
789,
852,
159
}
and then do:
lua Code:
if RepairProfession == "Engineering" then
for _, id in next, EngineeringRepairItems do
if GetItemCount(id) > 0 and GetItemCooldown(id) == 0 then
CastSpellByName(GetItemInfo(id))
break
end
end
else
To work around the fact that you can't call CastSpellByName directly, your best bet is probably:
- Create an invisible secure action button
- When the user mouses over your data panel button, check for combat lockdown
- If you're not in combat, show the action button and reposition it to cover your data panel button
- When the user mouses away from the action button, or the user enters combat, hide the secure button and ClearAllPoints it (if you leave it anchored to an insecure button it will break)