Jump to content
  • 0

Please help me to create a SubMenu


LupinV

Question

1 answer to this question

Recommended Posts

You just need to call a function for showing desired submenu, if user has chosen corresponding option in main menu.

Simple example of menu with submenu:

local function showSubMenu()
  local choice = gg.choice({'Option 1', 'Option 2'})
  if choice == nil then
    -- Actions, if the dialog was cancelled
  elseif choice == 1 then
    -- Actions for option 1
  elseif choice == 2 then
    -- Actions for option 2
  end
end

local function showMenu()
  local choice = gg.choice({'Option 1 - submenu', 'Option 2', 'Exit'})
  if choice == nil then
    -- Actions, if the dialog was cancelled
  elseif choice == 1 then
    showSubMenu()
  elseif choice == 2 then
    -- Actions for option 2
  elseif choice == 3 then
    os.exit()
  end
end

while true do
  if gg.isVisible() then
    showMenu()
    gg.setVisible(false)
  else
    gg.sleep(100)
  end
end

submenu_example.lua

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.