Jump to content
Sign in to follow this  
kresjah

Can't find door with selectionPosition

Recommended Posts

Long story short, I'd like to get the position for the trigger of the airport entryway doors. The config files for the airport states the following:

configfile >> "CfgVehicles" >> "Land_Airport_right_F" >> "UserActions" >> "OpenDoor_7" >> position = "Door_7_trigger";

So, I want to get the position of this door trigger. I've tried using selectionPosition but always get a [0, 0, 0] result (which means it didn't find the memory point). Am I doing something wrong here? Does anyone have a solution for this?

 

 

This is the code I use to check for the position:

 

* Player object's Init field

player addAction ["<t color='#FFFF00'>DEBUG: </t><t>Show memory point 7 on Airport</t>", { execVM "getMemoryPointDoor.sqf"; }, nil, 9999, false, true, "", ""];

* getMemoryPointDoor.sqf

private["_airport", "_memoryPoint"];

// Find nearest Airport object within a 100m radius of player

_airport = (nearestObjects [player, ["Land_Airport_left_F", "Land_Airport_right_F"], 100]) select 0;

if (isnil "_airport") exitwith { hint "No airport object found."; };

// Studying Land_Airport_*_F and its respective configs you'll find that the UserActions for the double sliding door entryways has trigger positions named Door_7_trigger and Door_8_trigger.
// I'd assume these refer to memory points on the model? I can find no indication in the config viewer of these points being defined somewhere in the config class for the set pieces.

// For this example, I've chosen to use Door_7_trigger.
_memoryPoint = _airport selectionPosition ["Door_7_trigger"];

if (_memoryPoint isEqualTo [0, 0, 0]) exitwith { hint "Airport object found, but failed to retrieve memory point position."; };

hint format["Position of memory point: %1", _memoryPoint];

Share this post


Link to post
Share on other sites

On DEV you can already use animationSelectionNames command for that. Config names are not always accurate. Here are the names returned by the command:

"door_7a"

"door_7b"

Share this post


Link to post
Share on other sites

EDIT: Apparently it was a matter of me coding when I was obviously too tired or something like that. Used the wrong syntax for selectionPosition... either you use it straight with a string, or you use an array with two arguments. I used an array with a single argument for some absurd reason. Making it just a string fixed the problem... so, in the end it should have been like this:

// ...
_memoryPoint = _airport selectionPosition "Door_7_trigger";
// ...

------------

 

Thanks for your answer! It's not entirely what I'm looking for though. Perhaps it'll become a bit clearer if I add a few more details as of what I'm trying to do.

 

Currently I'm working on a script to simulate automatically opening/closing doors. I know other people have made scripts for this already, but both for the sake of learning and for tailoring it to my specific needs I am trying to create my own from scratch. Getting the actual opening and closing of the doors to work is no problem, that part works like a charm. However, right now I'm using a preplaced map trigger to get it going. When the player enters the trigger, both of the doors open. Being somewhat nitpicky and a perfectionist I want to programatically find a location to generate the trigger from a script. At least this way you won't have to place a trigger for each and every set of such doors in a building, and when using it on multiple buildings of the same class the trigger will always be in the same (relative) place. It should also future proof it better so that I don't have to edit a ton of triggers manually if I at some point change the params the script uses. I see two potential solutions:

 

  1. Extrapolate the data by finding the center point between the two doors (or something like that). Pseudocode:
    _difference = getPos "Door_B" - getPos "Door_A";
    _centerpoint = getPos "Door_A" + (_difference / 2);
  2. Considering the config for the building open both doors in one fell swoop with a single UserAction whose position is defined as "Door_7_trigger" instead of a location array, I figured it had to be defined somewhere and was hoping to simply fetch that position. I first started looking for it in the config, but to no avail. As it was not there, I thought as such that it would instead be a memory point on the model, and that I could thus fetch it with selectionPosition... which leads me to where I am now. Am I wrong in thinking that it is a memory point location on the model? If not, where is it? Is it at all possible to fetch that location programatically?

 

Sure, the first solution should work and I'll fall back on that one if necessary, but I by far prefer the second one.

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  

×