Frictional Games Forum (read-only)

Full Version: Help with door script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
Do you want to door locked? Smile
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.
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.
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)
(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.

(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