Frictional Games Forum (read-only)

Full Version: Any function for getting if a cabinet's closed?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hellooo everyone Smile In the level I'm working on I need to make it so that if the player gets inside a cabinet and closes the door a function is called. However, GetSwingDoorClosed won't work for it and neither will the method usually used for pulling levers. I couldn't find the answer anywhere else so it'd be awesome if someone knows here Tongue If all else fails I'll use a collide callback with the cabinet's doors but I'd rather do something a bit less messy. Undecided
I just tested this with this script:

Code:
void OnStart() {

    SetEntityPlayerInteractCallback("cabinet_nice_1", "Cabinet", false);

}

void Cabinet(string &in asEntity) {

    if(GetSwingDoorState("cabinet_nice_1") == -1) {
    AddDebugMessage("CLOSED", false);
    }
    
    if(GetSwingDoorState("cabinet_nice_1") == 1) {
    AddDebugMessage("OPEN", false);
    }
    
}

I'm not really sure about this myself. But it seemed to work to an extent. I got both debug messages to appear when the cabinet was respectively open/closed. It also seems to work only when both is closed, the "CLOSED" message stopped appearing when I left one side open.
Script area callbacks might be your best choice. Since the GetSwingDoorState function returns an integer, there's no accounting for intermediate values. That is to say: Even if your door is open halfway, it still might be considered "closed".
Okay, thanks guise ^_^
You could make it with Collision Areas Smile?