Frictional Games Forum (read-only)

Full Version: lever problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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();
}
}
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.
I don't see anything wrong :|
are you sure the names are correct?


EDIT: Ninjaed XD
(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()
{

}
Try replacing your if statement with:

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

{
///do stuff

}
(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