imgui и диалог

Kecer

Участник
Автор темы
241
11
Версия MoonLoader
.026-beta
Как получить текст из диалога и вывести его в imgui?
 
Решение
Как получить текст из диалога и вывести его в imgui?
Lua:
local sampev = require 'lib.samp.events'
local text_dialog = ''
function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
    if text:find('') then
        text_dialog = text
    end
end

-- imgui
imgui.Text(text_dialog)

Либо этот вариант:

Lua:
local sampev = require 'lib.samp.events'
local text_dialog = {}
function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
    if text:find('') then
        text_dialog = {}
        for line in text:gmatch("[^\n]+") do
            table.insert(text_dialog, line)
        end
    end
end

-- imgui
for k, v in ipairs(text_dialog) do
    imgui.Text(v)
end

Rice.

Известный
Модератор
1,699
1,467
Как получить текст из диалога и вывести его в imgui?
Lua:
local sampev = require 'lib.samp.events'
local text_dialog = ''
function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
    if text:find('') then
        text_dialog = text
    end
end

-- imgui
imgui.Text(text_dialog)

Либо этот вариант:

Lua:
local sampev = require 'lib.samp.events'
local text_dialog = {}
function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
    if text:find('') then
        text_dialog = {}
        for line in text:gmatch("[^\n]+") do
            table.insert(text_dialog, line)
        end
    end
end

-- imgui
for k, v in ipairs(text_dialog) do
    imgui.Text(v)
end
 
Последнее редактирование:

Kecer

Участник
Автор темы
241
11
Lua:
local sampev = require 'lib.samp.events'
local text_dialog = ''
function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
    if text:find('') then
        text_dialog = text
    end
end

-- imgui
imgui.Text(text_dialog)

Либо этот вариант:

Lua:
local sampev = require 'lib.samp.events'
local text_dialog = {}
function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
    if text:find('') then
        text_dialog = {}
        for line in text:gmatch("[^\n]+") do
            table.insert(text_dialog, line)
        end
    end
end

-- imgui
for k, v in ipairs(text_dialog) do
    imgui.Text(v)
end
Напримере первого, это мне получается в text:find нужно ввести, то что он должен найти в диалоге, верно?
 

Kecer

Участник
Автор темы
241
11
Lua:
local sampev = require 'lib.samp.events'
local text_dialog = ''
function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
    if text:find('') then
        text_dialog = text
    end
end

-- imgui
imgui.Text(text_dialog)

Либо этот вариант:

Lua:
local sampev = require 'lib.samp.events'
local text_dialog = {}
function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
    if text:find('') then
        text_dialog = {}
        for line in text:gmatch("[^\n]+") do
            table.insert(text_dialog, line)
        end
    end
end

-- imgui
for k, v in ipairs(text_dialog) do
    imgui.Text(v)
end
и ещё, как сделать что бы оно брало информацию с определённого диалога?
 

Kecer

Участник
Автор темы
241
11
сделать проверку на опред.диалог, сделать проверку на его ид, стиль и т.д.
Lua:
local sampev = require 'lib.samp.events'
local text_dialog = ''
function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
    if dialogId = 0 and text:find('') then
        text_dialog = text
    end
end

-- imgui
imgui.Text(text_dialog)
Так норм будет, или есть пример по лучше?
 

Rice.

Известный
Модератор
1,699
1,467
Lua:
local sampev = require 'lib.samp.events'
local text_dialog = ''
function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
    if dialogId = 0 and text:find('') then
        text_dialog = text
    end
end

-- imgui
imgui.Text(text_dialog)
Так норм будет, или есть пример по лучше?
Lua:
if dialogId == 0 and text:find('') then