Frictional Games Forum (read-only)
[SOLVED] Script 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 (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: [SOLVED] Script Problem (/thread-7377.html)



[SOLVED] Script Problem - laser50 - 04-14-2011

Hey guys, While scripting i ran into a error and i have NO idea what to do or how to fix it. So i decided to ask it here.

ERROR:
Code:
main (62, 25) :ERR :Expected data Type

My Code:
Code:
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("mansion_2", true, true);
    SetSwingDoorLocked("cabinet_nice_1", false, true);
    PlaySoundAtEntity("","unlock_door", "cabinet_nice_1" ,0.0f, false);
    RemoveItem("CabinetKey1");
    StartPlayerLookAt("Monster3", 2, 2, "");

      AddTimer("donelook", 2.5f, "TimerDoneLookAt");

    SetEntityActive("Monster3", true);
}

void TimerDoneLookAt(string &in asTimer)
{
  StopPlayerLookAt();
}


((THis is one part of where the error is.))


RE: Script Problem - Pandemoneus - 04-14-2011

Post your whole code so we can see which line it is pointing at...


RE: Script Problem - laser50 - 04-15-2011

Here is my FULL code:

Code:
void OnStart()
{  
    SetPlayerLampOil(10.0f);
    AddEntityCollideCallback("Player", "ScriptArea_1", "ActivateMonsters", true, 1);  
    AddUseItemCallback("","CabinetKey1", "cabinet_nice_1","UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("mansion_2", true, true);
    SetSwingDoorLocked("cabinet_nice_1", false, true);
    PlaySoundAtEntity("","unlock_door", "cabinet_nice_1" ,0.0f, false);
    RemoveItem("CabinetKey1");
    StartPlayerLookAt("Monster3", 2, 2, "");

      AddTimer("donelook", 2.5f, "TimerDoneLookAt");

    SetEntityActive("Monster3", true);
}


void TimerDoneLookAt(string &in asTimer)
{
  StopPlayerLookAt();
}


////////////////////////////
// Run when entering map
void OnEnter()
{

}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}

void ActivateMonsters(string &in asParent, string &in asChild, int alState)
{
    /////////////////////
    // Monster 1
    SetEntityActive("Monster1", true);
    AddEnemyPatrolNode("Monster1", "PatrolNode1", 10.0f, "");
    GiveSanityDamage(15.0f, true);
    /////////////////////
    // Monster 2
    SetEntityActive("Monster2", true);
    AddEnemyPatrolNode("Monster2", "Monster2Path1", 6.0f, "");
    AddEnemyPatrolNode("Monster2", "Monster2Path2", 6.0f, "");
    AddEnemyPatrolNode("Monster2", "Monster2Path3", 6.0f, "");
    AddEnemyPatrolNode("Monster2", "Monster2Path4", 6.0f, "");
    AddEnemyPatrolNode("Monster2", "Monster2Path1", 6.0f, "");
    AddEnemyPatrolNode("Monster2", "Monster2Path2", 6.0f, "");
    AddEnemyPatrolNode("Monster2", "Monster2Path3", 6.0f, "");
    AddEnemyPatrolNode("Monster2", "Monster2Path4", 6.0f, "");
    
}

void OnLeverStateChange("Lever1", -1)
{

    if (alState == 1)
    {
        SetSwingDoorLocked("mansion_2", false, true);
    }
}



RE: Script Problem - laser50 - 04-15-2011

Could someone please take a look and help me here?? Thanks.


RE: Script Problem - Dalroc - 04-15-2011

void OnLeverStateChange
Where did you find this function? Never seen it and it's not on the script functions page on the wiki so I guess this is the problem Tongue


RE: Script Problem - laser50 - 04-15-2011

I found it here:
http://www.frictionalgames.com/forum/thread-5117.html

I think it should work. (I think it worked on a level before I reinstalled my PC...)


RE: Script Problem - MrBigzy - 04-15-2011

That's a user defined function, like MonsterFunc1 for example. It's not a "script function".

Use this: GetLeverState(string& asName);


RE: Script Problem - laser50 - 04-15-2011

Then how should i use it if i use GetLeverState? SOme help would be great.
(I'm much of a newb when it comes to scripting.)


RE: Script Problem - MrBigzy - 04-15-2011

If you just want to open a door with a lever, this is the best way I think:

SetEntityConnectionStateChangeCallback(string& asName, string& asCallback);

So if you had SetEntityConnectionStateChangeCallback("LeverOpensDoor", "LeverDoor");

Code:
void LeverDoor(string &in EntityName, int alState)
{
   if (alState==1) SetSwingDoorLocked("mansion_2", false, true);
}

Something like that.


RE: Script Problem - laser50 - 04-16-2011

I fixed it. Thanks for the help everyone!