Frictional Games Forum (read-only)

Full Version: Help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I was told to post my problem on this forum. So, I'm making a custom story (i'm a little new to this), and I'm trying to set up a key with a door. I have the key and door named and i have the correct coding for them to work together. I also have the latest version of amnesia, and notepad++. But whenever i save the script, and boot up the custom story, I can't use the key with the door. Please help
When you say you can't use the key, does the game just say "No object to use this item on" or similar? Then that means you need to add an AddUseItemCallback() for your key in OnStart(). Recheck the names of your door, key, and your .hps script file so that it matches your map name.

You can also post your script here for us to look at.
It says "cannot use this item this way" or something like that. Here's the script:
[Image: fhwRuq9.png]
(02-24-2017, 12:54 AM)MindScope Wrote: [ -> ]It says "cannot use this item this way" or something like that. Here's the script:
[Image: fhwRuq9.png]

try this. it may work


void OnStart()
{

AddUseItemCallback("", "Key", "Door/", "Unlock", true);

}


void Unlock(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);

PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false);

RemoveItem(asItem);
}


if it does not work someone else can correct the issue. Smile hopefully this helped you.
If it says "Cannot Use Item This Way", it usually means the names of your Key or your Door are wrong in the Level Editor.

Make sure that the "Key" in your script is the same name as the key in the Level Editor. It could be something like "key_study_1" and not just key. The same with the door, since the door may be something completely different like "mansion_2".

----------

The code above doesn't change much. It only plays a sound at the door and removes the item from the inventory. If the names referenced in the code as they do in the Level Editor do not match, then the above code won't change anything.
(02-24-2017, 09:25 AM)Romulator Wrote: [ -> ]If it says "Cannot Use Item This Way", it usually means the names of your Key or your Door are wrong in the Level Editor.

Make sure that the "Key" in your script is the same name as the key in the Level Editor. It could be something like "key_study_1" and not just key. The same with the door, since the door may be something completely different like "mansion_2".

----------

The code above doesn't change much. It only plays a sound at the door and removes the item from the inventory. If the names referenced in the code as they do in the Level Editor do not match, then the above code won't change anything.

ik i just thought i would be nice and try to help. i was going to say the same thing you did but i thought it would be better for someone else to do that
Another thing that COULD be the issue is that the .hps file and the .map file are not named the same.
Make sure that your .map file is named "Level1.map" since that's what you've called your .hps file.
(02-24-2017, 10:58 AM)FlawlessHappiness Wrote: [ -> ]Another thing that COULD be the issue is that the .hps file and the .map file are not named the same.
Make sure that your .map file is named "Level1.map" since that's what you've called your .hps file.

Thanks that worked!

Also thanks to everyone who tried to help Big Grin