my bad
LUA:local config = { [{1, 5}] = { healAmount = {90, 250}, effect = 1, color = 210 }, [{2, 6}] = { healAmount = {90, 250}, effect = 1, color = 210 }, [{3, 7}] = { healAmount = {90, 250}, effect = 1, color = 210 }, [{4, 8}] = { healAmount = {90, 250}, effect = 1, color = 210 } } function onCastSpell(player, variant, isHotkey) for v, c in pairs(config) do if table.contains(v, player:getVocation():getId()) then local pos = player:getPosition() local mana_add = math.random(c.healAmount[1], c.healAmount[2]) player:addMana(mana_add) pos:sendMagicEffect(c.effect) Game.sendAnimatedText(mana_add, pos, c.color) end end...
Try this:
LUA:local config = { [{1, 5}] = { healAmount = {90, 250}, effect = 1, color = 210 } [{2, 6}] = { healAmount = {90, 250}, effect = 1, color = 210 } [{3, 7}] = { healAmount = {90, 250}, effect = 1, color = 210 } [{4, 8}] = { healAmount = {90, 250}, effect = 1, color = 210 } } function onCastSpell(player, variant) for v, c in pairs(config) do if table.contains(v, player:getVocation():getId()) then local pos = player:getPosition() player:addMana(math.random(v.healAmount[1], v.healAmount[2])) pos:sendMagicEffect(v.effect) Game.sendAnimatedText(v.healAmount, pos, v.color) end end combat:execute(player, variant) end
Lua Script Error: [Spell Interface]
data/spells/scripts/Custom/Manarune.lua:onCastSpell
data/spells/scripts/Custom/Manarune.lua:12: attempt to index field 'healAmount' (a nil value)
stack traceback:
[C]: in function '__index'
data/spells/scripts/Custom/Manarune.lua:12: in function <data/spells/scripts/Custom/Manarune.lua:8>
do the math random as separate variable e.g local myvariable = math.random(v.healthAmount[1],...Code:Lua Script Error: [Spell Interface] data/spells/scripts/Custom/Manarune.lua:onCastSpell data/spells/scripts/Custom/Manarune.lua:12: attempt to index field 'healAmount' (a nil value) stack traceback: [C]: in function '__index' data/spells/scripts/Custom/Manarune.lua:12: in function <data/spells/scripts/Custom/Manarune.lua:8>
local config = {
[{1, 5}] = { healAmount = {90, 250}, effect = 1, color = 210 },
[{2, 6}] = { healAmount = {90, 250}, effect = 1, color = 210 },
[{3, 7}] = { healAmount = {90, 250}, effect = 1, color = 210 },
[{4, 8}] = { healAmount = {90, 250}, effect = 1, color = 210 },
}
function onCastSpell(player, variant)
for v, c in pairs(config) do
if table.contains(v, player:getVocation():getId()) then
local pos = player:getPosition()
-- Generate one random value for both healAmount and animated text
local healAmount = math.random(c.healAmount[1], c.healAmount[2])
player:addMana(healAmount)
pos:sendMagicEffect(c.effect)
Game.sendAnimatedText(tostring(healAmount), pos, c.color)
end
end
combat:execute(player, variant)
end
Code:Lua Script Error: [Spell Interface] data/spells/scripts/Custom/Manarune.lua:onCastSpell data/spells/scripts/Custom/Manarune.lua:12: attempt to index field 'healAmount' (a nil value) stack traceback: [C]: in function '__index' data/spells/scripts/Custom/Manarune.lua:12: in function <data/spells/scripts/Custom/Manarune.lua:8>
local config = {
[{1, 5}] = { healAmount = {90, 250}, effect = 1, color = 210 },
[{2, 6}] = { healAmount = {90, 250}, effect = 1, color = 210 },
[{3, 7}] = { healAmount = {90, 250}, effect = 1, color = 210 },
[{4, 8}] = { healAmount = {90, 250}, effect = 1, color = 210 }
}
function onCastSpell(player, variant, isHotkey)
for v, c in pairs(config) do
if table.contains(v, player:getVocation():getId()) then
local pos = player:getPosition()
local mana_add = math.random(c.healAmount[1], c.healAmount[2])
player:addMana(mana_add)
pos:sendMagicEffect(c.effect)
Game.sendAnimatedText(mana_add, pos, c.color)
end
end
combat:execute(player, variant)
end
I found the solution it was exactly as I said (ManaChange) Function didnt have sendeffects in the game.cppmy bad
LUA:local config = { [{1, 5}] = { healAmount = {90, 250}, effect = 1, color = 210 }, [{2, 6}] = { healAmount = {90, 250}, effect = 1, color = 210 }, [{3, 7}] = { healAmount = {90, 250}, effect = 1, color = 210 }, [{4, 8}] = { healAmount = {90, 250}, effect = 1, color = 210 } } function onCastSpell(player, variant, isHotkey) for v, c in pairs(config) do if table.contains(v, player:getVocation():getId()) then local pos = player:getPosition() local mana_add = math.random(c.healAmount[1], c.healAmount[2]) player:addMana(mana_add) pos:sendMagicEffect(c.effect) Game.sendAnimatedText(mana_add, pos, c.color) end end combat:execute(player, variant) end
int32_t realManaChange = targetPlayer->getMana();
targetPlayer->changeMana(manaChange);
realManaChange = targetPlayer->getMana() - realManaChange;
if (realManaChange > 0 && !targetPlayer->isInGhostMode()) {
addAnimatedText(fmt::format("+{:d}", realManaChange), targetPlayer->getPosition(), TEXTCOLOR_DARKPURPLE);
}

great solution by doing this in c++ the thing will generally run more smooth and will not use lua so there will be no delay or unnecessary stream of extra data in the game with a lot of players you are saving a lot of memory here!I found the solution it was exactly as I said (ManaChange) Function didnt have sendeffects in the game.cpp
I followed this gentleman solution and worked perfectly!
@Ramon Bernardo
The solution for coming people
Find in game cpp this code
C++:int32_t realManaChange = targetPlayer->getMana(); targetPlayer->changeMana(manaChange); realManaChange = targetPlayer->getMana() - realManaChange;
Add below it add this line
C++:if (realManaChange > 0 && !targetPlayer->isInGhostMode()) { addAnimatedText(fmt::format("+{:d}", realManaChange), targetPlayer->getPosition(), TEXTCOLOR_DARKPURPLE); }
View attachment 88271
And thanks for everyone help for sacrficing their time for me @Gesior.pl @Marko999x @czouski @Mateus Robeerto