Добрый день! Не работает вот такой скрипт, вылетает с ошибкой Attempt to compare nil with number
HEAL = {}
HEAL.variant = -1
Healing_arts = {{id=176, heal = 50}, {id=177, heal = 10},}
function HEAL.UseHeal(pl, ans)
if not ans then
HEAL.heal_arts_on = {}
for key, art in Healing_arts do
if HasArtefact(MAIN_HERO, art.id) then
table.insert(HEAL.heal_arts_on, art.id)
end
end
HEAL.len = length(HEAL.heal_arts_on)-1
print(HEAL.len, ' - длина 'массива) --Выводит минус единицу - длина массива
sleep()
if 0 < HEAL.len <= 4 then ---ВОТ ЗДЕСЬ ПАДАЕТ СКРИПТ.
print('Проверка') --НЕ ВЫВОДИТСЯ В КОНСОЛЬ
HEAL.variant = 1
local pthheal = "Interface/CustomAbilities/UseFirstAidKit/"
local options = {}
local values = {}
while not values and not options do
sleep()
end
for i=1, HEAL.len do
print (HEAL.len)
print('Проверка 2 ', HEAL.heal_arts_on[i])
options[i]=pthheal..'Use_'..i..'...'
values[i]= artifacts[HEAL.heal_arts_on[i]].name
--
end
while not options[HEAL.len] do
sleep()
end
options[HEAL.len+1]=Talk.BACK
Talk.mode = 1
Talk.NewDialog(GetIconPath('Heal'), pthheal..'Heal', pthheal..'HealDesc', 'HEAL.UseHeal', options, values)
--
-- elseif HEAL.len > 4 then
elseif HEAL.len <= 0 then
print('Ai?oe') ---ТОЖЕ НЕ ВЫВОДИТСЯ В КОНСОЛЬ
Talk.mode = 1
Talk.NewDialog("/UI/MessageBox/Warning.xdb#xpointer(/Texture)", pthheal.."WarningNoKit", pthheal.."NoKit", nil)
end
elseif ans then
if HEAL.variant == 1 then
if 0<ans<5 then
STALKER.ChangeHealth(artifacts[HEAL.heal_arts_on[ans]].heal)
RemoveArtefact(MAIN_HERO, HEAL.heal_arts_on[ans])
end
end
end
end
Эта функция вызывается из книги заклинаний, первый вызов проходит нормально, второй с ошибкой в указанном месте. Даже не знаю, в чём проблема, хотя наверняка с областью видимости. Но как исправить (а главное, что?) не знаю...