Frictional Games Forum (read-only)

Full Version: Can't get door to lock using SetSwingDoorLocked("mansion_1", false, true)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've tried everything to get this stupid door to lock and then open with a key, but I just can't.

Here's my exact script:
void OnStart()
{
AddUseItemCallback("", "awesomekey_1", "mansion_1", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false);
RemoveItem("awesomekey_1");
}

I renamed the key awesomekey_1. I followed MulleDK19's video tutorial (http://hpl2.frictionalgames.com/tutorials) TO THE LETTER, and I still can't get the door to lock. What am I doing wrong?

I searched the forums and couldn't find a solution, even on the "Recollecting Scripts" thread the locking door post there didn't work. And yes, my door is named mansion_1.
SetSwingDoorLocked("mansion_1", true, true);
(10-21-2010, 08:41 PM)Pandemoneus Wrote: [ -> ]SetSwingDoorLocked("mansion_1", true, true);

Didn't work.
Err.. misunderstood your script.

Go to the level editor, select the door, press the second tab and check 'locked'.
(10-21-2010, 09:00 PM)Pandemoneus Wrote: [ -> ]Err.. misunderstood your script.

Go to the level editor, select the door, press the second tab and check 'locked'.

That got the door to lock but the key won't open it...
I tried it too and it didn't work the way he did it, but I got it to work this way...
Code:
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
  SetSwingDoorLocked(asEntity, false, true);
  PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
  RemoveItem(asItem);
}
since asEntity is the entity we used the item on and the asItem, obviously, is the item.
This way you can make a global method to unlock doors, no need to make functions for every door you have to unlock.
You should Add: AddDebugMessage("Type anything you want here", false);

What this does, it says something at the very bottom very left. It says the thing you typed in the AddDebugMessage. Its useful to see if its even doing anything. You need to have the Debug Messages activated. Activate it here: C:\Documents and Settings\"YOUR COMPUTER USER NAME\My Documents\Amnesia\Main\"YOUR AMNESIA PROFILE NAME"\user_settings.cfg
Open it with your favorite text editing program. I recommend Notepad++. But you can still use the Notepad thing. If you don't want to get Notepad++ or don't have it, right click the file, Click Open With, select Notepad, Uncheck 'Always use the selected program to open this kind of file' If you don't uncheck it. It will mess up .cfg's FOREVER! So uncheck it. Press OK. It will open the file. Find:
ShowDebugMessages="false" Make: "false" to "true". It will show the debug messages. There are other useful and useless stuff to set true and false in the file if you want. You can always go back in the file and change it.

Add the Debug Message Code like this in the void UsedKeyOnDoor:

Code:
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false);
RemoveItem("awesomekey_1");
AddDebugMessage("Type anything you want here", false);
}

This won't solve fixing the key not opening the door. This is just something to see if its even doing anything.
First you need to go into the editor and click on the door and set "locked",
then you need to replace you scripting part where you have "UsedKeyOnDoor" and write the name of you key.. So it sould look like this..


void OnStart()
{
AddUseItemCallback("", "awesomekey_1", "mansion_1", "Usedawsomekey_1", true);
}

void Usedawsomekey_1(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false);
RemoveItem("awesomekey_1");
}



Hope it helped Smile
does your .hps file have two .hps's?

ex-
mymap.hps.hps or mymap.hps
HPS FILE

remove the first .hps in the name.


USE NOTEPAD++