Jump to content
  • 0

Submenu !


LuffyMC5
 Share

Question

Any Buddy Knows How Can I Minimize Submenu!

Means: If I Execute Any Script In Submenu Then It Will Auto Back To Main Menu And If Submenu Is Nil Then It Will Auto Back To Main Menu

My Main Point Is That: I Want To Stuck In Submenu Until I Back

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 1

someone gave this to me a very long time ago(forgot who that was)

not sure if this what you needed but you can take a look at it.

function main()
    local menu = gg.choice({
        "Menu A",
        "Menu B",
        "Menu C",
        "\nEXIT"
    }, nil, "Menu & Sub Menu TEST")
    
    if menu == nil then
        handleCancel(main)  -- Handle cancel in main menu
    elseif menu == 1 then
        Menu_A()
    elseif menu == 2 then
        Menu_B()
    elseif menu == 3 then
        Menu_C()
    elseif menu == 4 then
        gg.toast(" Canceled")
        os.exit()
    end
end

function Menu_A()
    local menu = gg.choice({
        "Sub Menu A1",
        "\nBACK"
    }, nil, "Menu A")
    
    if menu == nil then
        handleCancel(Menu_A)  -- Handle cancel in Menu A
    elseif menu == 1 then
        SubMenu_A1()
    elseif menu == 2 then
        gg.toast("return to main")
        main()
    end
end

function SubMenu_A1()
    gg.alert("You're in Sub Menu A1")
    handleExecute(Menu_A)
end


function Menu_B()
    local menu = gg.choice({
        "Sub Menu B1",
        "\nBACK"
    }, nil, "Menu B")
    
    if menu == nil then
        handleCancel(Menu_B)  -- Handle cancel in Menu B
    elseif menu == 1 then
        SubMenu_B1()
    elseif menu == 2 then
        gg.toast("return to main")
        main()
    end
end

function SubMenu_B1()
    gg.alert("You're in Sub Menu B1")
    handleExecute(Menu_B)
end


function Menu_C()
    local menu = gg.choice({
        "Sub Menu C1",
        "\nBACK"
    }, nil, "Menu C")
    
    if menu == nil then
        handleCancel(Menu_C)  -- Handle cancel in Menu C
    elseif menu == 1 then
        SubMenu_C1()
    elseif menu == 2 then
        gg.toast("return to main")
        main()
    end
end


function SubMenu_C1()
    gg.alert("You're in Sub Menu C1")
    handleExecute(Menu_C)
end


function handleCancel(callback)
    gg.toast("Canceled")
    while true do
        if gg.isVisible() then
            gg.setVisible(false)
            callback()  -- Call the callback function to return to the previous menu
        end
    end
end


function handleExecute(callback)
    gg.toast("Done")
    while true do
        if gg.isVisible() then
            gg.setVisible(false)
            callback()  -- Call the callback function to return to the previous menu
        end
    end
end


while true do
    if gg.isVisible() then
        gg.setVisible(false)
        main()
    end
end

perhaps someone can show a better or simple way to do all that.

its seem too much for me.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.