Scrocco88 1 Posted March 14, 2013 How can i get (in a script) the Object reference to an object created in the editor, having his name stored in a variable? Something like: _variable = "my_object_name"; _obj = getObjectByName _variable; Share this post Link to post Share on other sites
Tajin 349 Posted March 14, 2013 http://community.bistudio.com/wiki/vehicleVarName http://community.bistudio.com/wiki/setVehicleVarName Aside from that, the name itself is a reference to the object. 1 Share this post Link to post Share on other sites
Scrocco88 1 Posted March 14, 2013 mmm... i think it's not what i asked for. vehicleVarName: Returns the name of the variable which 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. setVehicleVarName Sets the name of the variable which contains a reference to this object. In both cases you already have an Object variable, and you manipulate it's name. I need to GET the object already HAVING his name, stored in a String variable. vehicleVarName Syntax: String = vehicleVarName objectName [b]Parameters: [/b]objectName: Object [b]Return Value:[/b] String I'm looking for something like object = <something> objectName [b]Parameters:[/b] objectName: String [b]Return Value: [/b]object Share this post Link to post Share on other sites
Master85 1 Posted March 14, 2013 http://community.bistudio.com/wiki/getVariable http://community.bistudio.com/wiki/missionNamespace Share this post Link to post Share on other sites
galevsky 11 Posted May 14, 2015 Does someone have the solution ? I am still blocked on this issue: _myObjectName = "first_laptop"; _myObjectInstance = ?????? ; // Looking for something like BIS_fn_GetObjectByName _myObjectName _res = alive _myObjectInstance; // if I use _myObjectName instead, there is an error: Error alive: Type String, expected Object Share this post Link to post Share on other sites
cuel 25 Posted May 14, 2015 _myObjectName = "first_laptop"; _myObjectInstance = missionNamespace getVariable [_myObjectName , objNull]; if (isNull _myObjectInstance ) exitWith{ ["Null ref %1", _myObjectName] call BIS_fnc_error; }; _res = alive _myObjectInstance; // if I use _myObjectName instead, there is an error: Error alive: Type String, expected Object Share this post Link to post Share on other sites
Schatten 287 Posted May 14, 2015 (edited) _myObjectInstance = objNull; {if ((vehicleVarName _x) == "first_laptop") exitWith {_myObjectInstance = _x}} forEach (allMissionObjects "Laptop"); if (!(isNull _myObjectInstance)) then {...}; Also should work _myObjectInstance = missionNamespace getVariable ["first_laptop", objNull]; if (!(isNull _myObjectInstance)) then {...}; Edited May 14, 2015 by Schatten Share this post Link to post Share on other sites
galevsky 11 Posted May 14, 2015 _myObjectInstance = missionNamespace getVariable [_myObjectName , objNull]; Does the job ! Big thank you @Schatten: thks too, but I was looking for optimized code, with no loop... Share this post Link to post Share on other sites