-- 初始化选项列表 local options = {"选项 1", "选项 2", "选项 3"} -- 添加一个新选项到列表的函数 function addOption(optionName) table.insert(options, optionName) end -- 显示选择框的函数 function showChoiceBox() local choice = gg.choice(options, nil, "选择一个选项") if choice == nil then gg.toast("你取消了选择") else gg.toast("你选择了: " .. options[choice]) end end -- 主脚本循环 while true do -- 显示主菜单 local menu = gg.choice({"显示选项框", "添加新选项", "退出脚本"}, nil, "主菜单") if menu == nil then gg.toast("你取消了选择") elseif menu == 1 then -- 显示选择框 showChoiceBox() elseif menu == 2 then -- 提示输入新选项的名称 local newOption = gg.prompt({"输入新选项名称"}, {""}, {"text"}) if newOption ~= nil then addOption(newOption[1]) gg.toast("选项 '" .. newOption[1] .. "' 已添加") else gg.toast("未添加新选项") end elseif menu == 3 then gg.toast("脚本已退出") break end end