IniCfg

By.Egorka

Участник
Автор темы
75
18
Версия MoonLoader
.026-beta
как сохронить кфг через imgui.Button()?

Говнокод:
local imgui = require 'imgui'
local key = require 'vkeys'
local ini = require 'inicfg'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local test_text_buffer = imgui.ImBuffer(800)
local main_window_state = imgui.ImBool(false)
function imgui.OnDrawFrame()
     if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(250, 400), imgui.Cond.FirstUseEver)
        imgui.Begin(u8"Шпоргалка", main_window_state)
        imgui.InputTextMultiline(u8"Шпоргалка", test_text_buffer)
        if imgui.Button("Save") then

        end
        imgui.End()
  end
end


function main()
  sampRegisterChatCommand("shpora", function()
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
  end)
end
 

Vespan

loneliness
Проверенный
2,140
1,783
11865dba7c946f83dbcec2845b2f5c94.jpg

Lua:
local imgui = require 'imgui'
local key = require 'vkeys'
local inicfg = require 'inicfg'
encoding = require("encoding"); encoding.default = 'CP1251'; u8 = encoding.UTF8
ini = inicfg.load({
    s = {
        text = 'ya eblan'
    }
},'shpora.ini')
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local test_text_buffer = imgui.ImBuffer(u8(ini.s.text),0xffff)
local main_window_state = imgui.ImBool(false)
function imgui.OnDrawFrame()
     if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(250, 400), imgui.Cond.FirstUseEver)
        imgui.Begin(u8"Шпоргалка", main_window_state)
        imgui.InputTextMultiline(u8"Шпоргалка", test_text_buffer)
        if imgui.Button("Save") then
            ini.s.text = u8:decode(test_text_buffer.v)
            inicfg.save(ini,'shpora.ini')
        end
        imgui.End()
  end
end


function main()
  sampRegisterChatCommand("shpora", function()
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
  end)
end
 
  • Нравится
Реакции: By.Egorka

By.Egorka

Участник
Автор темы
75
18
Посмотреть вложение 209397
Lua:
local imgui = require 'imgui'
local key = require 'vkeys'
local inicfg = require 'inicfg'
encoding = require("encoding"); encoding.default = 'CP1251'; u8 = encoding.UTF8
ini = inicfg.load({
    s = {
        text = 'ya eblan'
    }
},'shpora.ini')
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local test_text_buffer = imgui.ImBuffer(u8(ini.s.text),0xffff)
local main_window_state = imgui.ImBool(false)
function imgui.OnDrawFrame()
     if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(250, 400), imgui.Cond.FirstUseEver)
        imgui.Begin(u8"Шпоргалка", main_window_state)
        imgui.InputTextMultiline(u8"Шпоргалка", test_text_buffer)
        if imgui.Button("Save") then
            ini.s.text = u8:decode(test_text_buffer.v)
            inicfg.save(ini,'shpora.ini')
        end
        imgui.End()
  end
end


function main()
  sampRegisterChatCommand("shpora", function()
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
  end)
end
InputTextMultiline не сохраняется после перезагрузки скрипта