Пронумировать строки в диалоге

vegas

Известный
Автор темы
637
444
Версия MoonLoader
.026-beta
Хочу пронумировать строки в диалоге но они остаются неизменными

Код:
function numeracia(text)
    line = 0
    for S in text:gmatch("[^\n]+") do
        line = line + 1
        local replace = ''..line..'. '..S..''
        print(replace)
        text = string.gsub(text, S, replace)
    end
    return text
end
 

vegas

Известный
Автор темы
637
444
На каком этапе все остаётся? Функция норм работает
скинь полностью код
Код:
function samp.onShowDialog(id, style, title, button1, button2, text)
if id == 162 and title:find('Мой транспорт') then
        text = numeracia(text)
        return {id, style, title, button1, button2, text}
    end
end

function numeracia(text)
    line = 0
    for S in text:gmatch("[^\n]+") do
        line = line + 1
        local replace = ''..line..'. '..S..''
        print(replace)
        text = string.gsub(text, S, replace)
    end
    return text
end

Вот диалог

1611637646374.png
 

Hatiko

Известный
Проверенный
1,472
611
Попробуй. Заменишь на свои переменные.

Lua:
-- внутри события
if tit:find("Мой транспорт") then
    local text = {}
    local num = 1
    for line in tx:gmatch("[^\n\r]+") do
    table.insert(text, num..". "..line)
    num = num + 1
    end
    return {id, st, tit, b1, b2, table.concat(text, "\n")}
end
 
  • Нравится
Реакции: vegas и Gorskin

vegas

Известный
Автор темы
637
444
Попробуй. Заменишь на свои переменные.

Lua:
-- внутри события
if tit:find("Мой транспорт") then
    local text = {}
    local num = 1
    for line in tx:gmatch("[^\n\r]+") do
    table.insert(text, num..". "..line)
    num = num + 1
    end
    return {id, st, tit, b1, b2, table.concat(text, "\n")}
end
Спасибо
1614498127976.png