{"name":"import (Config)","title":"import (Config)","type":"topic","url":"https://community.bistudio.com/wiki/import_(Config)","revid":352475,"updated":"2024-02-11T23:38:07Z","aliases":[],"markdown":"Arma 3 v2.02\nThe `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.\nUseful 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.\n\nThe 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.\nFor example if one needs to inherit from `RscText`, the `import RscText;` should precede the inheritance:\n\n```cpp\nimport RscText;\nclass MyText : RscText\n{\n    // ...\n};\n```\n\nThe `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.\n\n### Modifiers\n\n#### from\n\nThe `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:\n\n```cpp\nimport Default from CfgTasks;\nclass CfgTasks\n{\n    class MyAwesomeTask : Default\n    {\n        name = \"My Awesome Task\";\n    };\n};\n```\n\n#### as (Arma 3 v2.14)\n\nThe `as` keyword is used to import a class from main config as another name, for example:\n\n```cpp\nimport CfgRemoteExec as CfgRemoteExecMod;\n\nclass CfgRemoteExec : CfgRemoteExecMod\n{\n    class Server : Server\n    {\n        class Functions : Functions\n        {\n            jip = 0;\n            class BIS_fnc_effectKilledSecondaries\n            {\n                allowedTargets = 0;\n                jip = 0;\n            };\n        };\n    };\n};\n```\n\n### Properties Override\n\nThe properties override is done in the same way it is done for modding.\n\n```cpp\nimport RscText;\nclass MyText : RscText\n{\n    style = 2;\n};\n```\n\nWhen the property is inside another class, this is how it can be done:\n\n```cpp\nimport RscStructuredText;\nclass MyText : RscStructuredText\n{\n    class Attributes : Attributes\n    {\n        align = \"right\";\n    };\n};\n```\n\nHere is example of overriding the color of vignette:\n\n```cpp\nimport RscDisplayEmpty;\nclass MyRscDisplayEmpty : RscDisplayEmpty\n{\n    class controls : controls\n    {\n        class CA_Vignette : CA_Vignette\n        {\n            colorText[] = { 1, 0, 0, 1 };\n        };\n    };\n};\n```\n\nAnd the result, after executing `findDisplay 46 createDisplay \"MyRscDisplayEmpty\";` in debug console:\n\n### Check Imported Classes\n\nIn debug console type `utils 2`, `LOCAL EXEC`, and select mission config from drop down menu. The mission config will be displayed including imported classes","sections":[{"heading":null,"level":1,"markdown":"Arma 3 v2.02\nThe `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.\nUseful 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.\n\nThe 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.\nFor example if one needs to inherit from `RscText`, the `import RscText;` should precede the inheritance:\n\n```cpp\nimport RscText;\nclass MyText : RscText\n{\n    // ...\n};\n```\n\nThe `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."},{"heading":"Modifiers","level":3,"markdown":""},{"heading":"from","level":4,"markdown":"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:\n\n```cpp\nimport Default from CfgTasks;\nclass CfgTasks\n{\n    class MyAwesomeTask : Default\n    {\n        name = \"My Awesome Task\";\n    };\n};\n```"},{"heading":"as (Arma 3 v2.14)","level":4,"markdown":"The `as` keyword is used to import a class from main config as another name, for example:\n\n```cpp\nimport CfgRemoteExec as CfgRemoteExecMod;\n\nclass CfgRemoteExec : CfgRemoteExecMod\n{\n    class Server : Server\n    {\n        class Functions : Functions\n        {\n            jip = 0;\n            class BIS_fnc_effectKilledSecondaries\n            {\n                allowedTargets = 0;\n                jip = 0;\n            };\n        };\n    };\n};\n```"},{"heading":"Properties Override","level":3,"markdown":"The properties override is done in the same way it is done for modding.\n\n```cpp\nimport RscText;\nclass MyText : RscText\n{\n    style = 2;\n};\n```\n\nWhen the property is inside another class, this is how it can be done:\n\n```cpp\nimport RscStructuredText;\nclass MyText : RscStructuredText\n{\n    class Attributes : Attributes\n    {\n        align = \"right\";\n    };\n};\n```\n\nHere is example of overriding the color of vignette:\n\n```cpp\nimport RscDisplayEmpty;\nclass MyRscDisplayEmpty : RscDisplayEmpty\n{\n    class controls : controls\n    {\n        class CA_Vignette : CA_Vignette\n        {\n            colorText[] = { 1, 0, 0, 1 };\n        };\n    };\n};\n```\n\nAnd the result, after executing `findDisplay 46 createDisplay \"MyRscDisplayEmpty\";` in debug console:"},{"heading":"Check Imported Classes","level":3,"markdown":"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"}],"categories":["Introduced with Arma 3 version 2.02","Scripting Topics"],"groups":["Scripting"]}