Как объединить автообновление и сохранение тем в imgui

NikkiReuz

Участник
Автор темы
55
4
Версия SA-MP
  1. 0.3.7 (R1)
  2. 0.3.7-R2
  3. 0.3.7-R3
  4. 0.3.7-R4
Помогите пожалуйста, делаю собственный скрипт(сам я новичок). И пользуюсь туториалами TheChampGuess, он мне помог сделать автообновление скрипта через гитхаб, но я также добавил в скрипт изменение темы, которые сохраняются в inicfg. Так вот получился такой код, что и то, и то работает по отдельности, но вместе не может. Вот код:


lua:
local inicfg = require 'inicfg'
local directIni = 'config\\ReuzMenu.ini'
local ini = inicfg.load({
    settings = {
        theme = 1,
    },
}, directIni)
inicfg.save(ini, directIni)
local checked_radio = imgui.ImInt(ini.settings.theme)

-- Обновление
local dlstatus = require('moonloader').download_status

update_state = false

local script_vers = 3
local script_vers_text = "3"

local update_url = "https://raw.githubusercontent.com/Reuz0201/sampik/main/update.ini"
local update_path = getWorkingDirectory() .. "/update.ini"

local script_url = "https://github.com/Reuz0201/sampik/blob/main/ReuzMenu.lua?raw=true"
local script_path = thisScript().path

--Продолжение

 downloadUrlToFile(update_url, update_path, function(id, status)
        if status == dlstatus.STATUS_ENDDOWNLOADDATA then
            updateIni = inicfg.load(nil, update_path)
            if tonumber(updateIni.info.vers) > script_vers then
                sampAddChatMessage("{FF0000}[Menu]{FFFFFF}У скрипта обновление! Новая версия: " .. updateIni.info.vers_text, -1)
                update_state = true
            end
            os.remove(update_path)
        end
    end)

while true do
     wait(0)
    
     if update_state then
            downloadUrlToFile(script_url, script_path, function(id, status)
                if status == dlstatus.STATUS_ENDDOWNLOADDATA then
                    sampAddChatMessage("Скрипт успешно обновлен!", -1)
                    thisScript():reload()
                end
            end)
            break
        end


-- И вот темы:

imgui.Text(u8"Выберите вашу тему: "
   imgui.BeginChild("Themes", imgui.ImVec2(300, 180), true)
    for id, value in ipairs(themes.colorThemes) do
            if imgui.RadioButton((value), checked_radio, id) then
                themes.SwitchColorTheme(id)
                ini.settings.theme = id
                inicfg.save(ini, directIni)
            end
        end
        imgui.EndChild()
imgui.End()

хелп
 
Последнее редактирование: