Frictional Games Forum (read-only)
Unlock door when timer is run out - 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 (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Unlock door when timer is run out (/thread-8276.html)

Pages: 1 2


Unlock door when timer is run out - dasde - 05-27-2011

Hello

I am sitting with a script, and I cant really figure out how to set up a script that unlocks a swingdoor after the timer "Door" has ran out.


I would like to know how I do this.


Thank you


RE: Unlock door when timer is run out - Greven - 05-27-2011

Well then you just
Code:
void door(string &in asTimer)
{
SetSwingDoorLocked("the doors name", false, true)
}
I dont remember what the "true" did but you can just try and see for yourself if its supposed to be true or false.


RE: Unlock door when timer is run out - xtron - 05-27-2011

Code:
void door(string &in asTimer)
{
AddTimer("", 60.0f, "Door_timer");
}


void Door_timer(string &in asTimer)
{
SetSwingDoorLocked("DOORNAME", false, true);
}

After 60seconds the function "Door_timer" will activate and unlock the door "DOORNAME". Correct me if I'm wrong 'cuz I'm new to scripting ;D


RE: Unlock door when timer is run out - dasde - 05-27-2011

Niether of the two scripts work


RE: Unlock door when timer is run out - Greven - 05-27-2011

(05-27-2011, 02:51 PM)dasde Wrote: Niether of the two scripts work

Can we see youre script then? And what is the name of the door in youre level editor?


RE: Unlock door when timer is run out - dasde - 05-27-2011

Thanks for the fast replies, very nice.

The door name is:

BruteDoor_1


There is nothing in the script yet, I am starting with the timer. I have the OnStart, OnEnter and OnLeave, all the starter stuff.


RE: Unlock door when timer is run out - Greven - 05-27-2011

(05-27-2011, 02:54 PM)dasde Wrote: Thanks for the fast replies, very nice.

The door name is:

BruteDoor_1


There is nothing in the script yet, I am starting with the timer. I have the OnStart, OnEnter and OnLeave, all the starter stuff.

Ok so is the timer for the beginning or when you enter a area?

If its in the beginning (on enter) then:
Code:
OnEnter()
{
AddTimer("", 30.0f, DoorOpen)
}

void DoorOpen(string &in asTimer)
{
SetSwingDoorLocked("BruteDoor_1", false, true)
}



RE: Unlock door when timer is run out - dasde - 05-27-2011

(05-27-2011, 03:00 PM)Greven Wrote:
(05-27-2011, 02:54 PM)dasde Wrote: Thanks for the fast replies, very nice.

The door name is:

BruteDoor_1


There is nothing in the script yet, I am starting with the timer. I have the OnStart, OnEnter and OnLeave, all the starter stuff.

Ok so is the timer for the beginning or when you enter a area?

If its in the beginning (on enter) then:
Code:
OnEnter()
{
AddTimer("", 30.0f, DoorOpen)
}

void DoorOpen(string &in asTimer)
{
SetSwingDoorLocked("BruteDoor_1", false, true)
}

Didnt work. If you can use this information, then the door is locked in the editor.



RE: Unlock door when timer is run out - Henriksen - 05-27-2011

Then you are doing something wrong send us the WHOLE script and let us see?


RE: Unlock door when timer is run out - dasde - 05-27-2011

(05-27-2011, 03:08 PM)teddifisk Wrote: Then you are doing something wrong send us the WHOLE script and let us see?

Well if you absolutely want it, then here it is:
Code:
//===========================================
     // Starter's Script File!
     //===========================================

     //===========================================
     // This runs when the map first starts
     void OnStart()
     {
        AddUseItemCallback("UseKeyOnDoor", "key_tomb_rusty_2", "level_wood_1", "UseKeyOnDoor", true);
     }
    
        
    



     //===========================================
     // This runs when the player enters the map
     void OnEnter()
     {
     AddTimer("", 52.0f, "Door_Timer");
     }

     //===========================================
     // This runs when the player leaves the map
     void OnLeave()
     {
     }
    
    
     //===========================================
    
/////////////////////////////////
//LAST DOOR//
void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
    PlaySoundAtEntity("unlocked", "unlock_door", asEntity, 0.0f, false);
    
    GiveSanityBoostSmall();
    
    SetLevelDoorLocked(asEntity, false);
    RemoveItem(asItem);
    
    CompleteQuest("02LockedDoosr", "02LockedDoor");

    
}
//LAST DOOR//
///////////////////////////////


///////////////////////////////
// START SWING DOOR

void Door_timer(string &in asTimer)
{
SetSwingDoorLocked("BruteDoor_1", false, true);
}



For the record, LAST DOOR is a door that leads to another map, but the code is taken from another script. LevelDoors is oddly easier to work with.