refactor spells to 7.4 magic level and mana

This commit is contained in:
ErikasKontenis
2021-04-10 16:56:15 +03:00
parent 0af275b70b
commit be0d0a3f59
2 changed files with 86 additions and 88 deletions

View File

@@ -4,25 +4,23 @@ function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local spells = {}
for i = 0, count - 1 do
local spell = getPlayerInstantSpellInfo(player, i)
if spell.level ~= 0 then
if spell.manapercent > 0 then
spell.mana = spell.manapercent .. "%"
end
spells[#spells + 1] = spell
if spell.manapercent > 0 then
spell.mana = spell.manapercent .. "%"
end
spells[#spells + 1] = spell
end
table.sort(spells, function(a, b) return a.level < b.level end)
table.sort(spells, function(a, b) return a.mlevel < b.mlevel end)
local prevLevel = -1
for i, spell in ipairs(spells) do
local line = ""
if prevLevel ~= spell.level then
if prevLevel ~= spell.mlevel then
if i ~= 1 then
line = "\n"
end
line = line .. "Spells for Level " .. spell.level .. "\n"
prevLevel = spell.level
line = line .. "Spells for Magic Level " .. spell.mlevel .. "\n"
prevLevel = spell.mlevel
end
text = text .. line .. " " .. spell.words .. " - " .. spell.name .. " : " .. spell.mana .. "\n"
end