Sure, here you go:
Lua Code:
frame:RegisterEvent("UNIT_TARGET")
frame:HookScript("OnEvent", powerBarHandler)
function powerBarHandler(frame, event, unit)
updatePowerBarVisibility(frame)
end
function updatePowerBarVisibility(frame)
local unit = 'target'
if UnitPlayerControlled(unit) or UnitPowerType(unit) ~= 1 then
frame.Power:Show()
else
frame.Power:Hide()
end
end
(simplified a tad)
The goal was to hide the target frame power bar for NPCs that don't use power. From testing it seems that they have assigned the power type 1 (i.e. 'RAGE').