Skip to content
User Avatar
#3447
Auto-translated
Hello! This script doesn't work, it crashes with the error 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)
options=pthheal..'Use_'..i..'...'
values= artifacts[HEAL.heal_arts_on].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


This function is called from the spell book, the first call goes fine, but the second one errors out at the specified location. I don't even know what the problem is, though it's probably related to scope. But how to fix it (and more importantly, what exactly) — I have no idea...

С уважением, }{0TT@6bI4
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________

Statistics

Welcome our newest member: artem