Alright, try this one, it should actually work this time.
Lua Code:
local oSetAttribute = getmetatable(ActionButton1).__index.SetAttribute
hooksecurefunc(getmetatable(ActionButton1).__index, 'SetAttribute', function(self, attribute)
if attribute ~= 'showgrid' then return end
oSetAttribute(self, 'showgrid', CursorHasSpell() or 0)
if not HasAction(self.action) then
self:Hide()
end
end)
Plus I'm pretty sure my last example had an infinite loop in it, I'm surprised it worked at all.