Module Framework – Arma 3
Jump to navigation
Jump to search
m (Removed: Mention of module icon, no longer needs a standardized frame in Eden) |
mNo edit summary |
||
Line 80: | Line 80: | ||
class Module_F: Logic | class Module_F: Logic | ||
{ | { | ||
class | class AttributesBase | ||
{ | { | ||
class Units; | class Default; | ||
class Edit; {{codecomment|// Default edit box (i.e., text input field)}} | |||
class Combo; {{codecomment|// Default combo box (i.e., drop-down menu)}} | |||
class Checkbox; {{codecomment|// Default checkbox (returned value is [[Bool]])}} | |||
class CheckboxNumber; {{codecomment|// Default checkbox (returned value is [[Number]])}} | |||
class ModuleDescription; {{codecomment|// Module description}} | |||
class Units; {{codecomment|// Selection of units on which the module is applied}} | |||
}; | }; | ||
{{codecomment|// Description base classes, for more information see below}} | |||
class ModuleDescription | class ModuleDescription | ||
{ | { | ||
Line 113: | Line 120: | ||
curatorInfoType = "RscDisplayAttribute<span style="color:green">Module</span><span style="color:orangered;">Nuke</span>"; | curatorInfoType = "RscDisplayAttribute<span style="color:green">Module</span><span style="color:orangered;">Nuke</span>"; | ||
{{codecomment|// Module | {{codecomment|// Module attributes, uses https://community.bistudio.com/wiki/Eden_Editor:_Configuring_Attributes#Entity_Specific}} | ||
class | class Attributes: AttributesBase | ||
{ | { | ||
{{codecomment|// Arguments shared by specific module type (have to be mentioned in order to be | {{codecomment|// Arguments shared by specific module type (have to be mentioned in order to be present)}} | ||
class Units: Units {}; | class Units: Units | ||
{ | |||
property = "<span style="color:indigo">myTag</span>_<span style="color:green">Module</span><span style="color:orangered;">Nuke</span>_Units"; | |||
}; | |||
{{codecomment|// Module specific arguments}} | {{codecomment|// Module specific arguments}} | ||
class Yield | class Yield: Combo | ||
{ | { | ||
{{codecomment|// Unique property, use "<moduleClass>_<attributeClass>" format to make sure the name is unique in the world}} | |||
property = "<span style="color:indigo">myTag</span>_<span style="color:green">Module</span><span style="color:orangered;">Nuke</span>_Yield"; | |||
displayName = "Nuclear weapon yield"; {{codecomment|// Argument label}} | displayName = "Nuclear weapon yield"; {{codecomment|// Argument label}} | ||
description = "How strong will the explosion be"; {{codecomment|// Tooltip description}} | description = "How strong will the explosion be"; {{codecomment|// Tooltip description}} | ||
typeName = "NUMBER"; {{codecomment|// Value type, can be "NUMBER", "STRING" or "BOOL"}} | typeName = "NUMBER"; {{codecomment|// Value type, can be "NUMBER", "STRING" or "BOOL"}} | ||
class | defaultValue = "50"; {{codecomment|// Default attribute value. WARNING: This is an expression, and its returned value will be used (50 in this case)}} | ||
class Values | |||
{ | { | ||
class 50Mt {name = "50 megatons"; value = 50 | class 50Mt {name = "50 megatons"; value = 50;}; {{codecomment|// Listbox item}} | ||
class 100Mt {name = "100 megatons"; value = 100;}; | class 100Mt {name = "100 megatons"; value = 100;}; | ||
}; | }; | ||
}; | }; | ||
class Name | class Name: Edit | ||
{ | { | ||
displayName = "Name"; | displayName = "Name"; | ||
description = "Name of the nuclear device"; | description = "Name of the nuclear device"; | ||
{{codecomment|// Default text filled in the input box}} | |||
{{codecomment|// | {{codecomment|// Because it's an expression, to return a [[String]] one must have a string within a string}} | ||
defaultValue = """Tsar Bomba"""; | |||
}; | }; | ||
class ModuleDescription: ModuleDescription{}; {{codecomment|// Module description should be shown last}} | |||
}; | }; | ||
Line 209: | Line 224: | ||
{{codecomment|// Module specific behavior. Function can extract arguments from logic and use them.}} | {{codecomment|// Module specific behavior. Function can extract arguments from logic and use them.}} | ||
if (_activated) then { | if (_activated) then { | ||
{{codecomment|// | {{codecomment|// Attribute values are saved in module's object space under their class names}} | ||
_bombYield = _logic [[getVariable]] ["Yield",-1]; {{codecomment|//(as per the previous example, but you can define your own.) }} | |||
_bombYield = _logic getVariable "Yield"; {{codecomment|//(as per the previous example, but you can define your own.) }} | |||
hint format ["Bomb yield is: %1", _bombYield ]; {{codecomment|// will display the bomb yield, once the game is started }} | hint format ["Bomb yield is: %1", _bombYield ]; {{codecomment|// will display the bomb yield, once the game is started }} | ||
}; | }; |
Revision as of 14:48, 20 December 2016
Arma 3 introduces a module framework, which lets designer to simplify the configuration and chose how the module function will be executed (e.g., globally and for every player who joins later).
How to Create a Module
When creating a new module, follow these steps:
- Create a module addon.
- Make a folder named myTag_addonName a create a config.cpp file in it.
- Inside, declare a CfgPatches class with your addon and its modules (in the units array). Without this, the game wouldn't recognize the addon.
- Make sure the addon and all objects start with your tag, e.g. myTag
- Select a module category
- Modules are placed into basic categories which makes finding a desired module easier for an user. Use can use on of the existing categories:
- Create config for module logic
- All in-game objects (soldiers, vehicles, buildings, logics, modules, ...) are defined in CfgVehicles class.
- All modules must inherit from Module_F parent class, either directly or through some additional sub-parent. While modules inheriting from some other class will be still displayed in the Modules menu (F7), they won't be using the module framework and all benefits tied to it.
- Modules functions are by default not executed when in Eden Editor workspace. It can be enabled using is3DEN property, but that will also change format of function params (see the section about writing a function below).
- Pre-defined sync preview entities are:
- Anything - Any object - persons, vehicles, static objects, etc.
- AnyPerson - Any person. Not vehicles or static objects.
- AnyVehicle - Any vehicle. No persons or static objects.
- AnyStaticObject - Any static object. Not persons or vehicles.
- AnyBrain - Any AI or player. Not empty objects
- AnyAI - Any AI unit. Not players or empty objects
- AnyPlayer - Any player. Not AI units or empty objects
- EmptyDetector - Any trigger
- Configure a module function
- Place class CfgFunctions to config.cpp. See Functions Library (Arma 3) for more info about functions configuration.
- Write the module function
- Create the functions folder within the addon folder and place *.sqf or *.fsm files there.
- Example: \myTag_addonName\functions\fn_moduleNuke.sqf
- Input parameters differ based on value of is3DEN property.
class | displayName |
---|---|
Effects | Effects |
Events | Events |
Modes | Gameplay Modes |
GroupModifiers | Group Modifiers |
Intel | Intel |
NO_CATEGORY | Misc |
Multiplayer | Multiplayer |
ObjectModifiers | Object Modifiers |
Sites | Sites |
StrategicMap | Strategic |
Supports | Supports |
Alternatively, you can create your own one:
class CfgFactionClasses { class NO_CATEGORY; class myTag_explosions: NO_CATEGORY { displayName = "Explosions"; }; };