Frictional Games Forum (read-only)
Getting a door to open using scripts - 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: Getting a door to open using scripts (/thread-18439.html)



Getting a door to open using scripts - go.go - 09-21-2012

I've had this problem for a while now and no matter what I do I can't seem to solve it. I've looked at this: http://www.youtube.com/watch?v=VSZ_uWz-PeM&list=PLD326789BC99530C8&index=16 and it still won't work.

Basically, what I want to do is get a door to open when a player enters a script area. The way I understand it there are two ways to do this, either by using SetSwingDoorClosed to False and True, or by using the AddPropForce. The problem is that I am probably doing something wrong because neither of these are working for me.

The doors name is "1_mansion", the script area is "area_opendoor1", here is the code I have for opening it slowly like in the youtube video:

Code:
void OnStart()
{
    AddEntityCollideCallback("Player", "area_opendoor1", "opendoor1", true, 1);
}
void opendoor1(string &in item)
{
    SetSwingDoorDisableAutoClose("1_mansion", true);
    SetSwingDoorClosed("1_mansion", false, false);
        for (int i = 0; i < 10; i++)
    {
        AddTimer("1_mansion", i * 0.1, "OpenDoorSlightly");
    }

    }
void OpenDoorSlightly(string &in door_name)
{
    AddPropForce(door_name, 1000, 1000, 1000, "world");
}


Nothing at all happens when I use this code. No errors, but also no effects. Even when I tried putting "SetSwingDoorDisableAutoClose("1_mansion", true);" directly in OnStart, the door would still auto close itself when almost closed.

I've also tried using just SetSwingDoorClosed("1_mansion", false, false); with false, false and false, true. Still won't work. I really have no idea what the problem is. Would really appreciate some help here!


RE: Getting a door to open using scripts - i3670 - 09-21-2012

Have you tried changing the values in the AddPropForce?


RE: Getting a door to open using scripts - Akos115 - 09-21-2012

I also have the same problem with the doors... :/


RE: Getting a door to open using scripts - go.go - 09-21-2012

(09-21-2012, 03:03 PM)i3670 Wrote: Have you tried changing the values in the AddPropForce?
Yes, I've tried using everything from 1 to 2000 in each direction. I think something else is the problem though since the door still auto closes after entering the script area.


RE: Getting a door to open using scripts - Robby - 09-21-2012

Are you sure you entered the door's name correctly, and it isn't like in the script you mentioned in the first post?

Like "MoveDoor" is the door's name (with the quotes too).


RE: Getting a door to open using scripts - go.go - 09-21-2012

(09-21-2012, 03:15 PM)Nemet Robert Wrote: Are you sure you entered the door's name correctly, and it isn't like in the script you mentioned in the first post?

Like "MoveDoor" is the door's name (with the quotes too).
The doors name is definitely "1_mansion" (without the quotes). I have double checked the names a lot of times and even copy pasted them from the level editor to the script file.


RE: Getting a door to open using scripts - The chaser - 09-21-2012

The syntax was incorrect. This should work:

void OnStart()

{

AddEntityCollideCallback("Player", "area_opendoor1", "opendoor1", true, 1);

}

void opendoor1(string &in asParent, string &in asChild, int alState)

{

SetSwingDoorDisableAutoClose("1_mansion", true);

SetSwingDoorClosed("1_mansion", false, false);

for (int i = 0; i < 10; i++)

{

AddTimer("1_mansion", i * 0.1, "OpenDoorSlightly");

}



}

void OpenDoorSlightly(string &in door_name)

{

AddPropForce(door_name, 1000, 1000, 1000, "world");

}


But, why you use force in every coordinate? Just put force in the X axis or in the Z axis and if it doesn't work, go trying.
this is a tutorial that you may like:

http://wiki.frictionalgames.com/hpl2/tutorials/script/pushdoorsopen (opening doors with force)
http://wiki.frictionalgames.com/hpl2/tutorials/script/events (slam)

Also, why do you use a "for"?


RE: Getting a door to open using scripts - go.go - 09-21-2012

Thanks Chaser! That script worked perfectly when I changed the force around a bit. I used force in every coordinate because I wasn't getting any effect from any of them, so I just figured I would put a high number in each to see what would happen, but nothing happened at all. Now it works fine though!

I actually don't know why I use a "for", I just followed what the guy in the tutorial did. There are still a few things I haven't learned yet in scripting, one of them being "for" so I do not know why it is there.


RE: Getting a door to open using scripts - The chaser - 09-21-2012

Maybe that is something more complicated. I know the basics and I work with "If", but the "For" scripts seem very complicated to me.
Also, if you read the tutorials in the wiki you will progress faster:

http://wiki.frictionalgames.com/hpl2/tutorials/

There's an explanation of the "for" loops, but I never understood them.