Крашит скрипт

Qwerty???

Участник
Автор темы
134
8
Версия MoonLoader
.027.0-preview
Крашит скрипт, добавил ToggleButton (Типо чекбокса) а скрипт начало крашить

[ML] (error) PossibleProject.lua: D:\Sborka by goose\moonloader\PossibleProject.lua:23: cannot convert 'string' to 'bool [1]'
stack traceback:
[C]: in function 'bool'
D:\Sborka by goose\moonloader\PossibleProject.lua:23: in main chunk
[ML] (error) PossibleProject.lua: Script died due to an error. (4AFCB564)

Код:
local inicfg = require 'inicfg'
local settings = inicfg.load({
    main =
    {
        checkboxstatus = false,
    }}, 'PossibleProject.ini')
local checkboxone = new.bool(settings.main.checkboxstatus)

    imgui.SetCursorPos(imgui.ImVec2(5, 125))
    if imgui.ToggleButton('Watermark', checkboxone) then

        settings.main.checkboxstatus = checkboxone[0]
        inicfg.save(settings, 'PossibleProject.ini')
    end

function imgui.ToggleButton(str_id, bool)
    local rBool = false

    if LastActiveTime == nil then
        LastActiveTime = {}
    end
    if LastActive == nil then
        LastActive = {}
    end

    local function ImSaturate(f)
        return f < 0.0 and 0.0 or (f > 1.0 and 1.0 or f)
    end

    local p = imgui.GetCursorScreenPos()
    local dl = imgui.GetWindowDrawList()

    local height = imgui.GetTextLineHeightWithSpacing()
    local width = height * 1.70
    local radius = height * 0.50
    local ANIM_SPEED = type == 2 and 0.10 or 0.15
    local butPos = imgui.GetCursorPos()

    if imgui.InvisibleButton(str_id, imgui.ImVec2(width, height)) then
        bool[0] = not bool[0]
        rBool = true
        LastActiveTime[tostring(str_id)] = os.clock()
        LastActive[tostring(str_id)] = true
    end

    imgui.SetCursorPos(imgui.ImVec2(butPos.x + width + 8, butPos.y + 2.5))
    imgui.Text( str_id:gsub('##.+', '') )

    local t = bool[0] and 1.0 or 0.0

    if LastActive[tostring(str_id)] then
        local time = os.clock() - LastActiveTime[tostring(str_id)]
        if time <= ANIM_SPEED then
            local t_anim = ImSaturate(time / ANIM_SPEED)
            t = bool[0] and t_anim or 1.0 - t_anim
        else
            LastActive[tostring(str_id)] = false
        end
    end

    local col_circle = bool[0] and imgui.ColorConvertFloat4ToU32(imgui.ImVec4(imgui.GetStyle().Colors[imgui.Col.ButtonActive])) or imgui.ColorConvertFloat4ToU32(imgui.ImVec4(imgui.GetStyle().Colors[imgui.Col.TextDisabled]))
    dl:AddRectFilled(p, imgui.ImVec2(p.x + width, p.y + height), imgui.ColorConvertFloat4ToU32(imgui.GetStyle().Colors[imgui.Col.FrameBg]), height * 0.5)
    dl:AddCircleFilled(imgui.ImVec2(p.x + radius + t * (width - radius * 2.0), p.y + radius), radius - 1.5, col_circle)
    return rBool
end
 

Qwerty???

Участник
Автор темы
134
8

AmbushMCZ

Новичок
1
0
Вроде-бы все предельно ясно, тебе сама ошибка говорит что ты пытаешься засунуть строку в булеан

Вроде-бы все предельно ясно, тебе сама ошибка говорит что ты пытаешься засунуть строку в булеан
И если тебе нужно решение, в лс мне отпиши discord: @AmbushMCZ
 

kirieshki.

Новичок
22
17
попробуй в PossibleProject.ini посмотреть как у тебя checkboxstatus записана если, true/false то все норм должно быть
у меня лично всё четко работает
1753791401585.png


Lua:
require('moonloader')
local imgui = require('mimgui')
local inicfg = require('inicfg')
local settings = inicfg.load({
    main =
    {
        checkboxstatus = false,
    }}, 'PossibleProject.ini')
local checkboxone = imgui.new.bool(settings.main.checkboxstatus)
local win = imgui.new.bool(true)
imgui.OnFrame(function() return win[0] end, function()
    imgui.Begin("##win")
    imgui.SetCursorPos(imgui.ImVec2(5, 125))
    if imgui.ToggleButton('Watermark', checkboxone) then
        settings.main.checkboxstatus = checkboxone[0]
        inicfg.save(settings, 'PossibleProject.ini')
    end
    imgui.End()
end
)
function main()
    sampRegisterChatCommand('openw', function()
        win[0] = not win[0]
    end)
end
function imgui.ToggleButton(str_id, bool)
    local rBool = false
    if LastActiveTime == nil then
        LastActiveTime = {}
    end
    if LastActive == nil then
        LastActive = {}
    end
    local function ImSaturate(f)
        return f < 0.0 and 0.0 or (f > 1.0 and 1.0 or f)
    end
    local p = imgui.GetCursorScreenPos()
    local dl = imgui.GetWindowDrawList()
    local height = imgui.GetTextLineHeightWithSpacing()
    local width = height * 1.70
    local radius = height * 0.50
    local ANIM_SPEED = type == 2 and 0.10 or 0.15
    local butPos = imgui.GetCursorPos()
    if imgui.InvisibleButton(str_id, imgui.ImVec2(width, height)) then
        bool[0] = not bool[0]
        rBool = true
        LastActiveTime[tostring(str_id)] = os.clock()
        LastActive[tostring(str_id)] = true
    end
    imgui.SetCursorPos(imgui.ImVec2(butPos.x + width + 8, butPos.y + 2.5))
    imgui.Text( str_id:gsub('##.+', '') )
    local t = bool[0] and 1.0 or 0.0
    if LastActive[tostring(str_id)] then
        local time = os.clock() - LastActiveTime[tostring(str_id)]
        if time <= ANIM_SPEED then
            local t_anim = ImSaturate(time / ANIM_SPEED)
            t = bool[0] and t_anim or 1.0 - t_anim
        else
            LastActive[tostring(str_id)] = false
        end
    end
    local col_circle = bool[0] and imgui.ColorConvertFloat4ToU32(imgui.ImVec4(imgui.GetStyle().Colors[imgui.Col.ButtonActive])) or imgui.ColorConvertFloat4ToU32(imgui.ImVec4(imgui.GetStyle().Colors[imgui.Col.TextDisabled]))
    dl:AddRectFilled(p, imgui.ImVec2(p.x + width, p.y + height), imgui.ColorConvertFloat4ToU32(imgui.GetStyle().Colors[imgui.Col.FrameBg]), height * 0.5)
    dl:AddCircleFilled(imgui.ImVec2(p.x + radius + t * (width - radius * 2.0), p.y + radius), radius - 1.5, col_circle)
    return rBool
end
 
Последнее редактирование:
  • Нравится
Реакции: Qwerty???