CfgPatches: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "Category:Eden Editor" to "Eden Editor")
 
(16 intermediate revisions by 6 users not shown)
Line 1: Line 1:
'''CfgPatches''' is a header class of an addon. Placed in [[Config.cpp]], it contains information about requirements, content and meta data describing the addon.
{{TOC|side}}
[[CfgPatches]] is a header class of an addon. Placed in [[Config.cpp]], it contains information about requirements, content and meta data describing the addon.


If the config doesn't contain CfgPatches, it is ignored when the game is loading addons on startup.
If the config doesn't contain CfgPatches, it is ignored when the game is loading addons on startup.


{{Feature|EdenEditor|For [[:Category:Eden Editor|Eden Editor]] see also [[Eden Editor: Modding#Addon_Configuration|Eden Editor: Modding]].}}


== Configuration ==
== Configuration ==
=== Root ===
=== Root ===
Most commonly, config.cpp file is placed in addon folder's root.
Most commonly, config.cpp file is placed in addon folder's root.


Line 19: Line 23:
url = "http://xkcd.com";
url = "http://xkcd.com";


// Minimum compatible version. When the game's version is lower, pop-up warning will appear when launching the game.
// Minimum compatible version. When the game's version is lower, pop-up warning will appear when launching the game. Note: was disabled on purpose some time late into Arma 2: OA.
requiredVersion = 1.60;  
requiredVersion = 1.60;
// Required addons, used for setting load order.
// Required addons, used for setting load order. (CfgPatches classname NOT PBO filename!)
// When any of the addons is missing, pop-up warning will appear when launching the game.
// When any of the addons are missing, a pop-up warning will appear when launching the game.
requiredAddons[] = {"A3_Functions_F"};
requiredAddons[] = { "A3_Functions_F" };
// List of objects (CfgVehicles classes) contained in the addon. Important also for Zeus content (units and groups) unlocking.
// List of objects (CfgVehicles classes) contained in the addon. Important also for Zeus content (units and groups) unlocking.
units[] = {};
units[] = {};
// List of weapons (CfgWeapons classes) contained in the addon.
// List of weapons (CfgWeapons classes) contained in the addon.
weapons[] = {};
weapons[] = {};
// Optional. If this is 1, if any of requiredAddons[] entry is missing in your game the entire config will be ignored and return no error (but in rpt) so useful to make a compat Mod (Since Arma 3 2.14)
skipWhenMissingDependencies = 1;
};
};
};
};
</syntaxhighlight>
</syntaxhighlight>


<tt>requiredAddons</tt> is the most important setting, because it defines initialization order of addons. If addon B requires addon A, then it will be loaded only once A is loaded as well. This is extremely crucial for making sure [[Class Inheritance]] works as intended. If an addon is using some assets from addon C (e.g., textures, sounds, etc.), it's a good practice to make C a required addons.
{{hl|requiredAddons}} is the most important setting, because it defines the initialization order of addons. If addon B requires addon A, then it will be loaded only once A is loaded as well. This is extremely crucial for making sure [[Class Inheritance]] works as intended. If an addon is using some assets from addon C (e.g., textures, sounds, etc.), it is a good practice to make C a required addons.


=== Sub-folders ===
=== Sub-folders ===
Additional config files can be also placed in sub-folders. Even when part of the same [[PBO]], they are treated as individual addons by the game.
 
Additional config.cpp files can be also placed in sub-folders of an addon (/[[PBO]]), they are treated as individual addons by the game.


To  make configuration of meta data simpler, you can simply create a link to the root class instead of defining name, author and url again. A good practice is to have all configs withing one PBO to use the same meta data.
To  make configuration of meta data simpler, you can simply create a link to the root class instead of defining name, author and url again. A good practice is to have all configs withing one PBO to use the same meta data.
Line 49: Line 57:


requiredVersion = 1.60;
requiredVersion = 1.60;
requiredAddons[] = {"MyAddon"};
requiredAddons[] = { "MyAddon" };
units[] = {};
units[] = {};
weapons[] = {};
weapons[] = {};
Line 57: Line 65:


