Frictional Games Forum (read-only)
lever 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: lever problem (/thread-17298.html)



lever problem - Lizard - 07-27-2012

I have a problem with lever i set in my cs.

The first time i scripted it in, it worked perfectly, but now after that i copied that script into another file, and changed the names that need to be changed, it wont work.

void OnStart()
{
SetEntityConnectionStateChangeCallback("bro_lever", "UnLockDoor");
}

void UnLockDoor(string &in asEntity, int level_state)
{
if (level_state == 1)
{
SetSwingDoorLocked("castle_1", false, true);
PlaySoundAtEntity("", "ui_sanity_gain", "Player", 0, false);
GiveSanityBoost();
}
}


RE: lever problem - Adny - 07-27-2012

The script looks fine and should work properly. Make sure:

-the new script file you pasted it into is an actual c++ script file and not just a .txt file
-the .map and .hps files are named exactly the same
-the .map and .hps files are in the same folder
-both the lever and door names in the .hps file are exactly the same as in the level editor.


RE: lever problem - Steve - 07-27-2012

I don't see anything wrong :|
are you sure the names are correct?


EDIT: Ninjaed XD


RE: lever problem - Lizard - 07-27-2012

(07-27-2012, 03:43 PM)andyrockin123 Wrote: The script looks fine and should work properly. Make sure:

-the new script file you pasted it into is an actual c++ script file and not just a .txt file
-the .map and .hps files are named exactly the same
-the .map and .hps files are in the same folder
-both the lever and door names in the .hps file are exactly the same as in the level editor.
it is a c++ script file, and i have other scripts that works fine in the same map and the lever and door names are excatly the same in both level editor and the .hps file

I can upload the entire script. There might be something i missed


////////////////////
//Run first time entering map
void OnStart()
{
AddEntityCollideCallback("Player", "StartMusicArea", "StartMusic", true, 1);
AddUseItemCallback("", "RustyKey", "metal_1", "UsedKeyOnDoor", true);
SetEntityPlayerInteractCallback("ScareCabinet", "RoarScare", true);
SetEntityConnectionStateChangeCallback("bro_lever", "UnLockDoor");
AddEntityCollideCallback("Player", "DeadBroArea", "BroStare", true, 1);
}

void StartMusic(string &in asParent, string &in asChild, int alState)
{
PlayMusic("ambience_haunting", true, 1, 2, 1, true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("metal_1", false, true);
PlaySoundAtEntity("", "unlock_door", "metal_1", 0, false);
RemoveItem("RustyKey");
}

void RoarScare(string &in asEntity)
{
PlaySoundAtEntity("", "brute/enabled", "castle_1", 0, false);
}

void UnLockDoor(string &in asEntity, int level_state)
{
if (level_state == 1)
{
SetSwingDoorLocked("castle_1", false, true);
PlaySoundAtEntity("", "ui_sanity_gain", "Player", 0, false);
GiveSanityBoost();
}
}

void BroStare(string &in asParent, string &in asChild, int alState)
{
StartPlayerLookAt("grunt_body_part2_1", 1, 10, "");
SetPlayerActive(false);
AddTimer("player_stare", 2, "Stare");
GiveSanityDamage(50, true);
}

void Stare(string &in asTimer)
{
SetPlayerActive(true);
StopPlayerLookAt();
}

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

}

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

}


RE: lever problem - Adny - 07-27-2012

Try replacing your if statement with:

if(GetLeverState("NAME_OF_LEVER") == 1)

{
///do stuff

}


RE: lever problem - Lizard - 07-27-2012

(07-27-2012, 03:53 PM)andyrockin123 Wrote: Try replacing your if statement with:

if(GetLeverState("NAME_OF_LEVER") == 1)

{
///do stuff

}
It worked, thanks man