vehicleVarName: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\|game([0-9]) ?= (.+) \|version([0-9]) ?= (.+) " to "|game$1= $2 |version$3= $4 ")
No edit summary
 
(18 intermediate revisions by 3 users not shown)
Line 18: Line 18:
|arg= global
|arg= global


|eff= local
|gr1= Object Manipulation


|gr1= Object Manipulation
|descr= 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]].


|descr= 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]]. <br>
{{Feature|informative|Respawned unit will have the same vehicleVarName as the corpse left behind, however actual [[missionNamespace]] variable of the same name will only contain respawned unit.}}


|mp= Since it is possible to [[setVehicleVarName]] individually on each PC, the value of [[vehicleVarName]] returned will be [[local]] to the PC on which command is executed.
|s1= [[vehicleVarName]] object


|s1= '''vehicleVarName''' object
|p1= object: [[Object]]


|p1= object: [[Object]]
|r1= [[String]] - variable name, if none was set, an empty string is returned


|r1= [[String]] - Variable name, if none was set, {{ic|""}} is returned
|x1= <sqf>hint vehicleVarName player;</sqf>
 
|x1= <code>[[hint]] [[vehicleVarName]] [[player]];</code>


|seealso= [[setVehicleVarName]] [[BIS_fnc_objectVar]]
|seealso= [[setVehicleVarName]] [[BIS_fnc_objectVar]]
}}
}}


<dl class="command_description">
{{Note
<dt></dt>
|user= Killzone_Kid
<dd class="notedate">Posted on April 19, 2015 - 08:45 (UTC)</dd>
|timestamp= 20150419084500
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
|text= To get variable names referencing an object in mission namespace:
<dd class="note">
<sqf>
To get variable names referencing an object in mission namespace:
KK_fnc_objectVarNames = {
<code>KK_fnc_objectVarNames <nowiki>=</nowiki> {
private "_names";
[[private]] "_names";
_names = [];
_names <nowiki>=</nowiki> [];
{
{
[[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
};
};


{{cc|Example}}
// Example
myGroup <nowiki>=</nowiki> [[group]] [[player]];
myGroup = group player;
aGroup <nowiki>=</nowiki> [[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"]
</dd>
</sqf>
</dl>
}}

Latest revision as of 20:33, 28 February 2024

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.
Respawned unit will have the same vehicleVarName as the corpse left behind, however actual missionNamespace variable of the same name will only contain respawned unit.
Groups:
Object Manipulation

Syntax

Syntax:
vehicleVarName object
Parameters:
object: Object
Return Value:
String - variable name, if none was set, an empty string 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"]