Frictional Games Forum (read-only)
Message on locked doors[SOLVED] - 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: Message on locked doors[SOLVED] (/thread-8043.html)



Message on locked doors[SOLVED] - Greven - 05-16-2011

Ok so i was just wondering how to script in both the .lang file and in the .hps file to get a text saying something like "this door is locked".

I have tried and tried but i cant get it to work... help!


RE: Message on locked doors - Acies - 05-16-2011

This is a ctrl-c, ctrl-v from my map script:

Spoiler below!

void OpenLevelDoor(string &in asItem, string &in asEntity)
{
CompleteQuest("Passage", "The_Passage");
SetLevelDoorLocked("level_wood_2", false);
PlayGuiSound("unlock_door.snt", 1.0f);
SetLocalVarInt("LevelLockedX", 1);
}

void LevelDoorLocked(string &in asEntity)
{
if(GetLocalVarInt("LevelLockedX")==0)
{
SetMessage("TheHall", "LevelLocked", 0);
PlaySoundAtEntity("", "locked_door.ogg", "level_wood_2", 0.0f, false);
return;
}
}

It displays the message when variable "LevelLockedX" is set to 0 (which it is by default).
When using a key on it however, that variable is set to 1. Thus interaction after unlocking will no longer display the message.

Note that this is for a leveldoor and not a swingdoor, so if you are using a swingdoor replace the "SetLevelDoorLocked("level_wood_2", false);" with the swingdoor command.


RE: Message on locked doors - Greven - 05-16-2011

uhm im not to familiar with the whole "if" things, can you simplify the whole procedure?


RE: Message on locked doors - Acies - 05-16-2011

Uhm, I could explain it better - or copy you OnStart() parts too. Right now I can't think of another way.

The "if" part says:
Spoiler below!

if(GetLocalVarInt("LevelLockedX")==0)
{
//Then do stuff
return;
}

if(GetLocalVarInt("LevelLockedX")==0)
The GetLocalVarInt is a command which checks a variable, VarInt meaning it's a number without decimals.
The "LevelLockedX" is the name, which I have made up (you can name it whatever you want.)
The "==0" part means equal to zero.

I am using this variable as a bool, 0 means true / 1 means false. Thus if the variable is equal to 0 the door is considered locked and if it is equal to 1 it is considered unlocked.

The "//Then do stuff" part is only done IF "LevelLockedX" = 0, otherwise nothing is done.

When using the key on the door the variable is set to 1 and therefore when you interact with the door, nothing is done.




RE: Message on locked doors - Russ Money - 05-16-2011

The longer way:
Code:
Void OnStart()
{
SetEntityPlayerInteractCallback(string& asName, string& asCallback, bool abRemoveOnInteraction);

//RemoveOnInteraction true, message once, false, message repeats each time you touch the door.
}

//Callback for message

void MyFunc(string &in entity)
{
SetMessage(string& asTextCategory, string& asTextEntry, float afTime);
}



RE: Message on locked doors - dragonlordsd - 05-17-2011

how is the message scripted in the english.lang file?