/*SIMPLE MENU v1.0 follow the comments to use this Lua in your mod, if you find any issue let me know! -Felix44*/ local function sayHi() print("hi!") --this function is only for showing how the function settings works, you are free to remove it end addHook("PlayerSpawn", function(player) io.openlocal("client/Name.dat", "a+"):close() --you can change "Name" to something else, change it for the line below too if you do local file = io.openlocal("client/Name.dat", "r+") local valt = file:read("*a") if valt == "" valt = "111111111" --IMPORTANT, put as many 1s as many settings your menu has, functions excluded (example: if your menu only has 3 setting and 1 function write "111" instead of the current one) file:write(valt) file:seek("set") end file:close() player.menu = {} player.menu.pointer = 1 player.menu.show = false player.menu.timer = 0 player.menu.contents = { {value = 1, name = "Value 1", description = "Description 1"}, {value = 1, name = "Value 2", description = "Description 2"}, {value = 1, name = "Value 3", description = "Description 3"}, {value = 1, name = "Value 4", description = "Description 4"}, {value = 1, name = "Value 5", description = "Description 5", toggledby = 4}, {value = 1, name = "Say hi", description = "This option calls a function!", func = sayHi}, {value = 1, name = "Value 7", description = "Description 7"}, {value = 1, name = "Value 8", description = "Description 8"}, {value = 1, name = "Value 9", description = "Description 9", toggledby = 8}, {value = 1, name = "Value 10", description = "Description 10", toggledby = 8} } local funcopts = 0 for i = 1,#player.menu.contents if player.menu.contents[i].func funcopts = $+1 continue end player.menu.contents[i].value = tonumber(valt:sub(i-funcopts, i-funcopts)) end end) /*player.menu.contents is the main part of the menu, you can have as many elements as you want, but it might be best not to have more than 10, "value" sets their value (1 = true, 0 = false), but they get overwritten by the saved data either way so you can leave it to 1 use this for your checks in your Lua, an example is at the end of this Lua "name" is the name of the setting that will appear on the menu "description" is the small text that will appear on the bottom of the screen "toggledby" is an extra parameter for subsections, set it to the number of the setting which your subsection setting should be depending on do note that if the setting that controls the subsecton is off, it will make the subsection not modifiable, but it will NOT set it to false automatically, remember that when making the checks in your other Luas "func" is an extra parameter for function setting, this settings can't be toggled on/off, selecting them will call the given function */ addHook("PlayerCmd", function(player, cmd) local menu = player.menu menu.timer = max($-1, 0) if menu.show == false or menu.timer then return end if cmd.forwardmove > 0 menu.pointer = max($-1, 1) menu.timer = 5 S_StartSound(player.mo, sfx_menu1, player) elseif cmd.forwardmove < 0 menu.pointer = min($+1, #menu.contents) menu.timer = 5 S_StartSound(player.mo, sfx_menu1, player) end if cmd.buttons & BT_JUMP if menu.contents[menu.pointer].toggledby and menu.contents[menu.contents[menu.pointer].toggledby].value == 0 then return end if menu.contents[menu.pointer].func menu.contents[menu.pointer].func() else menu.contents[menu.pointer].value = ($+1)%2 end menu.timer = 5 S_StartSound(player.mo, sfx_menu1, player) end end) addHook("PlayerThink", function(player) if player.menu.show player.powers[pw_nocontrol] = 1 player.powers[pw_flashing] = 1 end end) COM_AddCommand("showmenu", function(player) --you can change the command's name to anything you want if not (player.mo and player.mo.valid) CONS_Printf(player, "You must be in a level to use this.") return end player.menu.show = not $ if player.menu.show == false local file = io.openlocal("client/Name.dat", "w") --if you changed "Name" in the other lines, change it here too! for i = 1,#player.menu.contents if player.menu.contents[i].func then continue end file:write(player.menu.contents[i].value) end file:close() end end, COM_LOCAL) local mapColors = { --this changes the menu's color based on the player's, I guess you can change it if you want [0] = 0, [V_MAGENTAMAP] = 182, [V_YELLOWMAP] = 74, [V_GREENMAP] = 115, [V_BLUEMAP] = 159, [V_REDMAP] = 41, [V_GRAYMAP] = 20, [V_ORANGEMAP] = 58, [V_SKYMAP] = 141, [V_PURPLEMAP] = 187, [V_AQUAMAP] = 173, [V_PERIDOTMAP] = 94, [V_AZUREMAP] = 170, [V_BROWNMAP] = 249, [V_ROSYMAP] = 203, [V_INVERTMAP] = 31 } hud.add(function(v,player) --this draws the menu on the screen, you can change the values to what you prefer if you know what you are doing if not player.menu.show then return end local color = mapColors[skincolors[player.skincolor].chatcolor] v.drawFill(70, 25, 200, 25+(10*#player.menu.contents), color) v.drawString(110, 30, "SIMPLE MENU") --you should probably change this to something that fits for your menu though for i = 1,#player.menu.contents local thecolor = 0 local thex = 0 if player.menu.pointer == i then thecolor = V_YELLOWMAP end if player.menu.contents[i].toggledby thex = 10 if player.menu.contents[player.menu.contents[i].toggledby].value == 0 thecolor = $|V_TRANSLUCENT end end local thename = "Missing name!" if player.menu.contents[i].name and player.menu.contents[i].name ~= "" thename = player.menu.contents[i].name end v.drawString(75+thex, 35+(10*i), thename, thecolor|V_ALLOWLOWERCASE) local thevalue = "OFF" if player.menu.contents[i].value == 1 then thevalue = "ON" end if player.menu.contents[i].func then thevalue = "" end v.drawString(235, 35+(10*i), thevalue) end local patch = v.cachePatch("M_CURSOR") v.draw(55, 35+(10*player.menu.pointer), patch) local desctext = "No description found!" if player.menu.contents[player.menu.pointer].description and player.menu.contents[player.menu.pointer].description ~= "" desctext = player.menu.contents[player.menu.pointer].description end v.drawString(70, 160, desctext, V_ALLOWLOWERCASE, "thin") end) /*EXAMPLE FOR CHECKING A SETTING'S VALUE you have to check player.menu.contents[n].value, where n is the setting's number, this will return 1 when on and 0 when off, here's an example: local function myCoolFunction() if player.menu.contents[1].value --some cool code end return end */