import (Config): Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "<tt>([a-zA-Z0-9\. _"\\']+)<\/tt>" to "{{hl|$1}}")
m (Some wiki formatting)
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{TOC|side}}
{{TOC|side}}
{{GVI|arma3|2.02}}
{{GVI|arma3|2.02}}
== '''import''' keyword ==
The {{hl|import}} keyword '''can only be used''' in [[Description.ext|mission config]], pretty much like {{hl|class}} keyword, in order to import a class from main config into mission config.
Useful for UI creation as UI controls have a lot of properties which are already defined in main config, so if only some tweaks are required, it could be easily done after importing the class.


The {{hl|import}} keyword  '''can only be used''' in [[Description.ext|mission config]], pretty much like {{hl|class}} keyword, in order to import a class from main config into mission config. Useful for UI creation as UI controls have a lot of properties which are already defined in main config, so if only some tweaks are required, it could be easily done after importing the class.
The keyword tells parser to copy given class during parsing of the mission config so the imported class will be placed where the keyword {{hl|import}} was placed.
 
For example if one needs to inherit from {{hl|RscText}}, the {{hl|import RscText;}} should precede the inheritance:
The keyword tells parser to copy given class during parsing of the mission config so the imported class will be placed where the keyword {{hl|import}} was placed. For example if one needs to inherit from {{hl|RscText}}, the <tt>import RscText;</tt> should precede the inheritance:


<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
import RscText;
import RscText;
class MyText: RscText  
class MyText : RscText
{
{
// ...
// ...
Line 18: Line 18:




== '''from''' keyword ==
== Modifiers ==
 
=== from ===


The {{hl|from}} keyword is used to indicate specific config path from where the class should be imported. For example, one can do things like this, not that one will even need this particular usage:
The {{hl|from}} keyword is used to indicate specific config path from where the class should be imported. For example, one can do things like this, not that one will even need this particular usage:
Line 24: Line 26:
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
import Default from CfgTasks;
import Default from CfgTasks;
class CfgTasks
class CfgTasks
{
{
class MyAwesomeTask: Default
class MyAwesomeTask : Default
{
{
name = "My Awesome Task";
name = "My Awesome Task";
};
};
</syntaxhighlight>
{{ArgTitle|3|as|{{GVI|arma3|2.14}}}}
The {{hl|as}} keyword is used to import a class from main config as another name, for example:
<syntaxhighlight lang="cpp">
import CfgRemoteExec as CfgRemoteExecMod;
class CfgRemoteExec : CfgRemoteExecMod
{
class Server : Server
{
class Functions : Functions
{
jip = 0;
class BIS_fnc_effectKilledSecondaries
{
allowedTargets = 0;
jip = 0;
};
};
};
};
};
};
Line 35: Line 60:




== Modifying properties ==
== Properties Override ==


The properties override is done in the same way it is done for modding.  
The properties override is done in the same way it is done for modding.


<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
import RscText;
import RscText;
class MyText: RscText  
class MyText : RscText
{
{
style = 2;
style = 2;
Line 47: Line 72:
</syntaxhighlight>
</syntaxhighlight>


When property is inside another class, this is how it could be done:
When the property is inside another class, this is how it can be done:


<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
import RscStructuredText;
import RscStructuredText;
class MyText: RscStructuredText
class MyText : RscStructuredText
{
{
class Attributes: Attributes
class Attributes : Attributes
{
{
align = "right";
align = "right";
Line 64: Line 89:
<syntaxhighlight lang="cpp">
<syntaxhighlight lang="cpp">
import RscDisplayEmpty;
import RscDisplayEmpty;
class MyRscDisplayEmpty: RscDisplayEmpty
class MyRscDisplayEmpty : RscDisplayEmpty
{
{
class controls: controls
class controls : controls
{
{
class CA_Vignette: CA_Vignette
class CA_Vignette : CA_Vignette
{
{
colorText[] = {1,0,0,1};
colorText[] = { 1, 0, 0, 1 };
};
};
};
};
Line 76: Line 101:
</syntaxhighlight>
</syntaxhighlight>


And the result, after executing <code>[[findDisplay]] 46 [[createDisplay]] "MyRscDisplayEmpty";</code> in debug console:
And the result, after executing <sqf inline>findDisplay 46 createDisplay "MyRscDisplayEmpty";</sqf> in debug console:


[[Image:vignette_modified.jpg|600px]]
[[File:vignette_modified.jpg|600px]]




== Checking imported classes ==
== Check Imported Classes ==


In debug console type [[Arma 3: Utilities#Print Config|{{hl|utils 2}}]], LOCAL EXEC, and select mission config from drop down menu. The mission config will be displayed including imported classes
In debug console type {{hl|[[Arma 3: Utilities#Print Config|utils 2]]}}, {{hl|LOCAL EXEC}}, and select mission config from drop down menu. The mission config will be displayed including imported classes




[[Category:Scripting Topics]]
[[Category:Scripting Topics]]
[[Category:Introduced with Arma 3 version 2.02]]
[[Category:Introduced with Arma 3 version 2.02]]

Latest revision as of 00:38, 12 February 2024

Arma 3 logo black.png2.02 The import keyword can only be used in mission config, pretty much like class keyword, in order to import a class from main config into mission config. Useful for UI creation as UI controls have a lot of properties which are already defined in main config, so if only some tweaks are required, it could be easily done after importing the class.

The keyword tells parser to copy given class during parsing of the mission config so the imported class will be placed where the keyword import was placed. For example if one needs to inherit from RscText, the import RscText; should precede the inheritance:

import RscText;
class MyText : RscText
{
	// ...
};

The import keyword tells the engine to look for the base class in main config, which means classes in base directory. However, it is also possible to look in other dirs using from keyword.


Modifiers

from

The from keyword is used to indicate specific config path from where the class should be imported. For example, one can do things like this, not that one will even need this particular usage:

import Default from CfgTasks;
class CfgTasks
{
	class MyAwesomeTask : Default
	{
		name = "My Awesome Task";
	};
};

as

The as keyword is used to import a class from main config as another name, for example:

import CfgRemoteExec as CfgRemoteExecMod;

class CfgRemoteExec : CfgRemoteExecMod
{
	class Server : Server
	{
		class Functions : Functions
		{
			jip = 0;
			class BIS_fnc_effectKilledSecondaries
			{
				allowedTargets = 0;
				jip = 0;
			};
		};
	};
};


Properties Override

The properties override is done in the same way it is done for modding.

import RscText;
class MyText : RscText
{
	style = 2;
};

When the property is inside another class, this is how it can be done:

import RscStructuredText;
class MyText : RscStructuredText
{
	class Attributes : Attributes
	{
		align = "right";
	};
};

Here is example of overriding the color of vignette:

import RscDisplayEmpty;
class MyRscDisplayEmpty : RscDisplayEmpty
{
	class controls : controls
	{
		class CA_Vignette : CA_Vignette
		{
			colorText[] = { 1, 0, 0, 1 };
		};
	};
};

And the result, after executing findDisplay 46 createDisplay "MyRscDisplayEmpty"; in debug console:

vignette modified.jpg


Check Imported Classes

In debug console type utils 2, LOCAL EXEC, and select mission config from drop down menu. The mission config will be displayed including imported classes