Dear Otland !
I found a problem with my talkaction !spells and with my spellbook.lua in actions. I was trying to solve this like here or here but its still not working.
So, when I clink on spellbook in game I see error:
Here Is my compact.lua
And here spellbook.lua from actions:
When I try to write !spells I see error:
And here is my spells.lua in talkactions:
Question: Anyone knows how to solve issue with spellbook and command !spells or could share well working those 2 thing on TFS 1.2 ? Thanks for replys, best regards!
I found a problem with my talkaction !spells and with my spellbook.lua in actions. I was trying to solve this like here or here but its still not working.
So, when I clink on spellbook in game I see error:
Here Is my compact.lua
Lua:
function getPlayerInstantSpellCount(cid) local p = Player(cid) return p ~= nil and p:getInstantSpellCount() end
function getPlayerInstantSpellInfo(cid, spellId)
local player = Player(cid)
if not player then
return false
end
local spell = Spell(spellId)
if not spell or not player:canCast(spell) then
return false
end
return spell
end
And here spellbook.lua from actions:
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local count = getPlayerInstantSpellCount(player)
local text = ""
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
end
end
table.sort(spells, function(a, b) return a.level < b.level end)
local prevLevel = -1
local spell
for i = 1, #spells do
spell = spells[i]
local line = ""
if prevLevel ~= spell.level then
if i ~= 1 then
line = "\n"
end
line = line .. "Spells for Level " .. spell.level .. "\n"
prevLevel = spell.level
end
text = text .. line .. " " .. spell.words .. " - " .. spell.name .. " : " .. spell.mana .. "\n"
end
player:showTextDialog(item.itemid, text)
return true
end
When I try to write !spells I see error:
And here is my spells.lua in talkactions:
Lua:
function onSay(player, words, param)
if player:getExhaustion(1000) <= 0 then
player:setExhaustion(1000, 2)
local text = ""
local spells = {}
for _, spell in ipairs(player:getInstantSpells()) do
if spell.level ~= 0 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 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 .. "Spells for Level " .. spell.level .. "\n"
prevLevel = spell.level
end
text = text .. line .. " " .. spell.words .. " - " .. spell.name .. " : " .. spell.mana .. "\n"
end
player:showTextDialog(SPELL_BOOK, text)
else
player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You\'re exhausted for: '..player:getExhaustion(1000)..' seconds.')
end
end
Question: Anyone knows how to solve issue with spellbook and command !spells or could share well working those 2 thing on TFS 1.2 ? Thanks for replys, best regards!