Jump to content
Sign in to follow this  
R3vo

get3DENAttribute does not return correct value

Recommended Posts

I just noticed that the command get3DENAttribute seems to not return the correct value.

 

Example:

 

Attribute value set in the attribute window is 'SIT_LOW'

 

The command returns an empty array [];

 

I would expect it to return 'SIT_LOW' or at least the default value which would be 'STAND'.

 

In the editor itself, it returns nothing, even though the value is properly set e.g returned by

systemChat str _this

This was observed on the dev version.

Share this post


Link to post
Share on other sites

Can confirm (unless we're doing something worng), BIS own attributes work just fine but custom ones don't seem to.

Share this post


Link to post
Share on other sites

Thanks for the confirmation.

Share this post


Link to post
Share on other sites

Could you please show me how is the attribute configured and how are you trying to retrieve it using get3DENAttribute? When I try it for example on allowDamage attribute (Object: Special States / Enable Damage in game), it works fine.

I'm using this code in the debug console to get the attribute value. The object has to be selected.

(get3DENSelected "object" select 0) get3DENAttribute "allowDamage"

Share this post


Link to post
Share on other sites

Attribute:

class AmbientAnimation
{
    displayName = "Ambient Animation";
    collapsed = 1;
    class Attributes
    {
        class Activate
        {
            displayName = "Activate";
            tooltip = "";
            property = "Revo_animActivate";
            control = "Checkbox";
            expression =
            "\
                if(_value) then\
                {\
                    [_this,_this getVariable ['Revo_animType','SIT_LOW'],_this getVariable ['Revo_animEquipment','NONE']] remoteExec ['BIS_fnc_ambientAnim',0,true];\
                }\
                else\
                {\
                    [_this] remoteExec ['BIS_fnc_ambientAnim__terminate',0,true];\
                };\
            ";
            condition = "objectControllable";
            defaultValue = "false";
        };
        class Type
        {
            displayName = "Animation";
            tooltip = "";
            property = "Revo_animType";
            control = "AmbAnimTypeCombo";
            expression = "_this setVariable ['Revo_animType',_value]; systemChat str _value;";
            condition = "objectControllable";
            defaultValue = "'STAND'";
            typeName = "STRING";
        };
        class Equipment
        {
            displayName = "Equipment";
            tooltip = "";
            property = "Revo_animEquipment";
            control = "AmbAnimEquipmentCombo";
            expression = "_this setVariable ['Revo_animEquipment',_value]; systemChat str _value;";
            condition = "objectControllable";
            defaultValue = "'ASIS'";
            typeName = "STRING";
        };
    };
};

 


 

Control:

class AmbAnimTypeCombo: Title
{
    attributeLoad = "\
        _ctrl = _this controlsGroupCtrl 100;\
        _attCtrl = getText( _config >> 'control' );\
        _staticItemsCfg = configFile >> 'Cfg3DEN' >> 'Attributes' >> _attCtrl >> 'Controls' >> 'Value' >> 'items';\
        \
        _fnc_setValues = {\
            private [ '_index' ];\
            params[ '_path', [ '_apply', true ] ];\
            {\
                _cfg = _x;\
                if ( _apply ) then {\
                    _index = _ctrl lbAdd getText( _cfg >> 'text' );\
                    _ctrl lbSetData [ _index, getText( _cfg >> 'data' ) ];\
                }else{\
                    _index = _foreachindex;\
                };\
                if ( !( _value isEqualType '' ) ) then {\
                    if ( _index isEqualTo _value ) then {\
                        _ctrl lbSetCurSel _index;\
                    };\
                }else{\
                    if ( _value == getText( _cfg >> 'data' ) ) then {\
                        _ctrl lbSetCurSel _index;\
                    };\
                };\
            }forEach configProperties [_path,'isclass _x'];\
        };\
        if ( isClass _staticItemsCfg ) then {\
            [ _staticItemsCfg, false ] call _fnc_setValues;\
        };\
        \
        _dynamicItemsCfg = configFile >> 'Cfg3DEN' >> 'Attributes' >> _attCtrl >> 'Controls' >> 'Value' >> 'ItemsConfig';\
        if ( isNumber( _dynamicItemsCfg >> 'localConfig' ) && { getNumber( _dynamicItemsCfg >> 'localConfig' ) > 0 } ) then {\
            _class = getArray( _dynamicItemsCfg >> 'path' ) select 0;\
            _path = missionConfigFile >> _class;\
            if ( isClass _path ) then {\
                _path call _fnc_setValues;\
            };\
        };\
    ";

    attributeSave = "\
        _ctrl = (_this controlsGroupCtrl 100);\
        _value = _ctrl lbData lbCurSel _ctrl;\
        _att = getText( _config >> 'property' );\
        collect3DENHistory {\
            {\
                _x set3DENAttribute [_att,_value];\
            } forEach ( get3DENSelected 'object' );\
        };\
    ";

    class Controls {
        class Title: Title{};
        class Value: ctrlCombo
        {
            idc = 100;
            x = ATTRIBUTE_TITLE_W * GRID_W;
            w = ATTRIBUTE_CONTENT_W * GRID_W;
            h = SIZE_M * GRID_H;

            class Items
            {
                class STAND
                {
                    text = "Stand (Slightly turning to the sides, needs rifle!)";
                    data = "'STAND'";
                    default = 1;
                };
                class STAND_IA
                {
                    text = "Stand IA (Default A3 animation)";
                    data = "'STAND_IA'";
                };
                class STAND_U1
                {
                    text = "Stand U1 (Slightly turning to the sides, no weapon)";
                    data = "'STAND_U1'";
                };
                class STAND_U2
                {
                    text = "Stand U2 ((Slightly turning to the sides, no weapon))";
                    data = "'STAND_U2'";
                };
                class STAND_U3
                {
                    text = "Stand U3 ((Slightly turning to the sides, no weapon))";
                    data = "'STAND_U3'";
                };
                class WATCH1
                {
                    text = "Watch 1 (Standing and turning around)";
                    data = "'WATCH1'";
                };
                class WATCH2
                {
                    text = "Watch 2 (Standing and turning around)";
                    data = "'WATCH2'";
                };
                class LISTEN_BRIEFING
                {
                    text = "Listen Briefing (Hands behind back, no weapon)";
                    data = "'LISTEN_BRIEFING'";
                };
                class LEAN_ON_TABLE
                {
                    text = "Lean on table (Standing while leaning on table)";
                    data = "'LEAN_ON_TABLE'";
                };
                class LEAN
                {
                    text = "Lean";
                    data = "'LEAN'";
                };
                class BRIEFING
                {
                    text = "Briefing (Ambient briefing loop)";
                    data = "'BRIEFING'";
                };
                class BRIEFING_POINT_LEFT
                {
                    text = "Briefing pointing left (Pointing left & high)";
                    data = "'BRIEFING_POINT_LEFT'";
                };
                class BRIEFING_POINT_RIGHT
                {
                    text = "Briefing pointing right (Pointing right & high)";
                    data = "'BRIEFING_POINT_right'";
                };
                class BRIEFING_POINT_TABLE
                {
                    text = "Briefing pointing down (pointing front & low)";
                    data = "'BRIEFING_POINT_TABLE'";
                };
                class SIT1_U1
                {
                    text = "Sit U1 (Sitting on bench or similar, no weapon)";
                    data = "'SIT1_U1'";
                };
                class SIT1_U2
                {
                    text = "Sit U2 (Sitting on bench or similar, no weapon)";
                    data = "'SIT1_U2'";
                };
                class SIT1_U3
                {
                    text = "Sit U3 (Sitting on bench or similar, no weapon)";
                    data = "'SIT1_U3'";
                };
                class SIT1
                {
                    text = "Sit 1 (Sitting on bench or similar)";
                    data = "'SIT1'";
                };
                class SIT2
                {
                    text = "Sit 2 (Sitting on bench or similar)";
                    data = "'SIT2'";
                };
                class SIT3
                {
                    text = "Sit 3 (Sitting on bench or similar, no weapon)";
                    data = "'SIT3'";
                };
                class SIT_AT_TABLE
                {
                    text = "Sit at table";
                    data = "'SIT_AT_TABLE'";
                };
                class SIT_LOW
                {
                    text = "Sit low (Sitting on the ground, with weapon)";
                    data = "'SIT_LOW'";
                };
                class SIT_LOW_U
                {
                    text = "Sit low U (Sitting on the ground, no weapon)";
                    data = "'SIT_LOW_U'";
                };
                class SIT_HIGH1
                {
                    text = "Sit high 1 (Sitting on higher object, legs swinging, needs a rifle)";
                    data = "'SIT_HIGH1'";
                };
                class SIT_HIGH2
                {
                    text = "Sit high 2 (Sitting on higher object, legs swinging, needs a rifle)";
                    data = "'SIT_HIGH2'";
                };
                class SIT_SAD1
                {
                    text = "Sit sad 1 (Sitting on chair, looking sad)";
                    data = "'SIT_SAD1'";
                };
                class SIT_SAD2
                {
                    text = "Sit sad 2 (Sitting on chair, looking sad)";
                    data = "'SIT_SAD2'";
                };
                class KNEEL
                {
                    text = "Kneel";
                    data = "'KNEEL'";
                };
                class PRONE_INJURED_U1
                {
                    text = "Prone injured 1 (Laying wounded on back, no weapon)";
                    data = "'PRONE_INJURED_U1'";
                };
                class PRONE_INJURED_U2
                {
                    text = "Prone injured 2 (Laying wounded on back, no weapon)";
                    data = "'PRONE_INJURED_U2'";
                };
                class PRONE_INJURED
                {
                    text = "Prone injured (Laying wounded on back, with or without weapon)";
                    data = "'PRONE_INJURED'";
                };
                class KNEEL_TREAT
                {
                    text = "Kneel treat (Treating wounded soldier)";
                    data = "'KNEEL_TREAT'";
                };
                class REPAIR_VEH_STAND
                {
                    text = "Repair vehicle (Reparing vehicle, standing)";
                    data = "'REPAIR_VEH_STAND'";
                };
                class REPAIR_VEH_KNEEL
                {
                    text = "Repair vehicle (Reparing vehicle, Kneeling)";
                    data = "'REPAIR_VEH_KNEEL'";
                };
                class REPAIR_VEH_PRONE
                {
                    text = "Repair vehicle (Reparing vehicle, Prone)";
                    data = "'REPAIR_VEH_PRONE'";
                };
            };
        };
    };
};

 


I place a unit called s2 and try to get the info with:
 
 

s2 get3DENAttribute "Revo_animType";

Share this post


Link to post
Share on other sites

 

Could you please show me how is the attribute configured and how are you trying to retrieve it using get3DENAttribute? When I try it for example on allowDamage attribute (Object: Special States / Enable Damage in game), it works fine.

I'm using this code in the debug console to get the attribute value. The object has to be selected.

(get3DENSelected "object" select 0) get3DENAttribute "allowDamage"

I tried this exactly like this, it works just fine with default attributes but not with custom ones.

For example the one I tested on inherits from CheckboxState, the only differences to the original are: idc, class name (obviously) and onAttributeLoad/save slightly altered (ctrlShow instead of ctrlEnable)..

Share this post


Link to post
Share on other sites

Yet allowDamage attribute is a custom one as well. I'll investigate.

s2 get3DENAttribute "Revo_animType";

Where are you using this code? The variable won't be available in the editor (they are assigned only at the scenario start), and checking for attribute won't work in the preview, because attributes exist only in the editor.

Share this post


Link to post
Share on other sites

Where are you using this code? The variable won't be available in the editor (they are assigned only at the scenario start), and checking for attribute won't work in the preview, because attributes exist only in the editor.

 

Now we are getting somewhere.

 

I actually wanted to use this command for the following:

 [_this,_this get3denAttribute 'Revo_animType',_this get3denAttribute 'Revo_animEquipment'] remoteExec ['BIS_fnc_ambientAnim',0,true];

So I don't need to define variables for each attribute in the missionNamespace, but seems like the command cannot be used for that purpose.

Share this post


Link to post
Share on other sites

I've added a big warning to all Community WIki pages about attributes to prevent further misunderstanding.

 

The attribute system exists only within the editor, keeping in in memory during scenario would not be efficient. That's why each attribute has an expression - you can use it to apply attribute values to the scenario.

  • Like 1

Share this post


Link to post
Share on other sites

I was using it within the editor (haven't even tried any of the *3DEN* commands outside of it) and only got [<null>] with get3DENAttribute and my slightly customized attributes.. :wacko:

Value should either be bool or number..

 

EDIT:

I have to check further if I'm f'ing up something, which is always a strong contender :P

Share this post


Link to post
Share on other sites

Well, don't really get what could be wrong here:

 

config:

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

#include "..\3DEN\UI\macros.inc"

 class Cfg3DEN {
 	class Title;
	class Value;
	class Controls;

 	class Attributes {
		class CheckboxState;

		class HTR_testCheckboxState: CheckboxState {

			class Controls: Controls {
				class Title: Title {};
				class Value: Value {
					onCheckedChanged = "\
						_ctrlCheckbox = _this select 0;\
						_state = [false,true] select (cbChecked _ctrlCheckbox);\
						_fade = [0.75,0] select _state;\
						_ctrlGroup = ctrlParentControlsGroup ctrlParentControlsGroup _ctrlCheckbox;\
						{\
							if (ctrlParentControlsGroup _x == _ctrlGroup) then {\
								_x ctrlShow _state;\
								_x ctrlsetfade _fade;\
								_x ctrlcommit 0;\
							};\
						} foreach (allcontrols (ctrlparent _ctrlCheckbox) - [ctrlParentControlsGroup _ctrlCheckbox]);\
					";
					onLoad = "\
						_this spawn {\
							disableserialization;\
							_ctrlCheckbox = _this select 0;\
							_state = [false,true] select (cbChecked _ctrlCheckbox);\
							_fade = [0.75,0] select _state;\
							_ctrlGroup = ctrlParentControlsGroup ctrlParentControlsGroup _ctrlCheckbox;\
							{\
								if (ctrlParentControlsGroup _x == _ctrlGroup) then {\
									_x ctrlShow _state;\
									_x ctrlsetfade _fade;\
									_x ctrlcommit 0;\
								};\
							} foreach (allcontrols (ctrlparent _ctrlCheckbox) - [ctrlParentControlsGroup _ctrlCheckbox]);\
						};\
					";
				};
			};
		};
	};
	class Object {
		class AttributeCategories {
			class HTR_testCat {
				displayName = "TEST";
				collapsed = 0;
				class Attributes {
					class HTR_testAtt {
						displayName = "blah blah";
						tooltip = "";
						property = "HTR_testAttID";
						control = "HTR_testCheckboxState";

						expression = "";
						defaultValue = "false";
					};
				};
			};
		};
	};
 };

Then I run this in the debug console in the editor:

[]spawn {
	while {true} do {
		systemChat str(((get3DENSelected "object") select 0) get3DENAttribute "name");
		systemChat str(((get3DENSelected "object") select 0) get3DENAttribute "HTR_testAtt");
		sleep 0.5;
	};
};

Output is:

 

[""]

[<null>]

 

And of course if I name the entity the output changes to ["whatevername"] but my custom attribute output stays at [<null>] if I tick the checkbox or not..

 

I can't see anything that would be hugely wrong in my config etc :huh:

Share this post


Link to post
Share on other sites

You're asking for HTR_testAtt (attribute class), while it should be HTR_testAttID (attribute property).

 

It's entirely my fault - the documentation was quite confusing about that, even mentioning class on many occasions. I fixed affected pages, it should be clearer now.

Share this post


Link to post
Share on other sites

Ah. Well that solves this one then. :)

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
Sign in to follow this  

×