imgui; почему не работает?

WOUB1E

Известный
Автор темы
101
24
Code:
local imgui = require('imgui')
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
imgui.Process = false

local text = "TestTest"

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    wait(1000)
    sampAddChatMessage("load", -1)
    sampRegisterChatCommand("qweqwe", cmd_imgui)
    
    while true do
        wait(0)
        
        if main_window_state.v == false then
            imgui.Process = false
        end
        
    end
end
    
function cmd_imgui(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
end
    
function imgui.OnDrawFrame()
    imgui.Begin("Test", main_window_state.v)
    imgui.Text(text)
    imgui.End()
end

[ML] (error) Test.lua: ...es\ARIZONA GAMES\bin\Arizona - êîïèÿ\moonloader\Test.lua:19: attempt to index global 'main_window_state' (a nil value)
stack traceback:
...es\ARIZONA GAMES\bin\Arizona - êîïèÿ\moonloader\Test.lua: in function <...es\ARIZONA GAMES\bin\Arizona - êîïèÿ\moonloader\Test.lua:9>
[ML] (error) Test.lua: Script died due to an error. (2253FAFC)
 
Решение
Code:
local imgui = require('imgui')
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
imgui.Process = false

local text = "TestTest"

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    wait(1000)
    sampAddChatMessage("load", -1)
    sampRegisterChatCommand("qweqwe", cmd_imgui)
  
    while true do
        wait(0)
      
        if main_window_state.v == false then
            imgui.Process = false
        end
      
    end
end
  
function cmd_imgui(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
end
  
function imgui.OnDrawFrame()
    imgui.Begin("Test"...

Rice.

Известный
Модератор
1,753
1,660
Code:
local imgui = require('imgui')
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
imgui.Process = false

local text = "TestTest"

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end
    wait(1000)
    sampAddChatMessage("load", -1)
    sampRegisterChatCommand("qweqwe", cmd_imgui)
  
    while true do
        wait(0)
      
        if main_window_state.v == false then
            imgui.Process = false
        end
      
    end
end
  
function cmd_imgui(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
end
  
function imgui.OnDrawFrame()
    imgui.Begin("Test", main_window_state.v)
    imgui.Text(text)
    imgui.End()
end

[ML] (error) Test.lua: ...es\ARIZONA GAMES\bin\Arizona - êîïèÿ\moonloader\Test.lua:19: attempt to index global 'main_window_state' (a nil value)
stack traceback:
...es\ARIZONA GAMES\bin\Arizona - êîïèÿ\moonloader\Test.lua: in function <...es\ARIZONA GAMES\bin\Arizona - êîïèÿ\moonloader\Test.lua:9>
[ML] (error) Test.lua: Script died due to an error. (2253FAFC)
Зарегистрируй переменную своего окна в начале скрипта:
Lua:
local main_window_state = imgui.ImBool(false)