How to detect if the Mono is enabled

Want Cheat Engine to do something specific and no idea how to do that, ask here. (From simple scripts to full trainers and extensions)
Post Reply
User avatar
濒危物种猫咪
Table Makers
Table Makers
Posts: 167
Joined: Tue Oct 18, 2022 5:09 am
Reputation: 143

How to detect if the Mono is enabled

Post by 濒危物种猫咪 »

Here's my attempt

Code: Select all

if process and readInteger(process) ~= 0 then
    print("正在加载Mono,请耐心等待")
    mono_initialize()
    LaunchMonoDataCollector()

    local timer = createTimer(nil, false)
    timer.Interval = 1000
    timer.OnTimer = function()
        local method = mono_findMethod('', 'System.String', 'Equals')
        if method then
            timer.destroy()
            print("Mono已成功加载,可以启用修改功能\n本窗口在1s后自动关闭")


            local closeTimer = createTimer(nil, false)
            closeTimer.Interval = 1000
            closeTimer.OnTimer = function()
                closeTimer.destroy()

                local luaEngine = getLuaEngine()
                if luaEngine then
                    luaEngine.hide()
                end
            end
            closeTimer.Enabled = true
        else
            print("Mono加载中,请稍候...")
        end
    end
    timer.Enabled = true
else
    print('未检测到进程,请启动游戏')
    error('未检测到进程,请启动游戏')
