Frictional Games Forum (read-only)

Full Version: [SOLVED]Lever if-statements nearly working...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Yea so i have 4 levers (2 of them is combined in 1 script) So it is 3 scripts we are talking about.

Spoiler below!

void OnStart()
{

SetEntityConnectionStateChangeCallback("lever_simple01_1", "PipeStart1_1");
SetEntityConnectionStateChangeCallback("lever_simple01_2", "PipeStart1_2");
SetEntityConnectionStateChangeCallback("lever_simple01_3", "PipeStart2_1");
SetEntityConnectionStateChangeCallback("lever_simple01_4", "PipeStart3_1");
}


///TIMERS

void MachineSoundTimer(string &in asTimer)
{
PlaySoundAtEntity("","13_machine_run.snt", "ScriptArea_2", 0, false);
}

///LEVERS

void PipeStart3_1(string &in asEntity, int alState)
{
if(alState == -1)
{
AddDebugMessage("MachineStart +1", false);
AddLocalVarInt("MachineStart", 1);
SetLeverStuckState("lever_simple01_4", -1, true);
PlaySoundAtEntity("","13_press_done.snt", "ScriptArea_8", 0, false);
CreateParticleSystemAtEntity("Steam_5", "ps_steam.ps", "ScriptArea_7", true);
CreateParticleSystemAtEntity("Steam_6", "ps_steam.ps", "ScriptArea_8", true);
SetEntityActive("StickyArea_1", true);
}
else

if(GetLocalVarInt("MachineStart") == 3)
{
AddPlayerSanity(5.0f);
AddTimer("", 0.3, "MachineSoundTimer");
CreateParticleSystemAtEntity("Steam_nonstop_1", "ps_steam.ps", "ScriptArea_9", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_12", 0, false);
CreateParticleSystemAtEntity("Steam_nonstop_2", "ps_steam.ps", "ScriptArea_10", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_13", 0, false);
CreateParticleSystemAtEntity("Steam_nonstop_3", "ps_steam.ps", "ScriptArea_11", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_14", 0, false);
}
}

void PipeStart2_1(string &in asEntity, int alState)
{
if(alState == -1)
{
AddDebugMessage("MachineStart +1", false);
AddLocalVarInt("MachineStart", 1);
SetLeverStuckState("lever_simple01_3", -1, true);
PlaySoundAtEntity("","13_press_done.snt", "ScriptArea_6", 0, false);
CreateParticleSystemAtEntity("Steam_3", "ps_steam.ps", "ScriptArea_5", true);
CreateParticleSystemAtEntity("Steam_4", "ps_steam.ps", "ScriptArea_6", true);
SetEntityActive("StickyArea_2", true);
}
else

if(GetLocalVarInt("MachineStart") == 3)
{
AddPlayerSanity(5.0f);
AddTimer("", 0.3, "MachineSoundTimer");
CreateParticleSystemAtEntity("Steam_nonstop_1", "ps_steam.ps", "ScriptArea_9", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_12", 0, false);
CreateParticleSystemAtEntity("Steam_nonstop_2", "ps_steam.ps", "ScriptArea_10", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_13", 0, false);
CreateParticleSystemAtEntity("Steam_nonstop_3", "ps_steam.ps", "ScriptArea_11", true); PlaySoundAtEntity("","13_steam.snt", "ScriptArea_14", 0, false);
}
}

void PipeStart1_1(string &in asEntity, int alState)
{
if(alState == 1)
{
AddLocalVarInt("PipeStart1", 1);
SetLeverStuckState("lever_simple01_1", 1, true);
PlaySoundAtEntity("","13_press_done.snt", "pipes_thin_bend_short_9", 0, false);
CreateParticleSystemAtEntity("Steam_1", "ps_steam.ps", "ScriptArea_3", true);

if(GetLocalVarInt("PipeStart1") == 2)
{
AddDebugMessage("MachineStart +1", false);
AddLocalVarInt("MachineStart", 1);
PlaySoundAtEntity("","13_press_done.snt", "ScriptArea_2", 0, false);
PlaySoundAtEntity("","13_machine_fail.snt", "ScriptArea_2", 0, false);
SetEntityActive("StickyArea_3", true);
}
else

if(GetLocalVarInt("MachineStart") == 3)
{
AddPlayerSanity(5.0f);
AddDebugMessage("StartMachineSound", false);
AddTimer("", 0.3, "MachineSoundTimer");
CreateParticleSystemAtEntity("Steam_nonstop_1", "ps_steam.ps", "ScriptArea_9", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_12", 0, false);
CreateParticleSystemAtEntity("Steam_nonstop_2", "ps_steam.ps", "ScriptArea_10", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_13", 0, false);
CreateParticleSystemAtEntity("Steam_nonstop_3", "ps_steam.ps", "ScriptArea_11", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_14", 0, false);
}
}
}

void PipeStart1_2(string &in asEntity, int alState)
{
if(alState == 1)
{
AddLocalVarInt("PipeStart1", 1);
SetLeverStuckState("lever_simple01_2", 1, true);
PlaySoundAtEntity("","13_press_done.snt", "pipes_thin_bend_short_10", 0, false);
CreateParticleSystemAtEntity("Steam_2", "ps_steam.ps", "ScriptArea_4", true);

if(GetLocalVarInt("PipeStart1") == 2)
{
AddDebugMessage("MachineStart +1", false);
AddLocalVarInt("MachineStart", 1);
PlaySoundAtEntity("","13_press_done.snt", "Player", 0, false);
PlaySoundAtEntity("","13_machine_fail.snt", "ScriptArea_2", 0, false);
SetEntityActive("StickyArea_3", true);
}
else

if(GetLocalVarInt("MachineStart") == 3)
{
AddPlayerSanity(5.0f);
AddDebugMessage("StartMachineSound", false);
AddTimer("", 0.3, "MachineSoundTimer");
CreateParticleSystemAtEntity("Steam_nonstop_1", "ps_steam.ps", "ScriptArea_9", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_12", 0, false);
CreateParticleSystemAtEntity("Steam_nonstop_2", "ps_steam.ps", "ScriptArea_10", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_13", 0, false);
CreateParticleSystemAtEntity("Steam_nonstop_3", "ps_steam.ps", "ScriptArea_11", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_14", 0, false);
}
}
}



Everything works, except the if(GetLocalVarInt("MachineStart") == 3) and beneath that.

The debug messages show that the LocalVarInt is at 3, (They say +1, 3 times), but no sound or particlesystems are getting active..

It used to work, but now it doesn't. There are no errors or anything.. Just nothing
Can you tell me how to work levers for doors like in Amnesia : Justine ?
I don't know if they work any different. Do they?
Anyway these levers are just from the normal amnesia.
Can you send the map ? So I can test it. Maybe I could figure it out.
Actually i figured it out i hope:
void MachineSoundTimer(string &in asTimer)
{
PlaySoundAtEntity("","13_machine_run.snt", "ScriptArea_2", 0, false);
SetEntityActive("ScriptArea_18", true);
SetEntityActive("ScriptArea_19", true);
SetEntityActive("ScriptArea_20", true);
}


///LEVERS

void PipeStart3_1(string &in asEntity, int alState)
{
if(alState == -1)
{
AddDebugMessage("MachineStart +1", false);
AddLocalVarInt("MachineStart", 1);
SetLeverStuckState("lever_simple01_4", -1, true);
PlaySoundAtEntity("","13_press_done.snt", "ScriptArea_8", 0, false);
CreateParticleSystemAtEntity("Steam_5", "ps_steam.ps", "ScriptArea_7", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_7", 0, false);
CreateParticleSystemAtEntity("Steam_6", "ps_steam.ps", "ScriptArea_8", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_8", 0, false);
SetEntityActive("StickyArea_1", true);
Instead of having an 'else' here i just made it inside the if statement..
if(GetLocalVarInt("MachineStart") == 3)
{
AddPlayerSanity(5.0f);
AddTimer("", 0.3, "MachineSoundTimer");
CreateParticleSystemAtEntity("Steam_nonstop_1", "ps_steam.ps", "ScriptArea_9", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_12", 0, false);
CreateParticleSystemAtEntity("Steam_nonstop_2", "ps_steam.ps", "ScriptArea_10", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_13", 0, false);
CreateParticleSystemAtEntity("Steam_nonstop_3", "ps_steam.ps", "ScriptArea_11", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_14", 0, false);
}
}
}

This works for me
(06-11-2012, 01:30 PM)beecake Wrote: [ -> ]Actually i figured it out i hope:
void MachineSoundTimer(string &in asTimer)
{
PlaySoundAtEntity("","13_machine_run.snt", "ScriptArea_2", 0, false);
SetEntityActive("ScriptArea_18", true);
SetEntityActive("ScriptArea_19", true);
SetEntityActive("ScriptArea_20", true);
}


///LEVERS

void PipeStart3_1(string &in asEntity, int alState)
{
if(alState == -1)
{
AddDebugMessage("MachineStart +1", false);
AddLocalVarInt("MachineStart", 1);
SetLeverStuckState("lever_simple01_4", -1, true);
PlaySoundAtEntity("","13_press_done.snt", "ScriptArea_8", 0, false);
CreateParticleSystemAtEntity("Steam_5", "ps_steam.ps", "ScriptArea_7", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_7", 0, false);
CreateParticleSystemAtEntity("Steam_6", "ps_steam.ps", "ScriptArea_8", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_8", 0, false);
SetEntityActive("StickyArea_1", true);
Instead of having an 'else' here i just made it inside the if statement..
if(GetLocalVarInt("MachineStart") == 3)
{
AddPlayerSanity(5.0f);
AddTimer("", 0.3, "MachineSoundTimer");
CreateParticleSystemAtEntity("Steam_nonstop_1", "ps_steam.ps", "ScriptArea_9", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_12", 0, false);
CreateParticleSystemAtEntity("Steam_nonstop_2", "ps_steam.ps", "ScriptArea_10", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_13", 0, false);
CreateParticleSystemAtEntity("Steam_nonstop_3", "ps_steam.ps", "ScriptArea_11", true);
PlaySoundAtEntity("","13_steam.snt", "ScriptArea_14", 0, false);
}
}
}

This works for me
This script is very different to the earlier one. So you didn't really fix anything, you only modified it to the right.
Yes i modified the script, because more was needed for the story and stuff, but the main part is what is written in bold. I removed the 'else' and adjusted the if-statement to that.