Вопросы по Lua скриптингу

Общая тема для вопросов по разработке скриптов на языке программирования Lua, в частности под MoonLoader.
  • Задавая вопрос, убедитесь, что его нет в списке частых вопросов и что на него ещё не отвечали (воспользуйтесь поиском).
  • Поищите ответ в теме посвященной разработке Lua скриптов в MoonLoader
  • Отвечая, убедитесь, что ваш ответ корректен.
  • Старайтесь как можно точнее выразить мысль, а если проблема связана с кодом, то обязательно прикрепите его к сообщению, используя блок [code=lua]здесь мог бы быть ваш код[/code].
  • Если вопрос связан с MoonLoader-ом первым делом желательно поискать решение на wiki.

Частые вопросы

Как научиться писать скрипты? С чего начать?
Информация - Гайд - Всё о Lua скриптинге для MoonLoader(https://blast.hk/threads/22707/)
Как вывести текст на русском? Вместо русского текста у меня какие-то каракули.
Изменить кодировку файла скрипта на Windows-1251. В Atom: комбинация клавиш Ctrl+Shift+U, в Notepad++: меню Кодировки -> Кодировки -> Кириллица -> Windows-1251.
Как получить транспорт, в котором сидит игрок?
Lua:
local veh = storeCarCharIsInNoSave(PLAYER_PED)
Как получить свой id или id другого игрока?
Lua:
local _, id = sampGetPlayerIdByCharHandle(PLAYER_PED) -- получить свой ид
local _, id = sampGetPlayerIdByCharHandle(ped) -- получить ид другого игрока. ped - это хендл персонажа
Как проверить, что строка содержит какой-то текст?
Lua:
if string.find(str, 'текст', 1, true) then
-- строка str содержит "текст"
end
Как эмулировать нажатие игровой клавиши?
Lua:
local game_keys = require 'game.keys' -- где-нибудь в начале скрипта вне функции main

setGameKeyState(game_keys.player.FIREWEAPON, -1) -- будет сэмулировано нажатие клавиши атаки
Все иды клавиш находятся в файле moonloader/lib/game/keys.lua.
Подробнее о функции setGameKeyState здесь: lua - setgamekeystate | BlastHack — DEV_WIKI(https://www.blast.hk/wiki/lua:setgamekeystate)
Как получить id другого игрока, в которого целюсь я?
Lua:
local valid, ped = getCharPlayerIsTargeting(PLAYER_HANDLE) -- получить хендл персонажа, в которого целится игрок
if valid and doesCharExist(ped) then -- если цель есть и персонаж существует
  local result, id = sampGetPlayerIdByCharHandle(ped) -- получить samp-ид игрока по хендлу персонажа
  if result then -- проверить, прошло ли получение ида успешно
    -- здесь любые действия с полученным идом игрока
  end
end
Как зарегистрировать команду чата SAMP?
Lua:
-- До бесконечного цикла/задержки
sampRegisterChatCommand("mycommand", function (param)
     -- param будет содержать весь текст введенный после команды, чтобы разделить его на аргументы используйте string.match()
    sampAddChatMessage("MyCMD", -1)
end)
Крашит игру при вызове sampSendChat. Как это исправить?
Это происходит из-за бага в SAMPFUNCS, когда производится попытка отправки пакета определенными функциями изнутри события исходящих RPC и пакетов. Исправления для этого бага нет, но есть способ не провоцировать его. Вызов sampSendChat изнутри обработчика исходящих RPC/пакетов нужно обернуть в скриптовый поток с нулевой задержкой:
Lua:
function onSendRpc(id)
  -- крашит:
  -- sampSendChat('Send RPC: ' .. id)

  -- норм:
  lua_thread.create(function()
    wait(0)
    sampSendChat('Send RPC: ' .. id)
  end)
end
 
Последнее редактирование:

Myroslaw

Известный
133
5

PanSeek

t.me/dailypanseek
Всефорумный модератор
899
1,747
Мне просто интересно писать скриптЬІ, я нехочу себе еупрощать игру, мне просто интересно писать, но я особо не умею
Просто не пойму что именно не работает.
А сократить можно так:
Lua:
sampRegisterChatCommand("c", function() sampSendChat("/clist 0") end)
sampRegisterChatCommand("ad", function() sampSendChat("/admins") end)
sampRegisterChatCommand("vs", function() sampSendChat("/vehspawn") end)
sampRegisterChatCommand("mr", function() sampSendChat("/members") end)
sampRegisterChatCommand("use", function() sampSendChat("/usemedkit") end)
sampRegisterChatCommand("fi", function(arg) sampSendChat('/finvite '..arg) end)
sampRegisterChatCommand('fm', function() sampSendChat('/fmembers') end)
sampRegisterChatCommand('ac', function() sampSendChat('/accept') end)
sampRegisterChatCommand('re', function(arg) sampSendChat('/repairengine '..arg) end)
sampRegisterChatCommand('nc', function(arg) sampSendChat('/newcolor '..arg) end)
sampRegisterChatCommand('nn', function(arg) sampSendChat('/newnumber '..arg) end)
sampRegisterChatCommand('rep', function(arg) sampSendChat('/repair '..arg) end)
sampRegisterChatCommand('sd', function() sampSendChat('/speed') end)
sampRegisterChatCommand('fgb', function() sampSendChat('/fgivebank') end)
sampRegisterChatCommand('ftb', function() sampSendChat('/ftakebank') end)
sampRegisterChatCommand('gr', function(arg) sampSendChat('/giverank '..arg) end)
И внизу удалить функции. Когда выполняется маленькое (в одну строчку например) действие, так же проще и удобнее.
 

Myroslaw

Известный
133
5
как можно сделать, что б сервер думал что я нажимаю клавишу, но я ее не наажимал, я знаю что есть setVirtualKeyDown(16, true), но оно зажимает, а мне надо что б нажало, и отжало, вот так делать нехочу setVirtualKeyDown(16, true) setVirtualKeyDown(16, false)
 

ADscripts

Известный
37
13
как можно сделать, что б сервер думал что я нажимаю клавишу, но я ее не наажимал, я знаю что есть setVirtualKeyDown(16, true), но оно зажимает, а мне надо что б нажало, и отжало, вот так делать нехочу setVirtualKeyDown(16, true) setVirtualKeyDown(16, false)
 

tsunamiqq

Участник
429
16
Lua:
script_name('FamilyHelper v 1.0')
script_author('Tsunami_Nakamura')
script_description('FamilyHelper v 1.0')
script_version('1.0')

require "lib.moonloader"
local imgui = require 'imgui'
local key = require 'vkeys'

local main_window_state = imgui.ImBool(false)
function imgui.OnDrawFrame()
  if main_window_state.v then
    imgui.SetNextWindowSize(imgui.ImVec2(1000, 500), imgui.Cond.FirstUseEver)
    imgui.Begin('Family Helper by Nakamura', main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
    end
    imgui.End()
  end

function main()
  imgui.Process = true
end


function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(2000) end
    sampAddChatMessage('[FamHelper] ????? ???????: Tsunami_Nakamura. ????????: Adam_Karleone [ARIZONA 10]', 0x00BFFF)
    sampAddChatMessage('[FamHelper] ???? ???????? ?? - lcn.maks', 0x00BFFF)
    sampAddChatMessage('[FamHelper] ????????? ???????: /famh', 0x00BFFF)
    sampAddChatMessage('[FamHelper] ?????? ?? ?????????? ?????? ? ??', 0x00BFFF)
    sampRegisterChatCommand('famh', function() main_window_state.v = not main_window_state.v end)
    while true do
            wait(0)
            if main_window_state.v then
                imgui.ShowCursor = true
      imgui.Process = true
    else
      imgui.Process = false
    end
            imgui.Process = main_window_state.v
    end
end

Помогите сделать кнопки, я делаю, а у меня чет не выходит..
 

PanSeek

t.me/dailypanseek
Всефорумный модератор
899
1,747
Lua:
script_name('FamilyHelper v 1.0')
script_author('Tsunami_Nakamura')
script_description('FamilyHelper v 1.0')
script_version('1.0')

require "lib.moonloader"
local imgui = require 'imgui'
local key = require 'vkeys'

local main_window_state = imgui.ImBool(false)
function imgui.OnDrawFrame()
  if main_window_state.v then
    imgui.SetNextWindowSize(imgui.ImVec2(1000, 500), imgui.Cond.FirstUseEver)
    imgui.Begin('Family Helper by Nakamura', main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
    end
    imgui.End()
  end

function main()
  imgui.Process = true
end


function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(2000) end
    sampAddChatMessage('[FamHelper] ????? ???????: Tsunami_Nakamura. ????????: Adam_Karleone [ARIZONA 10]', 0x00BFFF)
    sampAddChatMessage('[FamHelper] ???? ???????? ?? - lcn.maks', 0x00BFFF)
    sampAddChatMessage('[FamHelper] ????????? ???????: /famh', 0x00BFFF)
    sampAddChatMessage('[FamHelper] ?????? ?? ?????????? ?????? ? ??', 0x00BFFF)
    sampRegisterChatCommand('famh', function() main_window_state.v = not main_window_state.v end)
    while true do
            wait(0)
            if main_window_state.v then
                imgui.ShowCursor = true
      imgui.Process = true
    else
      imgui.Process = false
    end
            imgui.Process = main_window_state.v
    end
end

Помогите сделать кнопки, я делаю, а у меня чет не выходит..
Lua:
--params imgui
local checkbox = imgui.ImBool(false)

--OnFrame
imgui.Checkbox('test checkbox', checkbox)
imgui.Button('test button')

--[[ привязать действие к кнопки можно так:
if imgui.Button('button') then
    print('test')
end ]]
 

Myroslaw

Известный
133
5
РЕбята, вот у мня виполняєтся один код, как сделать, если я наажимаю кнопку, чтоб етот код прекращался, и начинался другой
Lua:
        act = not act
        if act then
            if isKeyJustPressed(6) then
                setVirtualKeyDown(18, true)
                setVirtualKeyDown(16, true)
                    wait(0)
                setVirtualKeyDown(16, false)
                wait(250)
                setVirtualKeyDown(16, true)
                    wait(0)
                setVirtualKeyDown(16, false)
                setVirtualKeyDown(18, false)
                    wait(20)
                sampSendChat('/sroll')
            end
        end
    end
ТИпо вот так надо
Lua:
        act = not act
        if act then
            if isKeyJustPressed(6) then
                setVirtualKeyDown(18, true)
                setVirtualKeyDown(16, true)
                    wait(0)
                setVirtualKeyDown(16, false)
                wait(250)
                setVirtualKeyDown(16, true)
                    wait(0)
                setVirtualKeyDown(16, false)
                setVirtualKeyDown(18, false)
                    wait(20)
                sampSendChat('/sroll')
            end
            if not act then
                sampSendChat('Додик')
            end
        end
    end
Но как ето правильно сделать
 

PanSeek

t.me/dailypanseek
Всефорумный модератор
899
1,747
/code
script_name('FamilyHelper v 1.0')
script_author('Tsunami_Nakamura')
script_description('FamilyHelper v 1.0')
script_version('1.0')

require "lib.moonloader"
local imgui = require 'imgui'
local key = require 'vkeys'

local main_window_state = imgui.ImBool(false)
function imgui.OnDrawFrame()
local iScreenWidth, iScreenHeight = getScreenResolution()
local btn_size = imgui.ImVec2(-1, 0)
if main_window_state.v then
imgui.SetNextWindowSize(imgui.ImVec2(1000, 500), imgui.Cond.FirstUseEver)
imgui.Begin('Family Helper by Nakamura', main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
end
imgui.End()
end

local checkbox = imgui.ImBool(false)

imgui.Checkbox('Test', checkbox)
imgui.Button('Меню')

if imgui.Button('Менюшка') then
print('Тест')
end


function main()
imgui.Process = true
end


function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
while not isSampAvailable() do wait(2000) end
sampAddChatMessage('[FamHelper] ????? ???????: Tsunami_Nakamura. ????????: Adam_Karleone [ARIZONA 10]', 0x00BFFF)
sampAddChatMessage('[FamHelper] ???? ???????? ?? - lcn.maks', 0x00BFFF)
sampAddChatMessage('[FamHelper] ????????? ???????: /famh', 0x00BFFF)
sampAddChatMessage('[FamHelper] ?????? ?? ?????????? ?????? ? ??', 0x00BFFF)
sampRegisterChatCommand('famh', function() main_window_state.v = not main_window_state.v end)
while true do
wait(0)
if main_window_state.v then
imgui.ShowCursor = true
imgui.Process = true
else
imgui.Process = false
end
imgui.Process = main_window_state.v
end
end

Тип так? Но если да, то оно крашит..
Я же написал, что в Frame.
Lua:
script_name('FamilyHelper v 1.0')
script_author('Tsunami_Nakamura')
script_description('FamilyHelper v 1.0')
script_version('1.0')

require "lib.moonloader"
local imgui = require 'imgui'
local key = require 'vkeys'

local main_window_state = imgui.ImBool(false)
local checkbox = imgui.ImBool(false)

function imgui.OnDrawFrame()
    local iScreenWidth, iScreenHeight = getScreenResolution()
    local btn_size = imgui.ImVec2(-1, 0)
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(1000, 500), imgui.Cond.FirstUseEver)
        imgui.Begin('Family Helper by Nakamura', main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
        if imgui.Button('Hello') then
            sampAddChatMessage('Hi :)', -1)
        end
        imgui.Checkbox('Test', checkbox)
    end
    imgui.End()
end

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(2000) end

    sampAddChatMessage('[FamHelper] ????? ???????: Tsunami_Nakamura. ????????: Adam_Karleone [ARIZONA 10]', 0x00BFFF)
    sampAddChatMessage('[FamHelper] ???? ???????? ?? - lcn.maks', 0x00BFFF)
    sampAddChatMessage('[FamHelper] ????????? ???????: /famh', 0x00BFFF)
    sampAddChatMessage('[FamHelper] ?????? ?? ?????????? ?????? ? ??', 0x00BFFF)
    sampRegisterChatCommand('famh', function() main_window_state.v = not main_window_state.v end)

    while true do
        wait(0)

        imgui.Process = main_window_state.v and true or false

        if checkbox.v then
            printStringNow('test', 1000)
        end
    end
end
 

tsunamiqq

Участник
429
16
Я же написал, что в Frame.
Lua:
script_name('FamilyHelper v 1.0')
script_author('Tsunami_Nakamura')
script_description('FamilyHelper v 1.0')
script_version('1.0')

require "lib.moonloader"
local imgui = require 'imgui'
local key = require 'vkeys'

local main_window_state = imgui.ImBool(false)
local checkbox = imgui.ImBool(false)

function imgui.OnDrawFrame()
    local iScreenWidth, iScreenHeight = getScreenResolution()
    local btn_size = imgui.ImVec2(-1, 0)
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(1000, 500), imgui.Cond.FirstUseEver)
        imgui.Begin('Family Helper by Nakamura', main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
        if imgui.Button('Hello') then
            sampAddChatMessage('Hi :)', -1)
        end
        imgui.Checkbox('Test', checkbox)
    end
    imgui.End()
end

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(2000) end

    sampAddChatMessage('[FamHelper] ????? ???????: Tsunami_Nakamura. ????????: Adam_Karleone [ARIZONA 10]', 0x00BFFF)
    sampAddChatMessage('[FamHelper] ???? ???????? ?? - lcn.maks', 0x00BFFF)
    sampAddChatMessage('[FamHelper] ????????? ???????: /famh', 0x00BFFF)
    sampAddChatMessage('[FamHelper] ?????? ?? ?????????? ?????? ? ??', 0x00BFFF)
    sampRegisterChatCommand('famh', function() main_window_state.v = not main_window_state.v end)

    while true do
        wait(0)

        imgui.Process = main_window_state.v and true or false

        if checkbox.v then
            printStringNow('test', 1000)
        end
    end
end
Давай я тебе кину скрин по типу чего я хочу?
 

tsunamiqq

Участник
429
16
Я же написал, что в Frame.
Lua:
script_name('FamilyHelper v 1.0')
script_author('Tsunami_Nakamura')
script_description('FamilyHelper v 1.0')
script_version('1.0')

require "lib.moonloader"
local imgui = require 'imgui'
local key = require 'vkeys'

local main_window_state = imgui.ImBool(false)
local checkbox = imgui.ImBool(false)

function imgui.OnDrawFrame()
    local iScreenWidth, iScreenHeight = getScreenResolution()
    local btn_size = imgui.ImVec2(-1, 0)
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(1000, 500), imgui.Cond.FirstUseEver)
        imgui.Begin('Family Helper by Nakamura', main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
        if imgui.Button('Hello') then
            sampAddChatMessage('Hi :)', -1)
        end
        imgui.Checkbox('Test', checkbox)
    end
    imgui.End()
end

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(2000) end

    sampAddChatMessage('[FamHelper] ????? ???????: Tsunami_Nakamura. ????????: Adam_Karleone [ARIZONA 10]', 0x00BFFF)
    sampAddChatMessage('[FamHelper] ???? ???????? ?? - lcn.maks', 0x00BFFF)
    sampAddChatMessage('[FamHelper] ????????? ???????: /famh', 0x00BFFF)
    sampAddChatMessage('[FamHelper] ?????? ?? ?????????? ?????? ? ??', 0x00BFFF)
    sampRegisterChatCommand('famh', function() main_window_state.v = not main_window_state.v end)

    while true do
        wait(0)

        imgui.Process = main_window_state.v and true or false

        if checkbox.v then
            printStringNow('test', 1000)
        end
    end
end[/CODE[ATTACH type="full"]89338[/ATTACH]Мне такие кнопки над сделать.
[/QUOTE]
 

Вложения

  • 7BsQ3p3YMmg.png
    7BsQ3p3YMmg.png
    192.3 KB · Просмотры: 39

PanSeek

t.me/dailypanseek
Всефорумный модератор
899
1,747
Давай я тебе кину скрин по типу чего я хочу?
Lua:
script_name('FamilyHelper v 1.0')
script_author('Tsunami_Nakamura')
script_description('FamilyHelper v 1.0')
script_version('1.0')

require "lib.moonloader"
local imgui = require 'imgui'
local key = require 'vkeys'

local act = 0

local main_window_state = imgui.ImBool(false)
local checkbox = imgui.ImBool(false)

function imgui.OnDrawFrame()
    local iScreenWidth, iScreenHeight = getScreenResolution()
    local btn_size = imgui.ImVec2(-1, 0)
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(1000, 500), imgui.Cond.FirstUseEver)
        imgui.Begin('Family Helper by Nakamura', main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
        imgui.BeginChild('##tabs', imgui.ImVec2(120, 460), true)
        if imgui.Button('1 tab') then act = 0 end
        if imgui.Button('2 tab') then act = 1 end
        imgui.EndChild()
        imgui.SameLine()
        if act == 0 then
            imgui.BeginChild('##once', imgui.ImVec2(860, 460), true)
            imgui.Text('This is once tab')
            imgui.EndChild()
        elseif act == 1 then
            imgui.BeginChild('##twice', imgui.ImVec2(860, 460), true)
            imgui.Text('This is twice tab')
            imgui.EndChild()
        end
    end
    imgui.End()
end

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(2000) end

    sampAddChatMessage('[FamHelper] ????? ???????: Tsunami_Nakamura. ????????: Adam_Karleone [ARIZONA 10]', 0x00BFFF)
    sampAddChatMessage('[FamHelper] ???? ???????? ?? - lcn.maks', 0x00BFFF)
    sampAddChatMessage('[FamHelper] ????????? ???????: /famh', 0x00BFFF)
    sampAddChatMessage('[FamHelper] ?????? ?? ?????????? ?????? ? ??', 0x00BFFF)
    sampRegisterChatCommand('famh', function() main_window_state.v = not main_window_state.v end)

    while true do
        wait(0)

        imgui.Process = main_window_state.v and true or false

        if checkbox.v then
            printStringNow('test', 1000)
        end
    end
end
2021-03-13 22-35-39-205.png

2021-03-13 22-35-42-121.png
 

tsunamiqq

Участник
429
16
С
Lua:
script_name('FamilyHelper v 1.0')
script_author('Tsunami_Nakamura')
script_description('FamilyHelper v 1.0')
script_version('1.0')

require "lib.moonloader"
local imgui = require 'imgui'
local key = require 'vkeys'

local act = 0

local main_window_state = imgui.ImBool(false)
local checkbox = imgui.ImBool(false)

function imgui.OnDrawFrame()
    local iScreenWidth, iScreenHeight = getScreenResolution()
    local btn_size = imgui.ImVec2(-1, 0)
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(1000, 500), imgui.Cond.FirstUseEver)
        imgui.Begin('Family Helper by Nakamura', main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
        imgui.BeginChild('##tabs', imgui.ImVec2(120, 460), true)
        if imgui.Button('1 tab') then act = 0 end
        if imgui.Button('2 tab') then act = 1 end
        imgui.EndChild()
        imgui.SameLine()
        if act == 0 then
            imgui.BeginChild('##once', imgui.ImVec2(860, 460), true)
            imgui.Text('This is once tab')
            imgui.EndChild()
        elseif act == 1 then
            imgui.BeginChild('##twice', imgui.ImVec2(860, 460), true)
            imgui.Text('This is twice tab')
            imgui.EndChild()
        end
    end
    imgui.End()
end

function main()
    if not isSampfuncsLoaded() or not isSampLoaded() then return end
    while not isSampAvailable() do wait(2000) end

    sampAddChatMessage('[FamHelper] ????? ???????: Tsunami_Nakamura. ????????: Adam_Karleone [ARIZONA 10]', 0x00BFFF)
    sampAddChatMessage('[FamHelper] ???? ???????? ?? - lcn.maks', 0x00BFFF)
    sampAddChatMessage('[FamHelper] ????????? ???????: /famh', 0x00BFFF)
    sampAddChatMessage('[FamHelper] ?????? ?? ?????????? ?????? ? ??', 0x00BFFF)
    sampRegisterChatCommand('famh', function() main_window_state.v = not main_window_state.v end)

    while true do
        wait(0)

        imgui.Process = main_window_state.v and true or false

        if checkbox.v then
            printStringNow('test', 1000)
        end
    end
end
сяб, а со второго бока можешь сделать такую меню для кнопок?
 

PanSeek

t.me/dailypanseek
Всефорумный модератор
899
1,747
С

сяб, а со второго бока можешь сделать такую меню для кнопок?
Lua:
function imgui.OnDrawFrame()
    local iScreenWidth, iScreenHeight = getScreenResolution()
    local btn_size = imgui.ImVec2(-1, 0)
    if main_window_state.v then
        imgui.SetNextWindowSize(imgui.ImVec2(1000, 500), imgui.Cond.FirstUseEver)
        imgui.Begin('Family Helper by Nakamura', main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse)
        if act == 0 then
            imgui.BeginChild('##once', imgui.ImVec2(860, 460), true)
            imgui.Text('This is once tab')
            imgui.EndChild()
        elseif act == 1 then
            imgui.BeginChild('##twice', imgui.ImVec2(860, 460), true)
            imgui.Text('This is twice tab')
            imgui.EndChild()
        end
        imgui.SameLine()
        imgui.BeginChild('##tabs', imgui.ImVec2(120, 460), true)
        if imgui.Button('1 tab') then act = 0 end
        if imgui.Button('2 tab') then act = 1 end
        imgui.EndChild()
    end
    imgui.End()
end