I'm working on an addon that uses the damage type of a wielded staff for most of a class's spells, and it occurred to me that the method I used could be useful for modding, or development in general, and that it wouldn't hurt to share it.
Code:
getStaffType = function(self)
--from channel staff. we'll use this to check damage type for all of our staff and shield attacks.
--we changed damtype to kind so it wouldn't be confusing in our callbackOnMeleeAttack. we also added the name field to save ourselves some steps when we want to get the name as a string -- with colors!
local weapon, combat = self:hasStaffWeapon()
local combat = weapon and weapon.combat or false
local trail = "arcanetrail"
local particle = "bolt_arcane"
local explosion = "manathrust"
local name = "#PURPLE#Arcane#LAST#"
local kind = (combat and combat.element) or (combat and combat.damtype) or DamageType.ARCANE
if kind == DamageType.FIRE then explosion = "flame" particle = "bolt_fire" trail = "firetrail" name = "#LIGHT_RED#Fire#LAST#"
elseif kind == DamageType.COLD then explosion = "freeze" particle = "ice_shards" trail = "icetrail" name = "#1133F3#Cold#LAST#"
elseif kind == DamageType.ACID then explosion = "acid" particle = "bolt_acid" trail = "acidtrail" name = "#GREEN#Acid#LAST#"
elseif kind == DamageType.LIGHTNING then explosion = "lightning_explosion" particle = "bolt_lightning" trail = "lightningtrail" name = "#ROYAL_BLUE#Lightning#LAST#"
elseif kind == DamageType.LIGHT then explosion = "light" particle = "bolt_light" trail = "lighttrail" name = "#YELLOW#Light#LAST#"
elseif kind == DamageType.DARKNESS then explosion = "dark" particle = "bolt_dark" trail = "darktrail" name = "#GREY#Darkness#LAST#"
elseif kind == DamageType.NATURE then explosion = "slime" particle = "bolt_slime" trail = "slimetrail" name = "#LIGHT_GREEN#Nature#LAST#"
elseif kind == DamageType.BLIGHT then explosion = "slime" particle = "bolt_slime" trail = "slimetrail" name = "#DARK_GREEN#Blight#LAST#"
elseif kind == DamageType.PHYSICAL then explosion = "dark" particle = "stone_shards" trail = "earthtrail" name = "Physical#LAST#"
elseif kind == DamageType.TEMPORAL then explosion = "light" particle = "temporal_bolt" trail = "lighttrail" name = "#STEEL_BLUE#Temporal#LAST#"
else kind = DamageType.ARCANE explosion = "manathrust" particle = "bolt_arcane" trail = "arcanetrail" name = "#PURPLE#Arcane#LAST#"
end
return {kind = kind, explosion = explosion, particle = particle, trail = trail, name = name} -- half of these we might not use, but since we just coppied the function anyway, we might as well store the info in case we do decide to use it
end
All we've done here is copy the relevant portion of Channel Staff and dropped it into a function defined in spells.lua which returns all of the determined values. Also, for cosmetics, we added a 'name' field which returns a string with the name of the damage type in the appropriate color.

Edit: Image link looks broken. Might just be on my end, but I'll just drop it inline anyhow.
Attachment:
channelStaff.jpg [ 55.86 KiB | Viewed 752 times ]
It occurred to me afterward that this could also be wrapped up into hasStaffWeapon(). I'm not really sure which would be more ideal.