Frictional Games Forum (read-only)
Swing door message - 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: Swing door message (/thread-53606.html)



Swing door message - XeOnTricks - 03-01-2017

while creating my level i was thinking about adding a message to a locked swing door when you try to open it and it saing something along the lines of "this door requires a key"
how exactly do i do that?


RE: Swing door message - Mudbill - 03-01-2017

The SetMessage script is the one you want to use to display the message. Combine that with a player interact callback, and you should get the result you want.

First, set the callback in OnStart()
PHP Code:
SetEntityPlayerInteractCallback("Door""MyFuncName"false); 
Note: If you want this to happen only once, set the false to be true.

Next, set up the callback event:

PHP Code:
void MyFuncName(string &in asEntity)
{
    
SetMessage("MessageCategory""MessageEntry", -1.0f);


Here, the MessageCategory refers to a category in your extra_english.lang file. The MessageEntry refers to an entry within that category. The last float number determines how long it should last (but I've set it to auto).

Lastly you need your lang file to respect this. If you haven't worked much with your lang file, this may be a bit tricky, but you need to add the category and entry you specified.

PHP Code:
<CATEGORY Name="MessageCategory">
    <
Entry Name="MessageEntry">This door requires a key</Entry>
</
CATEGORY



RE: Swing door message - XeOnTricks - 03-01-2017

(03-01-2017, 09:23 AM)Mudbill Wrote: The SetMessage script is the one you want to use to display the message. Combine that with a player interact callback, and you should get the result you want.

First, set the callback in OnStart()
PHP Code:
SetEntityPlayerInteractCallback("Door""MyFuncName"false); 
Note: If you want this to happen only once, set the false to be true.

Next, set up the callback event:

PHP Code:
void MyFuncName(string &in asEntity)
{
    
SetMessage("MessageCategory""MessageEntry", -1.0f);


Here, the MessageCategory refers to a category in your extra_english.lang file. The MessageEntry refers to an entry within that category. The last float number determines how long it should last (but I've set it to auto).

Lastly you need your lang file to respect this. If you haven't worked much with your lang file, this may be a bit tricky, but you need to add the category and entry you specified.

PHP Code:
<CATEGORY Name="MessageCategory">
    <
Entry Name="MessageEntry">This door requires a key</Entry>
</
CATEGORY

probably will sound stupid but what is the MessageCategory?


RE: Swing door message - FlawlessHappiness - 03-01-2017

MessageCategory is a category you create in the .lang file.
The name "MessageCategory" is not important. It could have been "MesCat" or something else.

But notice that in Mudbill's script

PHP Code:
SetMessage("MessageCategory""MessageEntry", -1.0f); 

He references the name MessageCategory because he called it the same in the .lang file.


RE: Swing door message - Traggey - 03-03-2017

Moving this thread to development support.