Ошибка в скрипте Lua

Sct.L

Новичок
Автор темы
7
1
Делаю почти первый скрипт для себя вроде всё правильно но пишет ошибку
Lua:
require 'lib.moonloader'
local inicfg = require 'inicfg'
local imgui = require 'imgui'
encoding            = require "encoding"
encoding.default    = "CP1251"
u8                    = encoding.UTF8
local hook = require 'lib.samp.events'
vkeys = require("vkeys")
rkeys = require("rkeys")
local window_first = imgui.ImBool(false)
local tag = '{00FF00}[Goverment Helper]:{FFFFFF}'
------------------[Cfg]--------------------------
local f_ini         = getGameDirectory().."\\moonloader\\config\\Goverment\\settings.ini"
ini = {
    settings = {
        buf_com = No,
    }
}
local config = inicfg.load(nil, f_ini)
------------------[Cfg]--------------------------

------------------[Buffers/Int]------------------
local buf_com    = imgui.ImBuffer('' .. ini.settings.buf_com, 256)
------------------[Buffers/Int]------------------
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampAddChatMessage(tag .. 'Срипт загружен!', -1)
    sampAddChatMessage(tag .. 'Активация /gover.', -1)
    sampRegisterChatCommand('gover', function()
        window_first.v = not window_first.v
        imgui.Process = window_first.v
    end)
   
--------------[Cfg2]--------------
if config == nil then
        createDirectory(getGameDirectory().."\\moonloader\\config\\Goverment")
        local f = io.open(f_ini, "w")
        f:close()
        if inicfg.save(ini, f_ini) then
            config = inicfg.load(nil, f_ini)
        end
        print("Created default settings.ini")
    end
--------------[Cfg2]--------------
    while true do
        wait(1)
        if window_first.v == false then
        imgui.Process = false
        end
    end
end

function imgui.OnDrawFrame()
if window_first.v then
    imgui.Begin('Goverment Helper', window_first, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
    imgui.InputText("Команда для теста #1", buf_com)
    imgui.End()
end
end

Ошибка:
[ML] (error) goverment.lua: C:\GTA\moonloader\goverment.lua:23: attempt to concatenate field 'buf_com' (a nil value)
stack traceback:
 

Moorell

Участник
55
12
Делаю почти первый скрипт для себя вроде всё правильно но пишет ошибку
Lua:
require 'lib.moonloader'
local inicfg = require 'inicfg'
local imgui = require 'imgui'
encoding            = require "encoding"
encoding.default    = "CP1251"
u8                    = encoding.UTF8
local hook = require 'lib.samp.events'
vkeys = require("vkeys")
rkeys = require("rkeys")
local window_first = imgui.ImBool(false)
local tag = '{00FF00}[Goverment Helper]:{FFFFFF}'
------------------[Cfg]--------------------------
local f_ini         = getGameDirectory().."\\moonloader\\config\\Goverment\\settings.ini"
ini = {
    settings = {
        buf_com = No,
    }
}
local config = inicfg.load(nil, f_ini)
------------------[Cfg]--------------------------

------------------[Buffers/Int]------------------
local buf_com    = imgui.ImBuffer('' .. ini.settings.buf_com, 256)
------------------[Buffers/Int]------------------
function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    sampAddChatMessage(tag .. 'Срипт загружен!', -1)
    sampAddChatMessage(tag .. 'Активация /gover.', -1)
    sampRegisterChatCommand('gover', function()
        window_first.v = not window_first.v
        imgui.Process = window_first.v
    end)
  
--------------[Cfg2]--------------
if config == nil then
        createDirectory(getGameDirectory().."\\moonloader\\config\\Goverment")
        local f = io.open(f_ini, "w")
        f:close()
        if inicfg.save(ini, f_ini) then
            config = inicfg.load(nil, f_ini)
        end
        print("Created default settings.ini")
    end
--------------[Cfg2]--------------
    while true do
        wait(1)
        if window_first.v == false then
        imgui.Process = false
        end
    end
end

function imgui.OnDrawFrame()
if window_first.v then
    imgui.Begin('Goverment Helper', window_first, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
    imgui.InputText("Команда для теста #1", buf_com)
    imgui.End()
end
end

Ошибка:
[ML] (error) goverment.lua: C:\GTA\moonloader\goverment.lua:23: attempt to concatenate field 'buf_com' (a nil value)
stack traceback:
16 строка buf_com = No, а нужно buf_com = "No"