Jump to content

Recommended Posts

Does anyone have a simple way of getting the animation name of the door you are looking at?

I have been using animationNames and then opening each of the doors using foreach while displaying the anime name in system chat, but it is not very efficient.

Share this post


Link to post
Share on other sites

I am not the best at this - but I am assuming you want the code that will open the door? Or do you just want the door name? Or the doorsource name, in order to make it open/close?

 

Here is an example of how I find doors in one of my scripts. I am sure there are better ways, you will have to adjust the scripts below to your needs.

 

This code below runs in a loop - constantly checking for doors in buildings, and then executing code once a door is found.

				private _SelectionNames = (selectionNames _building);
				{
					if (["door",_x] call BIS_fnc_inString) then
					{
						private _doorPos = _building selectionPosition _x;
						private _WorldPos = (_building modelToWorld _doorPos);
						if (player distance2d _WorldPos < 3) then
						{
							private _Door = [_x, "dDoor_0123456789"] call BIS_fnc_filterString;
							if !(missionNamespace getVariable [((str _Building)+_Door),false]) then
							{
								private _HandleObj = "#lightpoint" createVehicleLocal _WorldPos;
								_HandleObj setpos _WorldPos;								
								[_Building,_Door,_x,"Door",_HandleObj] spawn INT_fnc_DoorDraw;
							};
						};
					};
				} foreach _SelectionNames;

 

Code snippet from DoorDraw function:

This part adds the door, among other things, to an array and adds a displayhandler that will allow the player to open/close a door by using their scroll wheel. I am assuming the way to get the door sourcename is what you are after? Look at the variables _Doorsource and _DoorNoSource.

private _DoorArray = [_Building,_Door,_HandleObj];	
INT_SelectedDoors pushback _DoorArray;
	_INT_SlowOpen = (findDisplay 46) displayAddEventHandler 
	["MouseZchanged",
		{
			params ["_displayorcontrol", "_scroll"];
			{
				_x params ["_Building","_Door","_HandleObj"];
				if ([player, _HandleObj, 0] call BIS_fnc_isInFrontOf) then
				{				
					private _DoorSource = format ["%1_sound_source", _Door];
					private _DoorNoSource = format ["%1_nosound_source", _Door];
					private _p = _Building animationSourcePhase _DoorSource;
					if (_scroll > 0) then {_p = _p + 0.4} else {_p = _p - 0.4};
					if (_p > 1) then {_p = 1};
					if (_p < 0) then {_p = 0};
					_Building animateSource [_DoorSource, _p];
					_Building animateSource [_DoorNoSource, _p];	
				};
			} foreach INT_SelectedDoors;				
		}
	];

 

 

 

  • Like 2

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

×