The spellcaststatus (the value returned by CanUseSpell(unit, slot)) has changed a some patches ago and no longer returns a constant
the function now returns a dword where each bit represents a certain state. This means that instead only being able to check if the spell is ready or on cooldown etc, we can now check multiple states (if the spell is on cooldown and the cost is too high, you can know)
I am not so good at explaining things so here is image to help:
so this is an example of the value returned represented in a base2 (binary) format
the example if a spell which is on cooldown. if you call CanUseSpell(myHero, _Q) and the spell is on cooldown it will return 32
if the spell if on cooldown but you are not enough mana to cast the function will return 96 which is 0110 0000. as you can see both the cooldown and outofmana set are both set
below is a sample code (add this to your common folder http://lua.tips/down...bit32/bit32.lua)
local bit32 = require("Common.bit32") SpellCastStatus = function(unit, slot) return setmetatable({ }, { __index = function(t, k) local bitIndex = ({ ready = -1, notexist = 2, disabled = 3, notlearned = 4, cooldown = 5, outofmana = 6 }) if bitIndex[k] then local status = CanUseSpell(unit, slot) if bitIndex[k] > -1 then local a_mask = bit32.band(status, bit32.lshift(1, bitIndex[k])) return bit32.rshift(a_mask, bitIndex[k]) == 1 else return status == 0x00000000 end end end }) end -- Example: local Q = SpellCastStatus(GetMyHero(), _Q) if Q.ready then PrintChat("ready") else if Q.notexist then -- This flag is only used for items which have not been purchased PrintChat("notexist") end if Q.notlearned then -- This flag is used for spells which are level 0 PrintChat("notlearned") end if Q.disabled then -- This flag is used when you cannot cast a spell like when you are suppressed PrintChat("disabled") end if Q.cooldown then PrintChat("cooldown") end if Q.outofmana then PrintChat("outofmana") end end