[MOD] Mods Options Menu

The place to discuss scripting and game modifications for X Rebirth.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Post Reply
User avatar
eliseeff
Posts: 255
Joined: Wed, 26. Jan 05, 17:17
x4

[MOD] Mods Options Menu

Post by eliseeff » Wed, 23. May 18, 05:53

Name: Mods Options
Version: 1.02
Autor: eliseeff
Requirements:
game version 4.0 or higher
Install: Subscribe to the mod on the Steam Workshop page
Uninstall: Unsubscribe from the mod and delete the mod folder
Savegame compatible: YES

XR VR-edition Steam Workshop page

Changelog:
1.01 - Added support for the legacy menu (Enter - 6 - 2)
1.02 - Fixed missing icons in the VR-version

Introduction:

It just so happened that I needed a setup menu for the three mods. I did not want to add them to the sidebar - it would clutter it up. And I decided to make one common menu for all the options of my mods. This can be used by someone else - I specifically made the addition of options as simple as possible.

Here's what happened as a result (click on images to enlage):

[ external image ] [ external image ]

The menu is called with Enter - 9 - 3 (Enter - 6 - 2 for Legacy menu). Options are scrolled by cursor keys, select - Enter. Also expandable sections are supported.

How to add your own option/options:

1. In your ui.xml file specify addon dependency:

Code: Select all

    <dependency name="mo_in_mainmenu" />
(If your file is loaded before, then you simply have nowhere to add your own options.)

2. In your lua file in init function you need to find the menu witn name="Mods_Options_Menu" in Menus table and add your option entry. Approximately so:

Code: Select all

local function init()
	Menus = Menus or {}
	for _, entry in ipairs(Menus) do
		if entry.name == "Mods_Options_Menu" and type(entry.mods_list) == "table" then
			table.insert(entry.mods_list, my_option)
			break
		end
	end
end
Here: my_option is your option entry. Now you need to set a value for your option (or options). Consider first adding a single option.

3.

Code: Select all

my_option = {
	name = "My mod name",
	-- must be a string with lenght > 0

	option = 1,
	-- must be 1 or 2: 1 for "Options" or 2 for "Uninstall"

	section = "gMain_my_section_name",
	-- must be a string with lenght > 5

	param = {0, 0}
	-- (optional) section param
}
Done... Now consider adding multiple options in the expanding section.

4.

Code: Select all

my_option = {
	name = "My mod2 name",
	-- still must be a string with lenght > 0

	list = {
	-- must be a table with at least 1 valid entry
	-- entry is valid, if have correct 'option' and 'section' values

		{
			option = "My mod2 option1",
			-- here 'option' must be a string with lenght > 0

			section = "gMain_my_mod2_section1",
			-- still must be a string with lenght > 5

			param = {0, 0}
			-- still optional
		},
		{
			option = "My mod2 option2",
			section = "gMain_my_mod2_section2",
			param = "Hello world"
			-- as above
		},
		{
			option = "My mod2 option3",
			section = "gMain_my_mod2_section3"
			-- as above
		}
	}
}
Done! As you can see, everything is very simple.

I can also provide an archive with two demo mini-mods. The first one adds one option to the menu, the second adds a section with three options. You can download it here.

The mod itself you can download here.

... or subscribe to it in STEAM Workshop.

Post Reply

Return to “X Rebirth - Scripts and Modding”