There is a problem: here is the codeEverything works fine, but... (see screenshot)function portal(hero)
if GetObjectOwner(hero) == 1 then
if GetObjectiveState("tom") == OBJECTIVE_UNKNOWN then
MessageBox(path.."tom1.txt")
end
if GetObjectiveState("tom") == OBJECTIVE_ACTIVE then
QuestionBox(path.."tom2.txt",'Dragon("'..hero..'")')
end
end
end
Trigger(OBJECT_TOUCH_TRIGGER, "portal","portal")
function Dragon(hero)
local week = ceil(GetDate(DAY) / 7)
sleep(3)
--
StartCombat(hero,nil,3,84, diff * week, 84, diff * week, 84, diff * week,nil,'BattleResult',nil,nil)
end
What could be causing this? I just want the console to be clean and not display an error.
This is due to calling the callback with a parameter. By default, the scripting engine simply adds two parentheses (and parameters, in some cases) to the name and executes the resulting code. If you call the callback with custom parameters, the executable code will look like this:
'Dragon("'..hero..'")()' that is, after calling the Dragon function, the result returned from it will be called, and since the function does not return anything, an error occurs when trying to call nil.It can be fixed by adding two hyphens:
QuestionBox(path.."tom2.txt",'Dragon("'..hero..'")--') then the executable code will look like this: 'Dragon("'..hero..'")--()' that is, the extra parentheses will be commented out.
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога
Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4