Jump to content
joemac90

Custom Combo & Attribute for only Ammo or Supply Boxes.

Recommended Posts

I have created a new attribute and combobox box.

 

Which category would I use to only display this on an ammo or supply box?

// Condition 	        For Type   Description
// object               Object     All
// objectBrain 	        Object     Object with simulation "soldier" or "UAVpilot"
// objectControllable 	Object 	   Object with simulation "soldier"
// objectAgent 	        Object 	   Object with non-empty agentTasks[], i.e., animals/
// objectVehicle 	Object 	   Vehicle which can be boarded
// objectSimulated 	Object 	   Object which is simulated (e.g., falls down when in the air)
// objectDestructable 	Object 	   Indestructible object, i.e., when destrType config property set not DestructNo
// logicModule 	        Logic      Logic which is a module (vehicleClass config property is "Modules")

Share this post


Link to post
Share on other sites

Theoretically objectSimulated, however that would also include many other objects. I'd wish they would implement more categories.

Share this post


Link to post
Share on other sites

Just place it in CfgVehicles in an Eden addon e.g

class CfgPatches {
	class TAG_myInit {
		units[] = {};
		weapons[] = {};
		requiredVersion = 1.0;
		requiredAddons[] = {3DEN};
	};
};


class CfgVehicles
{
	class All;
	class Thing: All
	{
		class Attributes
		{
			class ObjectTexture;
		};
	};
	class ThingX: Thing
	{
		class Attributes
		{
			class ObjectTexture;
		};
	};
	class ReammoBox_F : ThingX
	{
		class Attributes : Attributes
		{
			class ObjectTexture : ObjectTexture{};
			class TAG_myInit
			{
				//--- Mandatory properties
				displayName = "Init Code";
				tooltip = "My Init Code";
				property = "TAG_myInit";
				control = "EditCodeMulti3";

				expression = "if !( is3Den ) then { _this call compile format[ 'this = _this; %1', _value ] };";

				defaultValue = "''";

				//--- Optional properties
				validate = "expression";
				typeName = "STRING";
			};
		}; 
	};
};
  • Like 1

Share this post


Link to post
Share on other sites

Keep in mind that Larrow's solution will create a dependency when used for mission creation.

Share this post


Link to post
Share on other sites

Keep in mind that Larrow's solution will create a dependency when used for mission creation.

No it will not. That is the whole point of using CfgVehicles in a requiredAddons = {3Den} addon.

The attribute is saved in the sqm and is run from the information saved in the sqm, the addon is not required by the end user to play the content.

The only time it will break is if you edit the mission without having the 3Den addon loaded up as it will remove the information from the sqm.

HERE (rightclick and save as, as ive uploaded as a pbo and dropbox links it as text) is a single player PBO created using the previous posts addon. Load it up and take note of the hint. :P :)

If you view it as text (just click the link above) as it is a decrypted sqm in the pbo you will see..

class CustomAttributes
{
	class Attribute0
	{
		property="TAG_myInit";
		expression="if !( is3Den ) then { _this call compile format[ 'this = _this; %1', _value ] };";
		class Value
		{
			class data
			{
				class type
				{
					type[]=
					{
						"STRING"
					};
				};
				value="hint ""R3vo is incorrect""";
			};
		};
	};
	nAttributes=1;
};
buried in the ammo boxes class structure. Basically all the engine does is something along the lines of...

{
	_property = getText( _x >> "property" );
	_expression = getText( _x >> "expression" );
	_dataType = getArray( _x >> "Value" >> "data" >> "type" >> "type" ) select 0;
	_value = switch ( _dataType ) do {
		case "STRING" : {
			getText( _x >> "Value" >> "data" >> "value" );
		};
	};
	_header = "params[ '_this', '_value' ];";
	_split = _expression splitString "%s";
	_expression = format[ "%1 %2 %3", _split select 0, str _property, _split select 1 ]; //<< hence the reason you can only use %s for the attribute name once in your expressions
	[ _object, _value ] call compile format[ "%1%2", _header, _expression ];
}forEach ( "true" configClasses ( missionConfigFile >> .... >> object >> "CustomAttributes" ));  
  • Like 1

Share this post


Link to post
Share on other sites

No it will not. That is the whole point of using CfgVehicles in a requiredAddons = {3Den} addon.

The attribute is saved in the sqm and is run from the information saved in the sqm, the addon is not required by the end user to play the content.

The only time it will break is if you edit the mission without having the 3Den addon loaded up as it will remove the information from the sqm.

HERE (rightclick and save as, as ive uploaded as a pbo and dropbox links it as text) is a single player PBO created using the previous posts addon. Load it up and take note of the hint. :P :)

 

Thanks for the info. Learning something new every day.

Share this post


Link to post
Share on other sites

So I tried the following and well...the Hunter got the custom mod icon next to its name and I added a dependency. Where did I go wrong?

class CfgVehicles
{
    class MRAP_01_base_F;
    class B_MRAP_01_F: MRAP_01_base_F
    {
        class Attributes // Entity attributes have no categories, they are all defined directly in class Attributes
        {
            class Enh_test
            {
                displayName = "test";
                tooltip = "";
                property = "Enh_test";
                control = "Edit";
                expression = "systemChat 'Works'";
                defaultValue = "false";
            };
        };
    };
};

Share this post


Link to post
Share on other sites

Ok thank-you for your help, I will give them both a try.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×