Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting a door to open using scripts
go.go Offline
Junior Member

Posts: 11
Threads: 2
Joined: Jun 2012
Reputation: 0
#1
Getting a door to open using scripts

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-P...8&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:

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!
09-21-2012, 02:54 PM
Find
i3670 Offline
Posting Freak

Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation: 36
#2
RE: Getting a door to open using scripts

Have you tried changing the values in the AddPropForce?

"What you think is irrelevant" - A character of our time

A Christmas Hunt
09-21-2012, 03:03 PM
Find
Akos115 Offline
Member

Posts: 101
Threads: 14
Joined: Aug 2012
Reputation: 0
#3
RE: Getting a door to open using scripts

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

09-21-2012, 03:05 PM
Find
go.go Offline
Junior Member

Posts: 11
Threads: 2
Joined: Jun 2012
Reputation: 0
#4
RE: Getting a door to open using scripts

(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.
09-21-2012, 03:06 PM
Find
Robby Offline
Posting Freak

Posts: 2,549
Threads: 38
Joined: Jun 2009
Reputation: 47
#5
RE: Getting a door to open using scripts

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

Infrequently active. Don't expect an immediate response. Best to contact me at a different locale. If I create a thread, expect me to be quite active.
(This post was last modified: 09-21-2012, 03:15 PM by Robby.)
09-21-2012, 03:15 PM
Website Find
go.go Offline
Junior Member

Posts: 11
Threads: 2
Joined: Jun 2012
Reputation: 0
#6
RE: Getting a door to open using scripts

(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.
09-21-2012, 03:18 PM
Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#7
RE: Getting a door to open using scripts

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/tut...hdoorsopen (opening doors with force)
http://wiki.frictionalgames.com/hpl2/tut...ipt/events (slam)

Also, why do you use a "for"?

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
09-21-2012, 04:55 PM
Find
go.go Offline
Junior Member

Posts: 11
Threads: 2
Joined: Jun 2012
Reputation: 0
#8
RE: Getting a door to open using scripts

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.
09-21-2012, 05:15 PM
Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#9
RE: Getting a door to open using scripts

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.

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
09-21-2012, 05:29 PM
Find




Users browsing this thread: 1 Guest(s)