rudger
Active Member
Im using tfs 1.2 10.98 and I want to create a message that once you level up you can get to see a new spell.
(example: You reached level 38 and can now cast 'exevo vis hur'.)
But I'm getting an orange message with no text and no errors in console, can someone take a look please?
(example: You reached level 38 and can now cast 'exevo vis hur'.)
But I'm getting an orange message with no text and no errors in console, can someone take a look please?
Lua:
local s = {
repeatAfterDeath = false, -- true -> player will always get the msg at lvlup | false -> player will only get the 1st time the gets the new level
detailedInfo = true, -- true -> player will get name, words, mana & mana% info of spells | false -> player will only get the name and the words of the spells
-- storage below is where the newlevel will be stored ONLY IF YOU USE repeatAfterDeath
Storage = 10000,
messageType = 'channel', -- options: 'popUp' or 'channel'
--this one below only used if messageType = channel
channelClass = MESSAGE_EVENT_ORANGE
}
function onAdvance(player, skill, oldlevel, newlevel)
if skill == SKILL__LEVEL or not s.repeatAfterDeath and player:getStorageValue(s.Storage) >= newlevel then
return true
end
local spells = {}
for _, spell in ipairs(player:getInstantSpells()) do
if(spell.level ~= 0) and spell.level == newlevel then
if(spell.manapercent > 0) then
spell.mana = spell.manapercent .. '%'
end
spells[#spells + 1] = spell
end
end
table.sort(spells, function(a, b) return a.level < b.level end)
local text, prevLevel = '', -1
for i, spell in ipairs(spells) do
local line = ''
if(prevLevel ~= spell.level) then
if(i ~= 1) then
line = '\n'
end
line = line .. 'You have just advanced to level '..newlevel..' and learned new spells!\n'
prevLevel = spell.level
end
text = text ..line..' ['..spell.name..'] "'..spell.words..'" '..(s.detailedInfo and 'Mana['..spell.mana..']'..(spell.mlevel > 0 and ' ML['..spell.mlevel..']' or '') or '')..'\n'
--text = text .. line .. ' ' .. spell.words .. ' - ' .. spell.name .. ' : ' .. spell.mana .. '\n'
end
--if text == '' then
-- return true
--end
player:setStorageValue(s.Storage, newlevel)
--if s.messageType == 'popUp' then
player:showTextDialog(2175, text)
--elseif s.messageType == 'channel' then
-- player:sendTextMessage(s.channelClass, text)
--end
return true
end
Last edited by a moderator: