Frictional Games Forum (read-only)
[SCRIPT] Any function for getting if a cabinet's closed? - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] Any function for getting if a cabinet's closed? (/thread-14026.html)



Any function for getting if a cabinet's closed? - Mooserider - 03-16-2012

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


RE: Any function for getting if a cabinet's closed? - Equil - 03-16-2012

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.



RE: Any function for getting if a cabinet's closed? - palistov - 03-16-2012

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".


RE: Any function for getting if a cabinet's closed? - Mooserider - 03-17-2012

Okay, thanks guise ^_^


RE: Any function for getting if a cabinet's closed? - Stepper321 - 03-17-2012

You could make it with Collision Areas Smile?