Resource icon

[Open Assets] Quickmenu 1.0

What permissions do you give others to modify and/or maintain your submission?
Modify: YES - Maintain: YES - I give permission for my entire submission to be modified by others or used in their own work. I give permission for my entire submission to be maintained by others as well.
COPYRIGHT NOTE: this script is released under the Apache License 2.0, and the current copyright holder is Gustaf "Hanicef" Alhäll as they are the current maintainer of The Gaming Den scripts that this script comes from. the script contains a link to the full license in the copyright notice, which outlines exactly what is and isn't allowed to be done with this script. the license takes precedence in all cases as it is legally binding, so if you intend to modify it, read the license first so you understand what you need to do before you can release your changes!

this is a simple and modular menu that gives quick access to common console commands. it has a full-fledge api for easy integration, allowing other scripters to take advantage of it with ease.

srb20067.png

usage


to open the menu, press F6 (or M if you're running the script it 2.1). you can use the arrow keys to navigate the menu and press enter to select an option.

1739028473928.png


options ending with ... are submenus and will open up another menu when chosen. to navigate backwards, press backspace. you can close the menu at any time by pressing escape or F6.

it has a basic built-in menu for some engine stuff that you can't find in the ordinary settings. however, this menu can grow if you add addons that integrate into it - see "integration api" below for more info how to integrate into this addon.

NOTE: for the integration to work, this addon must be loaded first! to be on the safe side, always load the addon first before loading any other addons.

2.1 support


through very careful coding, this addon not only supports the latest version of 2.2, but also 2.1.25 or later (see the srb2 legacy project for 2.1 versions after 2.1.25, latest version of this writing is 2.1.27).

srb20000.png

the script has feature parity in both versions, but due to a bug in the bind mechanism in 2.1, the m key is used instead to toggle the menu, and escape cannot be used to close it. it also has fewer settings in the default menu in 2.1 due to fewer commands in general compared to 2.2.

integration api


the api can be integrated to by using the quickmenu namespace and using the classes Submenu and Entry. remember to always wrap the api call within an if quickmenu then statement so the addon doesn't throw errors if quickmenu isn't loaded. to get started quickly, go ahead and use this template:
Code:
if quickmenu then
    quickmenu.add_menu(Submenu("Insert menu name here", {
        -- TODO: add submenus and entries here
    }))
end

functions​

quickmenu.add_menu(submenu)
adds a submenu to the menu list. note that it only accepts Submenu; trying to pass an Entry is invalid and will raise a lua error.

classes​

Submenu(name, entries, flags)
creates a menu that contains other menus and entries.
name specifies the name of the menu, which will be displayed on-screen in the menu.
entries is either a table containing other submenus or entries, or a function that returns a table with submenus and entries. note that if you specify a function here, it's only locally invoked, so do not do anything that can desynchronize in this function!
flags is a table that can contain the following keys:
* singleplayer - if set to true, this setting will only be displayed in singleplayer, and will be hidden in multiplayer.
* multiplayer - if set to true, this setting will only be displayed in multiplayer, and will be hidden in singleplayer.
* admin - if set to true, this setting will only appear if the player is either host or remote admin, and is playing multiplayer. it will not appear in singleplayer.

Entry(name, command, flags)
creates an entry that will invoke a command or run a function when selected.
name specifies the name of the entry, which will be displayed on-screen in the menu.
command is either a string containing what command that will be ran on selection, or a function that is invoked when selected. note that if you specify a function here, it's only locally invoked, so do not do anything that can desynchronize in this function! if you need to synchronize from a function, invoke a command that is not local.
flags is a table that can contain the following keys:
* singleplayer - if set to true, this setting will only be displayed in singleplayer, and will be hidden in multiplayer.
* multiplayer - if set to true, this setting will only be displayed in multiplayer, and will be hidden in singleplayer.
* admin - if set to true, this setting will only appear if the player is either host or remote admin, and is playing multiplayer. it will not appear in singleplayer.
Author
Gouldron
Downloads
191
Views
905
Extension type
lua
File size
9.1 KB
MD5 Hash
16994f0696bbafaf2df026e99ccd529a
First release
Last update

More resources from Gouldron

Share this resource

Back
Top