Why you think it takes more CPU power though? Because here is what I think.
When you execute a spell, it will go trough Lua anyway to get the spell function.
I guess when you do it in spells.xml it will just read trough the parameters and checks if player can even cast it in first place ignoring the Lua function to do something with spell.
But don't think the difference is more than 0.01 seconds to execute function. (just talking about executing it, regardless how big script the spell itself is)
And if you simply add Lua way of adding exhaust time to spell. It will take same amount of time like in source.
Because the Lua functions are loaded to memory anyway, they will be simply executed.
So doesn't matter do you ask the question: "is spell under cooldown?" in c++ or Lua, should be same speed.
and executing function: "set exhaust time" also would take same amount of CPU power.
Only difference was that with Lua you used Lua libraries to find the source function. But since they are in memory anyway, It will be fast.
Besides I think spells.xml is horrible place to make spells anyway. way too many restrictions.
Talkaction for player spells and onThink() for creature spells.
If you use spell.xml then less time consuming option for this particular feature is source edit. Else you would have to edit every single spell.
But with talkactions. All you have to do is add else statement to cooldown question and then simply another line to increase cooldown and you can even config for particular spell that some give 1 sec less or some give 2 sec more cooldown, etc etc.
I use talkaction to cast spell and here is how it would look for me.
Code:
if os.time() < spellCD then
playerPos:sendMagicEffect(3)
return false, player:sendTextMessage(GREEN, "Spell under Cooldown.")
else
addSV(player, t.storageID+20000, t.cdPenalty or 1)
end
If I don't edit my spells now, ALL spells have this effect that if I spell is under cooldown then it will add 1 second to cooldown.
And it took me 1 minute to do this. (opening the coding program > find the file > doublecheck variables > write the line)
That's why i recommend moving away from spell folder and not make any spells there.