attempt to concatenate global 'id' a nil value

Сергей

Известный
Автор темы
150
9
Версия MoonLoader
.027.0-preview
Хелпа:
    H = tonumber(os.date("%H",os.time()+time_correct))
if ( (H >= 8 and H <= 9 ) or (H >= 21 and H <= 23) ) then   
    local name,id,helpa = string.match(text, '^(.+)%[(%d+)%] говорит:%{......%} (.+)$')
    if name then
        helpa = lowers(helpa)
        id = tonumber(id)
        if helpa == ('хелпа') then
                --if work_time then
                    Tasking.new(function()
                    sendInput('test1')
                    Tasking.wait(1500)
                    sendInput('test2')
                    Tasking.wait(1500)
                    sendInput('test3')end,false)
                --else
                    --sendInput('1')
                --end
        end
    end   
else
    sendInput('test '..id..' test')
end
ругается attempt to concatenate global 'id' a nil value на 21 строку
 

lainban

Известный
1,429
613
Lua:
H = tonumber(os.date("%H", os.time() + time_correct))
if ((H >= 8 and H <= 9) or (H >= 21 and H <= 23)) then
    local name, id, helpa = string.match(text, '^(.+)%[(%d+)%] говорит:%{......%} (.+)$')
    if name then
        local helpa = lowers(helpa)
        local id = tonumber(id)
        if helpa == ('хелпа') then
            -- if work_time then
            Tasking.new(function()
                sendInput('test1')
                Tasking.wait(1500)
                sendInput('test2')
                Tasking.wait(1500)
                sendInput('test3')
            end, false)
            -- else
            -- sendInput('1')
            -- end
        end
    else
        sendInput('test ' .. id .. ' test')
    end
end

так вроде
 

Сергей

Известный
Автор темы
150
9
Lua:
H = tonumber(os.date("%H", os.time() + time_correct))
if ((H >= 8 and H <= 9) or (H >= 21 and H <= 23)) then
    local name, id, helpa = string.match(text, '^(.+)%[(%d+)%] говорит:%{......%} (.+)$')
    if name then
        local helpa = lowers(helpa)
        local id = tonumber(id)
        if helpa == ('хелпа') then
            -- if work_time then
            Tasking.new(function()
                sendInput('test1')
                Tasking.wait(1500)
                sendInput('test2')
                Tasking.wait(1500)
                sendInput('test3')
            end, false)
            -- else
            -- sendInput('1')
            -- end
        end
    else
        sendInput('test ' .. id .. ' test')
    end
end

так вроде
Спасибо работает

А нет не сработало, ты ж перенес
else
sendInput('test ' .. id .. ' test')

под if name then
а нужно, что бы оно выводило
else
sendInput('test ' .. id .. ' test')
если время не совпадает
 
Последнее редактирование:

lainban

Известный
1,429
613
Спасибо работает

А нет не сработало, ты ж перенес
else
sendInput('test ' .. id .. ' test')

под if name then
а нужно, что бы оно выводило
else
sendInput('test ' .. id .. ' test')
если время не совпадает
так у тебя айди не передается дальше, откуда он будет его брать

Lua:
local name, id, helpa = string.match(text, '^(.+)%[(%d+)%] говорит:%{......%} (.+)$')
H = tonumber(os.date("%H", os.time() + time_correct))
if ((H >= 8 and H <= 9) or (H >= 21 and H <= 23)) then
    if name then
        helpa = lowers(helpa)
        id = tonumber(id)
        if helpa == ('хелпа') then
            -- if work_time then
            Tasking.new(function()
                sendInput('test1')
                Tasking.wait(1500)
                sendInput('test2')
                Tasking.wait(1500)
                sendInput('test3')
            end, false)
            -- else
            -- sendInput('1')
            -- end
        end
    end
else
    sendInput('test ' .. id .. ' test')
end
 
Последнее редактирование: