Frictional Games Forum (read-only)

Full Version: Leveldoor Problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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.
Try this for your OnEnter function:

Code:
void OnEnter()
{
     CheckLantern("level_wood_1");
}
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.
(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.
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.
(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.
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.
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.
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");
}
There is no reason to check if the player has a lantern within the interact callback of the lantern itself.
Pages: 1 2