Frictional Games Forum (read-only)
Locked Door and Key Issue - 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: Locked Door and Key Issue (/thread-5829.html)



Locked Door and Key Issue - Nitrowing - 12-22-2010

I've browsed through the various tutorials and searched through these forums for a solution to my Key>Door related issues and failed to find anything that helps, so here goes. It's probably some stupid error but, I need a push in the right direction.

Code:
void UseKey("Hotel Room Key, "Hotel Room Door"){
    // Set the entity(desk or door) to unlocked
    SetSwingDoorLocked("Hotel Room Door", false, true);

    // Remove the item used from the inventory
    RemoveItem(Hotel Room Key);
    PlaySoundAtEntity("", "unlock_door.snt", "Hotel Room Door",0.0f, true);
    AddDebugMessage("The Door has successfully opened. Congratulations!", false);
    }


////////////////////////////
// Run first time starting map
  void OnStart()
     {
          if(ScriptDebugOn())
          {
               GiveItemFromFile("lantern", "lantern.ent");
               SetPlayerLampOil(100.0f);

               for(int i = 0;i < 10;i++)
               {
                    GiveItemFromFile("tinderbox", "tinderbox.ent");
               }
          }
     }


////////////////////////////
// Run when entering map
void OnEnter()
{

}

////////////////////////////
// Run when leaving map
void OnLeave()
{
}
}
Any help would be appreciated.


RE: Locked Door and Key Issue - ThePaSch - 12-22-2010

Yup, you missed quite a few ""s there.
Code:
void UseKey("Hotel Room Key", "Hotel Room Door"){
    // Set the entity(desk or door) to unlocked
    SetSwingDoorLocked("Hotel Room Door", false, true);

    // Remove the item used from the inventory
    RemoveItem("Hotel Room Key");
    PlaySoundAtEntity("", "unlock_door.snt", "Hotel Room Door",0.0f, true);
    AddDebugMessage("The Door has successfully opened. Congratulations!", false);
    }



RE: Locked Door and Key Issue - Nitrowing - 12-22-2010

Fatal Error: Could not load script.
Main (1, 13) : ERR: Expected Data Type
Main (40, 1) : ERR: Unexpected token '}'

OK so I fixed the second error by removing the } at the last line. The (1, 13) one I'm not so sure about.
I'd assume it wants something added/changed to this line:
Code:
void UseKey("Hotel Room Key", "Hotel Room Door"){

Resolved the issue by browsing some more. Scrapped the old stuff and threw this at the end of the basic one.
Code:
////////////////////////////
// Actual functions

void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Hotel Room Door", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "Hotel Room Door", 0.0f, false);
RemoveItem("Hotel Room Key");
AddDebugMessage("The Door has successfully opened. Congratulations!", false);
}
And this at the onEnter part:
Code:
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "Hotel Room Key", "Hotel Room Door", "KeyOnDoor", true);
}