Frictional Games Forum (read-only)
[SOLVED]Need Help With A Sliding Door - 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: [SOLVED]Need Help With A Sliding Door (/thread-25308.html)



[SOLVED]Need Help With A Sliding Door - Viper85626 - 05-17-2014

Hey guys! I don't really post on these forums, but I do lurk on them a lot and have been learning a lot! I would consider myself an intermediate scripter. I'm not new to using HPL2, but there are some things I've never tried before. One of those things are sliding doors!

Now, my question is, how would I make a sliding door slide open and closed at the press of a button? I've tried using ConnectionStateChangeCallback in the level editor, but it doesn't work. I thought it would be almost the same since I used that same thing to turn lights on and off.

Anybody have any ideas on how to do this? Thanks in advance!


RE: Need Help With A Sliding Door - PutraenusAlivius - 05-17-2014

What was the entity? MultiSlider probably works.


RE: Need Help With A Sliding Door - Viper85626 - 05-17-2014

It was the "safety_normal_vert_1." It works with wheels and valves, but I want to just use a button. What's the MultiSlider? I've never heard of that one before. Or maybe I have, but that name doesn't ring any bells.

Edit: I looked around the Engine Functions page and found the MultiSlider function. I tried it out using a button that relies on alStates, but the door doesn't do anything.


RE: Need Help With A Sliding Door - PutraenusAlivius - 05-17-2014

Use:
PHP Code:
void SetMoveObjectState(stringasNamefloat afState); 

Script:
Spoiler below!

PHP Code:
void OnStart()
{
SetEntityPlayerInteractCallback("button""MoveTheDoor"false); //Change false to true if you want the door to open/close once
}

void MoveTheDoor(string &in asEntity)
{
SetMoveObjectState("safety_normal_vert_1"1); //Change the "1" in the second argument since I don't know which state is open or closed





RE: Need Help With A Sliding Door - Viper85626 - 05-17-2014

I tried this, but it didn't do anything, unfortunately.

I did basically the same thing, but I put my function in the PlayerInteractCallback dialog box in the Level Editor. Then I added your MoveTheDoor function in the script. It looks like this:
PHP Code:
void SlideDoor(string &asEntity)
{
    
SetMoveObjectState("safety_normal_vert_1"1);


I feel like the solution is probably to use the ConnectionStateChangeCallback on the button. I'll try it out with the SetMoveObjectState function and let you know what happens.

EDIT:
So I tried doing this:
PHP Code:
void SlideDoor(string &asEntityint alState)
{
    if (
alState == 1)
    {
        
SetMoveObjectState("safety_normal_vert_1"1);
    }
    else if (
alState == 0)
    {
        
SetMoveObjectState("safety_normal_vert_1", -1);
    }


The door just sits there. Sad I'm getting the impression that this door only works with levers...

EDIT 2:
I'm such an idiot. I realized what was wrong. I used the above code correctly, but I forgot that I changed the door from "safety_normal_vert_1" to "safety_normal_vert_noauto_1" to prevent it from automatically closing itself.

Well, it all works now. Thanks a lot man! +rep Smile