== Scenario Design ==
== Scenario Design ==
{| style="margin: 0 auto 0 auto;"
 
|[[File:3den requiredAddons.jpg|center|384px]]
{| style="margin: 0 auto"
|[[File:3den requiredAddons advanced.jpg|center|384px]]
| [[File:3den requiredAddons.jpg|center|384px]]
| [[File:3den requiredAddons advanced.jpg|center|384px]]
|}
|}


When a designer is saving a scenario, meta data of all required addons are saved to [[Mission_Editor:_External#Mission.sqm|mission.sqm]] as well. When someone else attempts to load the scenario without having the required addons, he will be shown a list of all addons including meta data, even though he doesn't have the addons where they're defined.
When a designer is saving a scenario, meta data of all required addons are saved to [[Mission Editor: External#Mission.sqm|mission.sqm]] as well. When someone else attempts to load the scenario without having the required addons, he will be shown a list of all addons including meta data, even though he doesn't have the addons where they're defined.
 
Introduced to [[:Category:Eden Editor|Eden Editor]] in {{GVI|arma3|1.60}}
 


Introduced to [[Eden Editor]] in {{GVI|arma3|1.60}}
{{GameCategory|arma3|Editing}}

Latest revision as of 14:27, 9 July 2023

CfgPatches is a header class of an addon. Placed in Config.cpp, it contains information about requirements, content and meta data describing the addon.

If the config doesn't contain CfgPatches, it is ignored when the game is loading addons on startup.

Configuration

Root

Most commonly, config.cpp file is placed in addon folder's root.

MyAddon\config.cpp

class CfgPatches
{
	class MyAddon
	{
		// Meta information for editor
		name = "My Addon";
		author = "Me";
		url = "http://xkcd.com";

		// Minimum compatible version. When the game's version is lower, pop-up warning will appear when launching the game. Note: was disabled on purpose some time late into Arma 2: OA.
		requiredVersion = 1.60;
		// Required addons, used for setting load order. (CfgPatches classname NOT PBO filename!)
		// When any of the addons are missing, a pop-up warning will appear when launching the game.
		requiredAddons[] = { "A3_Functions_F" };
		// List of objects (CfgVehicles classes) contained in the addon. Important also for Zeus content (units and groups) unlocking.
		units[] = {};
		// List of weapons (CfgWeapons classes) contained in the addon.
		weapons[] = {};

		// Optional. If this is 1, if any of requiredAddons[] entry is missing in your game the entire config will be ignored and return no error (but in rpt) so useful to make a compat Mod (Since Arma 3 2.14)
		skipWhenMissingDependencies = 1;
	};
};

requiredAddons is the most important setting, because it defines the initialization order of addons. If addon B requires addon A, then it will be loaded only once A is loaded as well. This is extremely crucial for making sure Class Inheritance works as intended. If an addon is using some assets from addon C (e.g., textures, sounds, etc.), it is a good practice to make C a required addons.

Sub-folders

Additional config.cpp files can be also placed in sub-folders of an addon (/PBO), they are treated as individual addons by the game.

To make configuration of meta data simpler, you can simply create a link to the root class instead of defining name, author and url again. A good practice is to have all configs withing one PBO to use the same meta data.

MyAddon\Weapons\config.cpp

class CfgPatches
{
	class MyAddon_Weapons
	{
		// Use meta information from specified addon. Used to avoid repeated declarations.
		addonRootClass = "MyAddon";

		requiredVersion = 1.60;
		requiredAddons[] = { "MyAddon" };
		units[] = {};
		weapons[] = {};
	};
};

Scenario Design

3den requiredAddons.jpg
3den requiredAddons advanced.jpg

When a designer is saving a scenario, meta data of all required addons are saved to mission.sqm as well. When someone else attempts to load the scenario without having the required addons, he will be shown a list of all addons including meta data, even though he doesn't have the addons where they're defined.

Introduced to Eden Editor in Arma 3 logo black.png1.60