I think I have see this before in this forum but can't find it now, I have a xml table that defines some callback function, that need to be called by a unit, like this:
but that won't work, the error is:
if I write it like this:
there is an error too:
I wonder if someone know how to do that?
my code piece here:
Code:
local callback = GetTheFunctionNameFromTable(...);
unit:callback(...);
Code:
HeroesUtils.lua:98: attempt to call method 'callback' (a nil value)
Code:
unit[callback](...);
Code:
HeroesUtils.lua:98: Not a valid instance. Either the instance is NULL or you used '.' instead of ':'.
I wonder if someone know how to do that?
my code piece here:
Spoiler :
Code:
local modifier = GameInfo.AbilityModifiers[modi.YieldType];
if modifier ~= nil and modifier.Callback ~= nil and unit ~= nil and unit[modifier.Callback] ~= nil then
local callback = modifier.Callback;
local change = modi.Yield;
if isminus then
change = -modi.Yield;
end
unit[callback]( change );
end