Frictional Games Forum (read-only)
[SCRIPT] Leveldoor Problem - 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: [SCRIPT] Leveldoor Problem (/thread-11330.html)

Pages: 1 2


Leveldoor Problem - Togglevolt - 11-13-2011

Hi!

I want my level door to be locked if you don't have a lantern in your inventory. But for some reason it doesn't work. If I don't have a lantern a message say "I need to find a Lantern". But I still teleports to the next map.

Help!

Here's my script:



void CheckLantern(string &in asEntity)
{
if(HasItem("lantern_1") == true)
SetLevelDoorLocked(asEntity, false);
else
SetLevelDoorLocked(asEntity, true);
SetMessage("Ch01Level01", "InteractLevelDoor", 0);
}


void OnEnter()
{
SetEntityPlayerInteractCallback("level_wood_1", "CheckLantern", true);
}


I have also placed the "CheckLantern" into Entity of the leveldoor, in the PlayerInteractCallback tab.


RE: Leveldoor Problem - Your Computer - 11-13-2011

Try this for your OnEnter function:

Code:
void OnEnter()
{
     CheckLantern("level_wood_1");
}



RE: Leveldoor Problem - Togglevolt - 11-13-2011

It works!

Only problem is, it shows the message when I start the map too. In the very beginning. "/
Any idea how to fix that?

I want it displayed only when I touch the door.


RE: Leveldoor Problem - Your Computer - 11-13-2011

(11-13-2011, 08:32 PM)Togglevolt Wrote: It works!

Only problem is, it shows the message when I start the map too. In the very beginning. "/
Any idea how to fix that?

I want it displayed only when I touch the door.

What kind of message are we talking about? If it's a locked message or focus message, then we can avoid using SetMessage. Otherwise, just place the SetMessage in a separate (interact) callback.


RE: Leveldoor Problem - Togglevolt - 11-13-2011

The SetMessage("Ch01Level01", "InteractLevelDoor", 0); = Maybe I should find a Lantern first.


It is displayed as wanted when I touch the door without a Lantern. But it is also displayed at the very
beginning. I have a "wake up" intro, so it makes no sence having a message telling you to find a
Lantern first when your waking up.


RE: Leveldoor Problem - Your Computer - 11-13-2011

(11-13-2011, 08:42 PM)Togglevolt Wrote: The SetMessage("Ch01Level01", "InteractLevelDoor", 0); = Maybe I should find a Lantern first.


It is displayed as wanted when I touch the door without a Lantern. But it is also displayed at the very
beginning. I have a "wake up" intro, so it makes no sence having a message telling you to find a
Lantern first when your waking up.

In that case we can avoid using the SetMessage function. Since the door would, i presume, be unlocked when picking up a lantern, we can safely have that message be the locked message for the level door. In the level editor specify the category and entry names for the desired level door and remove the SetMessage function from your script.


RE: Leveldoor Problem - Togglevolt - 11-13-2011

It works, but it's not perfect. If I have the lantern in my inventory, I have to touch the door twice.
The first time I touch it, nothing happens except "Maybe I should find a Lantern first." is displayed. Then the second time I touch it, I get teleported to the next level and no message is displayed.


I suppose it unlocks the first time I click it.



RE: Leveldoor Problem - Your Computer - 11-13-2011

You probably have the callback that unlocks the door on the level door. The interact callback should be on the lantern to unlock the level door.


RE: Leveldoor Problem - Togglevolt - 11-13-2011

I tried to put the "CheckLantern" in the interact callback tab on the lantern. Then the level door is locked even if I have the lantern on me.


CheckLantern looks like this:



void CheckLantern(string &in asEntity)
{
if(HasItem("lantern_1") == true){
SetLevelDoorLocked(asEntity, false);
}
else{
SetLevelDoorLocked(asEntity, true);
}

}


void OnEnter()
{

CheckLantern("level_wood_1");
}


RE: Leveldoor Problem - Your Computer - 11-14-2011

There is no reason to check if the player has a lantern within the interact callback of the lantern itself.