Как искать во втором столбце диалога?

calambiaaa

Новичок
Автор темы
4
0
Версия MoonLoader
Другое
1746078977996.png

как найти строку, где будет определенное расстояние, заданное мной?
 
Решение
Lua:
function sampEvents.onShowDialog(id, style, title, button1, button2, text)
    if title:find('Важные места') then
        local prepText = string.gsub(text, '{......}', '')
        prepText = splitStringByLine(prepText)
        for key, value in pairs(prepText) do
            local distance = value:match('(%d+%.%d+) м%.')
            if distance ~= nil then
                -- ...
            end
        end
    end
end

function splitStringByLine(string)
    local splitText = {}
    for line in string:gmatch("([^\n]*)\n?") do
        if line ~= "" or #splitText == 0 or string:sub(-1) == "\n" then
            table.insert(splitText, line)
        end
    end
    return splitText
end

Неадекватная сова

Известный
Проверенный
291
235
Lua:
function sampEvents.onShowDialog(id, style, title, button1, button2, text)
    if title:find('Важные места') then
        local prepText = string.gsub(text, '{......}', '')
        prepText = splitStringByLine(prepText)
        for key, value in pairs(prepText) do
            local distance = value:match('(%d+%.%d+) м%.')
            if distance ~= nil then
                -- ...
            end
        end
    end
end

function splitStringByLine(string)
    local splitText = {}
    for line in string:gmatch("([^\n]*)\n?") do
        if line ~= "" or #splitText == 0 or string:sub(-1) == "\n" then
            table.insert(splitText, line)
        end
    end
    return splitText
end