vehicleVarName: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\[\[([a-zA-Z][a-zA-Z0-9_]+)\]\]([^ ]*)<\/code>" to "$1$2</code>")
m (Some wiki formatting)
Line 35: Line 35:
}}
}}


{{Notes
{{Note
|user= Killzone_Kid
|user= Killzone_Kid
|timestamp= 20150419084500
|timestamp= 20150419084500
|text= To get variable names referencing an object in mission namespace:
|text= To get variable names referencing an object in mission namespace:
<code>KK_fnc_objectVarNames = {
<sqf>
[[private]] "_names";
KK_fnc_objectVarNames = {
_names <nowiki>=</nowiki> [];
private "_names";
_names = [];
{
{
[[if]] ([[missionNamespace]] [[getVariable]] _x [[isEqualTo]] _this) [[then]] {
if (missionNamespace getVariable _x isEqualTo _this) then {
_names [[pushBack]] _x;
_names pushBack _x;
};
};
} [[forEach]] [[allVariables]] [[missionNamespace]];
} forEach allVariables missionNamespace;
_names
_names
};
};


// Example
// Example
myGroup = [[group]] [[player]];
myGroup = group player;
aGroup = [[group]] [[player]];
aGroup = group player;
hint str (group player call KK_fnc_objectVarNames); // ["agroup", "mygroup"]</code>
hint str (group player call KK_fnc_objectVarNames); // ["agroup", "mygroup"]
</sqf>
}}
}}

Revision as of 12:18, 13 May 2022

Hover & click on the images for description

Description

Description:
Returns the variable name that contains a primary editor reference to this object. This is the variable given in the Insert Unit dialog / name field in the editor. It can be changed using setVehicleVarName.
Groups:
Object Manipulation

Syntax

Syntax:
vehicleVarName object
Parameters:
object: Object
Return Value:
String - Variable name, if none was set, "" is returned

Examples

Example 1:
hint vehicleVarName player;

Additional Information

See also:
setVehicleVarName BIS_fnc_objectVar

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Killzone_Kid - c
Posted on Apr 19, 2015 - 08:45 (UTC)
To get variable names referencing an object in mission namespace:
KK_fnc_objectVarNames = { private "_names"; _names = []; { if (missionNamespace getVariable _x isEqualTo _this) then { _names pushBack _x; }; } forEach allVariables missionNamespace; _names }; // Example myGroup = group player; aGroup = group player; hint str (group player call KK_fnc_objectVarNames); // ["agroup", "mygroup"]