Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED]Lever if-statements nearly working...
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#1
[SOLVED]Lever if-statements nearly working...

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

Trying is the first step to success.
(This post was last modified: 06-11-2012, 06:01 PM by FlawlessHappiness.)
06-10-2012, 02:31 PM
Find
No Author Offline
Posting Freak

Posts: 962
Threads: 10
Joined: Jun 2012
Reputation: 13
#2
RE: Lever if-statements nearly working...

Can you tell me how to work levers for doors like in Amnesia : Justine ?

[Image: the-cabin-in-the-woods-masked-people.jpg]
06-10-2012, 02:53 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#3
RE: Lever if-statements nearly working...

I don't know if they work any different. Do they?
Anyway these levers are just from the normal amnesia.

Trying is the first step to success.
06-10-2012, 03:05 PM
Find
No Author Offline
Posting Freak

Posts: 962
Threads: 10
Joined: Jun 2012
Reputation: 13
#4
RE: Lever if-statements nearly working...

Can you send the map ? So I can test it. Maybe I could figure it out.

[Image: the-cabin-in-the-woods-masked-people.jpg]
06-11-2012, 01:19 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#5
RE: Lever if-statements nearly working...

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

Trying is the first step to success.
(This post was last modified: 06-11-2012, 01:30 PM by FlawlessHappiness.)
06-11-2012, 01:30 PM
Find
Theforgot3n1 Offline
Member

Posts: 192
Threads: 20
Joined: Apr 2012
Reputation: 6
#6
RE: Lever if-statements nearly working...

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

Confusion: a Custom Story - Ch1 for play!
http://www.frictionalgames.com/forum/thread-15477.html
About 50% built.
Delayed for now though!
06-11-2012, 02:53 PM
Website Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#7
RE: Lever if-statements nearly working...

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.

Trying is the first step to success.
06-11-2012, 03:09 PM
Find




Users browsing this thread: 1 Guest(s)