Вопрос по text:match

shadow80962

Известный
Автор темы
129
14
Версия MoonLoader
.026-beta
Как сделать что-бы dataWindowReport.text = text:match('Текст: (.+)') брало только я 1 строки текст, так как на 2 у меня автор репорта

Lua:
    if dialogId == 32700 and title:find('{......}Ответ') then
        dataWindowReport.nickname = text:match('- Прислал: (.+)')
        dataWindowReport.text = text:match('Текст: (.+)')
        Window_Report[0] = true
        return false
    end

Вот скрин диалогаПосмотреть вложение 162520
 
Решение
Как сделать что-бы dataWindowReport.text = text:match('Текст: (.+)') брало только я 1 строки текст, так как на 2 у меня автор репорта

Lua:
    if dialogId == 32700 and title:find('{......}Ответ') then
        dataWindowReport.nickname = text:match('- Прислал: (.+)')
        dataWindowReport.text = text:match('Текст: (.+)')
        Window_Report[0] = true
        return false
    end

Вот скрин диалогаПосмотреть вложение 162520
Lua:
function samp.onShowDialog(dialogId, style, title, button1, button2, text)
    if dialogId == 32700 and title:find('{......}Ответ') then
        for line in text:gmatch("[^\n]+") do
            dataWindowReport.nickname = line:match('- Прислал: (.+)')
            dataWindowReport.text = line:match('Текст: (.+)')...

Rice.

Известный
Модератор
1,753
1,662
Как сделать что-бы dataWindowReport.text = text:match('Текст: (.+)') брало только я 1 строки текст, так как на 2 у меня автор репорта

Lua:
    if dialogId == 32700 and title:find('{......}Ответ') then
        dataWindowReport.nickname = text:match('- Прислал: (.+)')
        dataWindowReport.text = text:match('Текст: (.+)')
        Window_Report[0] = true
        return false
    end

Вот скрин диалогаПосмотреть вложение 162520
Lua:
function samp.onShowDialog(dialogId, style, title, button1, button2, text)
    if dialogId == 32700 and title:find('{......}Ответ') then
        for line in text:gmatch("[^\n]+") do
            dataWindowReport.nickname = line:match('- Прислал: (.+)')
            dataWindowReport.text = line:match('Текст: (.+)')
        end
        Window_Report[0] = true
        return false
    end
end
Либо:
Lua:
function samp.onShowDialog(dialogId, style, title, button1, button2, text)
    if dialogId == 32700 and title:find('{......}Ответ') then
        dataWindowReport.nickname = text:match('- Прислал: (.+)')
        dataWindowReport.text = text:match('Текст: (.+)\n%s*%-')
        Window_Report[0] = true
        return false
    end
end
 
  • Нравится
Реакции: shadow80962