About this mod
If you know how to use console commands, then you can likely make a menu with this easy-to-use creator (though it is mostly intended for mod developers).
- Requirements
- Permissions and credits
- Changelogs
- This is an attempt to make in-game menu creation as easy as possible for modders to easily create menus for their mods (and yes, this sentence is intentional).
- Supports adding sub-menus ("pages") to this mod's menu, or fully creating your own menu.
- The mod handles practically everything except for naming/labeling your menu pages/buttons and setting up the button functionalities.
- Your menus can also have their own sub-menus (by adding buttons to take users to them in your main menu and a "back" button to return to your main menu in each sub-menu).
- Currently only supports adding basic buttons to menus, but support for other element types will be added at some point (please don't ask, I'll get to it when I can. If someone wants to offer assistance, please do). A lot can be done with just a simple button when they can open sub-menus, though.
- The mod's folder contains an example menu that can be tested in-game, by copy/pasting it into your main game install folder and executing it in-game with the 'exec "filename"' command.
- Mod v1.0.3 added gameplay hints (same that are in the pause menu) to the empty space on the left side of the mod's menu. If you would like, these can be disabled using this console command in your "autoexec.cfg" file (or in-game or any other cfg that loads for gameplay): kcdmenus_disableHints true --(Note: Setting this to false will re-enable them in-game)
How To Open The Mod's Main Menu:
- Set up a keybind in your "autoexec.cfg" file using this command (with quotes): "kcdmenus_open 'KCD Menus Mod' 'Welcome To KCD Menus Mod'"
- Use the keybind in-game any time the game is NOT paused to open the menu.
- Note: If you have no supported mods or your own menus added, the menu will not show much at all.
How Do I Package My Mod To Publish?
- This mod will automatically load any cfg files containing the mod's commands that are found in a "Data/KCDMenusMod/" folder, or any subfolders inside of it, so this is the recommend method. Just create that folder structure in a new mod folder, add your cfg file, pak it all up (the Data folder and it's contents), and you should be good to go.
- Since these are just commands, you can also package them in any way that will execute them automatically for the user, but an "autoexec" or "user" cfg file is not recommended (unless you just provide a copy/paste method for users, as it will work, it's just not a good idea to overwrite their existing files).
Installation:
- Extract to main KCD2 game installation folder, or install with Vortex. To uninstall manually, delete the "KCD2 Native Menus Creator" folder from your "KCD2/Mods" folder.
Known Issues:
- If you have more buttons than can appear in the allotted area on screen, players can scroll as usual, but the scrollbar will be shown directly in the center of the buttons, not to their right as they are in actual game menus. I have not found a way to resolve this yet, but have been trying to, and hopefully will eventually. It is recommended to use sub-menus when possible to avoid having too many buttons on one page.
- The mod currently only supports navigating the menu with your mouse cursor. I've tried many different ways to make keyboard/d-pad work, but have been unsuccessful without breaking other game inputs. I am still trying to figure it out, though.
Example Menu Creation Cfg (Menu Seen In Screenshots):
~~~~~~~~~~~~~~~~~~~~~~~~Always include quotations, both single and double. Use double qoutes to encapsulate a parameter, and single quotes to encapsulate strings inside of parameters, for example: "System.LogAlways('Hello World - This is a test')"~~~~~~~~~~~~~~~~~~~~~~~~
Adding Menu Pages:
Console Command:
kcdmenus_newpage "KCD Menus Mod" "Sub Page 1" --Adding your main menu page
kcdmenus_newpage "KCD Menus Mod" "Sub Page 2" --Adding an optional secondary page/menu
Lua Function: kcdmenus.NewPage()
Parameters: 1:["Menu Name"], 2:["Page Name"]
Adding Your Main Menu Button To This Mod's Menu (Takes Players To Your Menu):
Console Command:
kcdmenus_newbutton "KCD Menus Mod" "Welcome To KCD Menus Mod" "Go To Menu -> SubMenu Test" "Go to the Teleport Menu" "false" "command" "kcdmenus_open 'KCD Menus Mod' 'Sub Page 1'"
Lua Function: kcdmenus.NewButton()
Parameters: 1:["Menu Name"], 2:["Page Name"], 3:["Button Label"], 4:["Button Tooltip"] 5:["Disable (true/false)"] 6:["Execution Type" (command/lua)], 7:["Command/Function To Execute"]
Adding Return To Main Menu Button (Returns To This Mod's Menu):
kcdmenus_newbutton "KCD Menus Mod" "Sub Page 1" "Back To Menu -> KCD2 Mods Menu" "Go back to the main KCD2 Mods Menu" "false" "command" "kcdmenus_open 'KCD Menus Mod' 'Welcome To KCD Menus Mod'"
Adding Optional Button To Take Players To A Secondary Menu For Your Mod):
kcdmenus_newbutton "KCD Menus Mod" "Sub Page 1" "Go To Menu -> Sub Page 2" "Go to the second submenu" "false" "command" "kcdmenus_open 'KCD Menus Mod' 'Sub Page 2'"
Adding Button To Log A "Hello World" Message To Console (Example Functionality):
kcdmenus_newbutton "KCD Menus Mod" "Sub Page 1" "Hello World" "Logs a 'Hello World' message to the console." "false" "lua" "System.LogAlways('Hello World - This is a test')"
Adding Your Optional Sub-Menu Buttons:
kcdmenus_newbutton "KCD Menus Mod" "Sub Page 2" "Back To Menu -> KCD2 Mods Menu" "Go back to the main KCD2 Mods Menu" "false" "command" "kcdmenus_open 'KCD Menus Mod' 'Welcome To KCD Menus Mod'"
kcdmenus_newbutton "KCD Menus Mod" "Sub Page 2" "Back To Menu -> Sub Page 1" "Go back to the previous menu" "false" "command" "kcdmenus_open 'KCD Menus Mod' 'Sub Page 1'"
kcdmenus_newbutton "KCD Menus Mod" "Sub Page 2" "Clear Console" "Clears the game console log." "false" "lua" "System.ClearConsole()"
Setting A Page As The Main Menu For Your Mod (Adds Button To Return To This Mod's Main Menu):
Console Command:
kcdmenus_SetMainPage("KCD Menus Mod" "Sub Page 1")
Lua Function: kcdmenus.SetMainPage("KCD Menus Mod", "Sub Page 1")
Parameters: 1:["Menu Name"], 2:["Page Name"]You can add more sub-menus if you would like. Or add none at all and have everything in your mod's "main" menu page.~~~~~~~~~~~~~~~~~~~~~~~~
The above commands list will create our menu and add a button to it into this mod's main menu. You can also set up a keybind to directly open your sub-menu (using the above example's menu and main page names for the params):
Command: bind "kcdmenus_open 'KCD Menus Mod' 'Sub Page 1'"
Note: Include all of the quotes, single and double (You need to do this when params include spaces).
NewPage command params:
1.) Menu Name that the page will be added to
2.) Page Name that your buttons will be added to. Used as the menu header label and to distinguish between different mods/menus in-game. This is your "menu", basically.
NewButton command params:
1.) Menu Name. Should always be "KCD Menus Mod" if you want your page/content to be added to the main mod's menu, or any unique name if creating your own menu.
2.) Page Name. Should be the page you want the button to be in. If you want the same button in multiple pages/menus, you need to add it multiple times. This should be unique, as it is used to distinguish between mod menus in-game.
3.) Button Label Text (for the in-game button label).
4.) Button Tooltip Text (when hovered over in-game).
5.) Boolean to disable interactions with the button. You will usually want this to be "false". True disables the button interactions and greys the option out.
6.) Command/Code Type. Should always be "command" or "lua", depending on what you want to execute. Can execute full lines of lua or single functions (from vanilla or other mods).
7.) Command/Code String. The command/lua code, in a string format, that you wish to execute.
NewMenu command example/params (use only if you want to create your own menu instead of adding to the main mod's menu):
Command: kcdmenus_newmenu "My Menu Name"
Param: Menu Name~~~~~~~~~~~~~~~~~~~~~~~~Method For Getting Your Page ID In Lua (To Use If You Want To Manually Adjust Anything):
local menuName = "Example Menu Name"
local pageName = "Example Page Name"
local pageID = kcdmenus.GetPageID(menuName, pageName)
Method For Getting The Current Active Menu/Page Names In Lua:
local activeMenu = kcdmenus.activeMenu
local activePage = kcdmenus.activePage
Method For Getting The Current Page Buttons In Lua:
local menu = kcdmenus.menus[activeMenu] --Replace 'activeMenu' with menu name to check specific menus
local page = menu.pages[tonumber(pageID)] --You need the pageID to get this
local buttons = page.elements --Does not include the "Exit" button added by this mod
local numberOfButtons = #page.elements + 1 --Adding +1 to account for the "Exit" button
Check If Any Of The Mod's Menus Are Currently Opened In Lua:
local isAnyModMenuOpen = kcdmenus.anyMenuOpen
Check If Any Game Menus Are Opened In Lua:
local isAnyGameMenuOpen = kcdmenus.isGamePaused or not kcdmenus.hasGameStarted
Close Active Mod Menu In Lua:
if isAnyModMenuOpen then --Semi-redundant check as the mod will check this
kcdmenus.CloseMenu() --Safe to call even with no menu open
end~~~~~~~~~~~~~~~~~~~~~~~~
Want To Use Lua Instead To Create Your Menu?
- Have a look inside of my script. Scroll to the bottom and you will see where I am adding the console commands, and see which script function each command calls. Use those functions instead of the commands. Or reuse the code altogether, just don't reuse it to release a competing mod with it (allowing other mods to add options to your menu), of course, and give proper credits on your mod page if you publish, and know that if you make improvements, I will add them to this mod if I find it worthy.
- Alternatively, you could always just execute the console commands in your lua script with the game's 'System.ExecuteCommand("CommandString")' function.
Want To Translate This To Other Languages Or Include In A Nexus/Vortex Collection?
- Please do. I definitely would not be upset.