Проверка

Neil_

Активный
Автор темы
201
30
Версия MoonLoader
Другое
У меня есть такой код

Lua:
function ev.onShowDialog(id,style,title,b1,b2,text)
    if title:find('Покупка предмета') then
        if text:find('Предмет: {%x-}(.-){%x-}\n') or text:find('Аксессуар: {%x-}(.-){%x-}\n') then
            if text:find('Стоимость: $(.+) за %d+ шт%.') then
                if text:find('%- Улучшение: {%x+}(%d+)/%d+') then
                    price, item, sharpening = text:match('Стоимость: $(.+) за %d+ шт%.'), text:match('Предмет: {%x-}(.-){%x-}\n') or text:match('Аксессуар: {%x-}(.-){%x-}\n'), text:match('%- Улучшение: {%x+}(%d+)/%d+')
                    table_insert_aks(list,{price = price:gsub('%.', ''), item = item, sharpening = sharpening})
                    json('test2.json'):Save(list)
                else
                    price, item = text:match('Стоимость: $(.+) за %d+ шт%.'), text:match('Предмет: {%x-}(.-){%x-}\n')
                    table_insert(list,{price = price:gsub('%.', ''), item = item})
                    json('test2.json'):Save(list)
                end
            end
            count, list_price = 0, {}
            for i = 1, #list do
                if list[i].item == item then
                    count = count + 1
                    price = tonumber(list[i].price)
                    table.insert(list_price, price)
                end
                if list[i].item == item and list[i].sharpening == sharpening and sharpening ~= nil then
                    sampAddChatMessage(list[i].item..' +'..list[i].sharpening..' | $'..list[i].price,-1)
                end
            end
            if count > 1 then
                a_price = sum(list_price)/count
                a_price = math.modf(a_price)
                a_price = math.floor(a_price)
                if not text:find('%- Улучшение: {%x+}(%d+)/%d+') then
                    text = text:gsub('Стоимость: $(.+) за %d+ шт%.', '%0     {FFDAB9}~('..a_price..'$)')
                    return {id,style,title,b1,b2,text}
                end
            else
                text = text:gsub('Стоимость: $(.+) за %d+ шт%.', '%0     {FFDAB9}~(Нету данных)')
                return {id,style,title,b1,b2,text}
            end
        end
    end
end
Desktop Screenshot 2022.10.07 - 01.35.24.14.png
Как не выводить ~(нету данных), если это аксессуар, я полностью запутался в этом всем
Из аксессуаром в типе предмет получилось, из аксессуаром нет(
 

Вложения

  • Desktop Screenshot 2022.10.07 - 01.35.38.67.png
    Desktop Screenshot 2022.10.07 - 01.35.38.67.png
    999.2 KB · Просмотры: 11
Решение
У меня есть такой код

Lua:
function ev.onShowDialog(id,style,title,b1,b2,text)
    if title:find('Покупка предмета') then
        if text:find('Предмет: {%x-}(.-){%x-}\n') or text:find('Аксессуар: {%x-}(.-){%x-}\n') then
            if text:find('Стоимость: $(.+) за %d+ шт%.') then
                if text:find('%- Улучшение: {%x+}(%d+)/%d+') then
                    price, item, sharpening = text:match('Стоимость: $(.+) за %d+ шт%.'), text:match('Предмет: {%x-}(.-){%x-}\n') or text:match('Аксессуар: {%x-}(.-){%x-}\n'), text:match('%- Улучшение: {%x+}(%d+)/%d+')
                    table_insert_aks(list,{price = price:gsub('%.', ''), item = item, sharpening = sharpening})
                    json('test2.json'):Save(list)...

Loocking

Известный
1,376
472
У меня есть такой код

Lua:
function ev.onShowDialog(id,style,title,b1,b2,text)
    if title:find('Покупка предмета') then
        if text:find('Предмет: {%x-}(.-){%x-}\n') or text:find('Аксессуар: {%x-}(.-){%x-}\n') then
            if text:find('Стоимость: $(.+) за %d+ шт%.') then
                if text:find('%- Улучшение: {%x+}(%d+)/%d+') then
                    price, item, sharpening = text:match('Стоимость: $(.+) за %d+ шт%.'), text:match('Предмет: {%x-}(.-){%x-}\n') or text:match('Аксессуар: {%x-}(.-){%x-}\n'), text:match('%- Улучшение: {%x+}(%d+)/%d+')
                    table_insert_aks(list,{price = price:gsub('%.', ''), item = item, sharpening = sharpening})
                    json('test2.json'):Save(list)
                else
                    price, item = text:match('Стоимость: $(.+) за %d+ шт%.'), text:match('Предмет: {%x-}(.-){%x-}\n')
                    table_insert(list,{price = price:gsub('%.', ''), item = item})
                    json('test2.json'):Save(list)
                end
            end
            count, list_price = 0, {}
            for i = 1, #list do
                if list[i].item == item then
                    count = count + 1
                    price = tonumber(list[i].price)
                    table.insert(list_price, price)
                end
                if list[i].item == item and list[i].sharpening == sharpening and sharpening ~= nil then
                    sampAddChatMessage(list[i].item..' +'..list[i].sharpening..' | $'..list[i].price,-1)
                end
            end
            if count > 1 then
                a_price = sum(list_price)/count
                a_price = math.modf(a_price)
                a_price = math.floor(a_price)
                if not text:find('%- Улучшение: {%x+}(%d+)/%d+') then
                    text = text:gsub('Стоимость: $(.+) за %d+ шт%.', '%0     {FFDAB9}~('..a_price..'$)')
                    return {id,style,title,b1,b2,text}
                end
            else
                text = text:gsub('Стоимость: $(.+) за %d+ шт%.', '%0     {FFDAB9}~(Нету данных)')
                return {id,style,title,b1,b2,text}
            end
        end
    end
end
Посмотреть вложение 172110Как не выводить ~(нету данных), если это аксессуар, я полностью запутался в этом всем
Из аксессуаром в типе предмет получилось, из аксессуаром нет(
Проверку на слово Аксессуар добавь
 
  • Нравится
Реакции: ARMOR