Frictional Games Forum (read-only)
If player has lantern - 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: If player has lantern (/thread-30344.html)



If player has lantern - User01 - 08-02-2015

Player gets lantern on map A. In map B an entity is supposed to be active when player has the item.

My first try (I like this better cause it seems simpler)
Map B
PHP Code:
void OnStart()
{
AddTimer("LanternChecker"0.1f"haslantern");
}

void haslantern(string &in asTimer)
{
if(
HasItem("Lantern"))
{
SetEntityActive("Entity_Name"true);
}



My second try
Map A
PHP Code:
void OnStart()
{
SetGlobalVarInt("LanternVar"0);
SetEntityPlayerInteractCallback("Lantern""Setvar"true);
}

void Setvar(string &in asEntity)
{
    
AddGlobalVarInt("LanternVar"1);


Map B
PHP Code:
void OnEnter()
{
if(
GetGlobalVarInt("LanternVar")==1)
SetEntityActive("Entity_Name"true);
}

But nothing changes when player has item.


RE: If player has lantern - Mudbill - 08-02-2015

The first should work, although you really don't need that timer.

PHP Code:
void OnStart()
{
    if(
HasItem("Lantern"))
    {
        
SetEntityActive("Entity_Name"true);
    }


Just make sure your entity actually can be scripted with. Not all types can. StaticProp does not support activating/deactivating. Also, since this is in OnStart, not OnEnter, make sure this is the first time the player enters this map, not returning.

Is your entity actually inactive when you enter the map? Check for map_caches and internal names.


RE: If player has lantern - User01 - 08-02-2015

Yep it works now. Thanks.