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
Script Help Help with door script
CrushedRaiD Offline
Member

Posts: 115
Threads: 10
Joined: Dec 2010
Reputation: 0
#1
Help with door script

I need help with a script that would shut the door behind me and deactivate all the candles along the corridor...Huh Sorry im still learning how to script Smile
01-17-2012, 08:38 PM
Find
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
#2
RE: Help with door script

Do you want to door locked? Smile

(This post was last modified: 01-17-2012, 08:43 PM by SilentStriker.)
01-17-2012, 08:43 PM
Find
Juby Away
Senior Member

Posts: 290
Threads: 2
Joined: May 2011
Reputation: 5
#3
RE: Help with door script

We all go through that learning process, one day it will click to you and become easy.

Okay, make an script area (a.k.a the 3-D cube on the left toolbar or hotkey 8). Basically, when you touch this area, the event will play, but to do that you need to first name your area whatever you feel like, I'll just name it Cupcakes for now, then add this to your .hps file in the OnStart function:

AddEntityCollideCallback("Player", "Cupcakes", "CupcakeEvent", true, 1);

Then add this outside of the OnStart:


void CupcakeEvent(string &in asParent, string &in asChild, int alState)
{
AddPropImpulse("DOORNAME", 0, 0, 0, "world");
for(int x = 1; x <= 5; x++) SetLampLit("LightName_"+x, false, false);
}

You're going to need to edit these if you want them to work. For the impulse command, the three zeros are actually the coordinates X, Y, Z in that order to "impulse" the prop (the door). First, find what direction you need to push your door, in the editor, the red line is X, the green is Y, and the blue is Z. Change one of the zeros to 100 to push the door that certain way. Also change "DOORNAME" to the name of the door you want to close Wink

The second line there will turn off all the candles from the names "LightName_1" to "LightName_5". x <= 5 determines this, change that to x <= 8 if you need to turn of 8 lights, etc..

I hope I explained that well enough.

Insanity. Static.
(This post was last modified: 01-17-2012, 09:00 PM by Juby.)
01-17-2012, 08:56 PM
Find
Shadowfied Offline
Senior Member

Posts: 261
Threads: 34
Joined: Jul 2010
Reputation: 5
#4
RE: Help with door script

Thanks Juby for the part with the lamplit stuff. Now I don't have to have a single line for my 20 lights in my story.

Current - Castle Darkuan
Other - F*cked Map
01-17-2012, 10:04 PM
Find
Tripication Offline
Member

Posts: 172
Threads: 19
Joined: Dec 2011
Reputation: 6
#5
RE: Help with door script

Wouldnt you use this

void CupcakeEvent(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("DOORNAME", true, true);
for(int x = 1; x <= 5; x++) SetLampLit("LightName_"+x, false, false);
}



Should only need to edit the door name and the lamplit stuff(if you need to edit the lamplit at all, i dont know enough about that so owell)

[Image: speedart__2___yoshimitsu_by_kamofudge-d4yo6kk.png]
(This post was last modified: 01-18-2012, 04:09 AM by Tripication.)
01-18-2012, 04:08 AM
Find
Juby Away
Senior Member

Posts: 290
Threads: 2
Joined: May 2011
Reputation: 5
#6
RE: Help with door script

(01-18-2012, 04:08 AM)Tripication Wrote: Wouldnt you use this

void CupcakeEvent(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("DOORNAME", true, true);
for(int x = 1; x <= 5; x++) SetLampLit("LightName_"+x, false, false);
}

Yeah, that works too.


Insanity. Static.
01-18-2012, 04:49 AM
Find
CrushedRaiD Offline
Member

Posts: 115
Threads: 10
Joined: Dec 2010
Reputation: 0
#7
RE: Help with door script

(01-17-2012, 08:43 PM)SilentStriker Wrote: Do you want to door locked? Smile
Yes, and later i need to open it with a key Big Grin
(01-17-2012, 08:56 PM)Juby Wrote: We all go through that learning process, one day it will click to you and become easy.

Okay, make an script area (a.k.a the 3-D cube on the left toolbar or hotkey 8). Basically, when you touch this area, the event will play, but to do that you need to first name your area whatever you feel like, I'll just name it Cupcakes for now, then add this to your .hps file in the OnStart function:

AddEntityCollideCallback("Player", "Cupcakes", "CupcakeEvent", true, 1);

Then add this outside of the OnStart:


void CupcakeEvent(string &in asParent, string &in asChild, int alState)
{
AddPropImpulse("DOORNAME", 0, 0, 0, "world");
for(int x = 1; x <= 5; x++) SetLampLit("LightName_"+x, false, false);
}

You're going to need to edit these if you want them to work. For the impulse command, the three zeros are actually the coordinates X, Y, Z in that order to "impulse" the prop (the door). First, find what direction you need to push your door, in the editor, the red line is X, the green is Y, and the blue is Z. Change one of the zeros to 100 to push the door that certain way. Also change "DOORNAME" to the name of the door you want to close Wink

The second line there will turn off all the candles from the names "LightName_1" to "LightName_5". x <= 5 determines this, change that to x <= 8 if you need to turn of 8 lights, etc..

I hope I explained that well enough.
Thx Smile I really want to learn but i think that i wont be scripting as well as others in many years Big GrinDD
(This post was last modified: 01-18-2012, 12:57 PM by CrushedRaiD.)
01-18-2012, 12:55 PM
Find




Users browsing this thread: 1 Guest(s)