end
I thought it worked at first, but the funny thing is that when I manually load other processes, it still says Mono loaded
I really don't know how to proceed. I didn't find anything related in the CE forum(or maybe it's my oversight). If anyone can help me, I will be very grateful:)
PS: I only know a little bit about Lua

User avatar
Metanoia
Expert Cheater
Expert Cheater
Posts: 67
Joined: Thu Mar 07, 2024 7:16 pm
Reputation: 41

Re: How to detect if the Mono is enabled

Post by Metanoia »

濒危物种猫咪 wrote:
Wed Jul 03, 2024 1:20 pm
Here's my attempt

Code: Select all

if process and readInteger(process) ~= 0 then
    print("正在加载Mono,请耐心等待")
    mono_initialize()
    LaunchMonoDataCollector()

    local timer = createTimer(nil, false)
    timer.Interval = 1000
    timer.OnTimer = function()
        local method = mono_findMethod('', 'System.String', 'Equals')
        if method then
            timer.destroy()
            print("Mono已成功加载,可以启用修改功能\n本窗口在1s后自动关闭")


            local closeTimer = createTimer(nil, false)
            closeTimer.Interval = 1000
            closeTimer.OnTimer = function()
                closeTimer.destroy()

                local luaEngine = getLuaEngine()
                if luaEngine then
                    luaEngine.hide()
                end
            end
            closeTimer.Enabled = true
        else
            print("Mono加载中,请稍候...")
        end
    end
    timer.Enabled = true
else
    print('未检测到进程,请启动游戏')
    error('未检测到进程,请启动游戏')
end
I thought it worked at first, but the funny thing is that when I manually load other processes, it still says Mono loaded
I really don't know how to proceed. I didn't find anything related in the CE forum(or maybe it's my oversight). If anyone can help me, I will be very grateful:)
PS: I only know a little bit about Lua
.... check if monopipe is nil

User avatar
濒危物种猫咪
Table Makers
Table Makers
Posts: 167
Joined: Tue Oct 18, 2022 5:09 am
Reputation: 143

Re: How to detect if the Mono is enabled

Post by 濒危物种猫咪 »

Metanoia wrote:
Wed Jul 03, 2024 1:57 pm
濒危物种猫咪 wrote:
Wed Jul 03, 2024 1:20 pm
Here's my attempt

Code: Select all

if process and readInteger(process) ~= 0 then
    print("正在加载Mono,请耐心等待")
    mono_initialize()
    LaunchMonoDataCollector()

    local timer = createTimer(nil, false)
    timer.Interval = 1000
    timer.OnTimer = function()
        local method = mono_findMethod('', 'System.String', 'Equals')
        if method then
            timer.destroy()
            print("Mono已成功加载,可以启用修改功能\n本窗口在1s后自动关闭")


            local closeTimer = createTimer(nil, false)
            closeTimer.Interval = 1000
            closeTimer.OnTimer = function()
                closeTimer.destroy()

                local luaEngine = getLuaEngine()
                if luaEngine then
                    luaEngine.hide()
                end
            end
            closeTimer.Enabled = true
        else
            print("Mono加载中,请稍候...")
        end
    end
    timer.Enabled = true
else
    print('未检测到进程,请启动游戏')
    error('未检测到进程,请启动游戏')
end
I thought it worked at first, but the funny thing is that when I manually load other processes, it still says Mono loaded
I really don't know how to proceed. I didn't find anything related in the CE forum(or maybe it's my oversight). If anyone can help me, I will be very grateful:)
PS: I only know a little bit about Lua
.... check if monopipe is nil
Get it !
thanku!!!

User avatar
濒危物种猫咪
Table Makers
Table Makers
Posts: 167
Joined: Tue Oct 18, 2022 5:09 am
Reputation: 143

Re: How to detect if the Mono is enabled

Post by 濒危物种猫咪 »

濒危物种猫咪 wrote:
Wed Jul 03, 2024 4:17 pm
Metanoia wrote:
Wed Jul 03, 2024 1:57 pm
濒危物种猫咪 wrote:
Wed Jul 03, 2024 1:20 pm
Here's my attempt

Code: Select all

if process and readInteger(process) ~= 0 then
    print("正在加载Mono,请耐心等待")
    mono_initialize()
    LaunchMonoDataCollector()

    local timer = createTimer(nil, false)
    timer.Interval = 1000
    timer.OnTimer = function()
        local method = mono_findMethod('', 'System.String', 'Equals')
        if method then
            timer.destroy()
            print("Mono已成功加载,可以启用修改功能\n本窗口在1s后自动关闭")


            local closeTimer = createTimer(nil, false)
            closeTimer.Interval = 1000
            closeTimer.OnTimer = function()
                closeTimer.destroy()

                local luaEngine = getLuaEngine()
                if luaEngine then
                    luaEngine.hide()
                end
            end
            closeTimer.Enabled = true
        else
            print("Mono加载中,请稍候...")
        end
    end
    timer.Enabled = true
else
    print('未检测到进程,请启动游戏')
    error('未检测到进程,请启动游戏')
end
I thought it worked at first, but the funny thing is that when I manually load other processes, it still says Mono loaded
I really don't know how to proceed. I didn't find anything related in the CE forum(or maybe it's my oversight). If anyone can help me, I will be very grateful:)
PS: I only know a little bit about Lua
.... check if monopipe is nil
Get it !
thanku!!!
emm,I try to

Code: Select all

    print("正在加载Mono,请耐心等待")
    mono_initialize()
    LaunchMonoDataCollector()

    local timer = createTimer(nil, false)
    timer.Interval = 1000
    timer.OnTimer = function()
        if monopipe == nil then
            timer.destroy()
            print("Mono加载失败,请检查进程")
            return
        end
        if monopipe ~= nil then
            timer.destroy()
            print("Mono已成功加载,可以启用修改功能\n本窗口在1s后自动关闭")

            local closeTimer = createTimer(nil, false)
            closeTimer.Interval = 1000
            closeTimer.OnTimer = function()
                closeTimer.destroy()

                local luaEngine = getLuaEngine()
                if luaEngine then
                    luaEngine.hide()
                end
            end
            closeTimer.Enabled = true
        else
            print("Mono加载中,请稍候...")
        end
    end
    timer.Enabled = true
But it still cannot work correctly
it will always show print("Mono已成功加载,可以启用修改功能\n本窗口在1s后自动关闭")

User avatar
Metanoia
Expert Cheater
Expert Cheater
Posts: 67
Joined: Thu Mar 07, 2024 7:16 pm
Reputation: 41

Re: How to detect if the Mono is enabled

Post by Metanoia »

no no forget all of that code just

if monopipe then
print('Mono is on')
else
print('Mono is off')
end

What are you trying to do ?

User avatar
濒危物种猫咪
Table Makers
Table Makers
Posts: 167
Joined: Tue Oct 18, 2022 5:09 am
Reputation: 143

Re: How to detect if the Mono is enabled

Post by 濒危物种猫咪 »

May be a solution

Code: Select all


if process and readInteger(process) ~= 0 then
    print("正在加载Mono,请耐心等待")
    mono_initialize()
    LaunchMonoDataCollector()

    local maxRetries = 10  -- 最大重试次数
    local retries = 0

    local timer = createTimer(nil, false)
    timer.Interval = 1000
    timer.OnTimer = function()
        -- 尝试调用一个简单的 Mono 函数来检测 Mono 是否可用
        local success, result = pcall(function()
            return mono_enumDomains()
        end)

        if success and result and #result > 0 then
            timer.destroy()
            print("Mono已成功加载,可以启用修改功能\n本窗口在1s后自动关闭")

            local closeTimer = createTimer(nil, false)
            closeTimer.Interval = 1000
            closeTimer.OnTimer = function()
                closeTimer.destroy()

                local luaEngine = getLuaEngine()
                if luaEngine then
                    luaEngine.hide()
                end
            end
            closeTimer.Enabled = true
        elseif success then
            print("Mono加载中,请稍候...")
            retries = retries + 1
            if retries >= maxRetries then
                timer.destroy()
                print("尝试启用Mono功能已超过10s,请确保进程是正确的")
            end
        else
            timer.destroy()
            print("尝试启用Mono功能已超过10s,请确保进程是正确的")
        end
    end
    timer.Enabled = true


User avatar
濒危物种猫咪
Table Makers
Table Makers
Posts: 167
Joined: Tue Oct 18, 2022 5:09 am
Reputation: 143

Re: How to detect if the Mono is enabled

Post by 濒危物种猫咪 »

Metanoia wrote:
Wed Jul 03, 2024 4:31 pm
no no forget all of that code just

if monopipe then
print('Mono is on')
else
print('Mono is off')
end

What are you trying to do ?
Some functions require to use Mono
I usually write a script that automatically loads the program and add Usemono().
But it takes time to turn on Mono
Some people rush to turn on functions, which will cause CE to report an error, so I want to check whether Mono is turned on or not.
These scripts of mine seem to meet my needs (including yours). I'm just confused why it still shows that I have loaded Mono when I manually load other processes (Which is impossible to turn on the Mono function).
My latest script solves the problem (even though it may not be a good solution), anyway, thanku very much

Post Reply

Who is online

Users browsing this forum: No registered users