Frictional Games Forum (read-only)
[SCRIPT] Help with door script - 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: [SCRIPT] Help with door script (/thread-12677.html)



Help with door script - CrushedRaiD - 01-17-2012

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



RE: Help with door script - SilentStriker - 01-17-2012

Do you want to door locked? Smile



RE: Help with door script - Juby - 01-17-2012

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.


RE: Help with door script - Shadowfied - 01-17-2012

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.



RE: Help with door script - Tripication - 01-18-2012

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)


RE: Help with door script - Juby - 01-18-2012

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




RE: Help with door script - CrushedRaiD - 01-18-2012

(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