Using a Timer to Unlock a Door - 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: Using a Timer to Unlock a Door (/thread-21423.html) Pages:
1
2
|
Using a Timer to Unlock a Door - AGP - 05-06-2013 All right, I've been searching around for a code to unlock a door after a certain amount of time, but not really found what I was looking for. Any ideas? RE: Using a Timer to Unlock a Door - Tomato Cat - 05-06-2013 First, you would need something to trigger the timer. Collide, useitem, etc etc. When the timer expires, its callback would call the SetSwingDoorLocked function. Also, I would visit the wiki. It has documentation for each function. RE: Using a Timer to Unlock a Door - AGP - 05-06-2013 Sounds good, but still very confused with the script for the timer. This is what the wiki says, but no idea what it means. Still pretty new to scripting. Code: void AddTimer(string& asName, float afTime, string& asFunction); RE: Using a Timer to Unlock a Door - Tomato Cat - 05-06-2013 asName, afTime, and asFunction are known as arguments. asName is the name of your timer. Basically a string. It isn't required (unless you wish to use stop timer), but I recommend it as it can help you keep track of multiple timers. afTime is, well, the time. "Float" is basically a decimal number. As an example, 1.5f will create a timer that runs for 1.5 seconds. asFunction is the callback. This is the function that will be called when your timer expires. asTimer is the parameter for the callback function. Here's an example. PHP Code: void Function()//Parameters would go here, depending on what called this function RE: Using a Timer to Unlock a Door - AGP - 05-06-2013 Okay, so the player hits a script area named "timer_area" and then after 42 seconds, the door named "hall_door" would unlock. The door is already set to locked in the editor. This script probably looks like the world's biggest mess.... Code: In OnStart() RE: Using a Timer to Unlock a Door - Tomato Cat - 05-06-2013 Looks good, but you're missing the parameters for OpenDoor. Same kind of deal with the timer. Except the entitycollide has a different callback syntax: PHP Code: void Function(string &in asParent, string &in asChild, int alState) RE: Using a Timer to Unlock a Door - AGP - 05-06-2013 Now getting a error saying " f is not declared". RE: Using a Timer to Unlock a Door - Tomato Cat - 05-06-2013 Try changing it to 42.0f? Oh, and is "In" in your .hps file? PHP Code: In OnStart() RE: Using a Timer to Unlock a Door - AGP - 05-06-2013 Error is gone. Yippee, but the door is not opening. =/ Code: void OpenDoor(string &in asParent, string &in asChild, int alState) RE: Using a Timer to Unlock a Door - Tomato Cat - 05-06-2013 Try SetSwingDoorLocked. |