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


Thread Rating:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with a pipe puzzle
Rownbear Offline
Member

Posts: 157
Threads: 13
Joined: Apr 2011
Reputation: 2
#1
Help with a pipe puzzle

Hello I need help with using the "if" in my script, I just dont get it. So I have 3 pipes use them on 3 separate scripts and every time one placed right an pipe entity appears so the player sees that it's placed right. Now When all are placed right I want to swap a stuck valve with a valve that can be turned. So here's my script so far

Spoiler below!

void OnStart()
{
AddUseItemCallback("GetOil", "pipe_piece_1", "PipeArea1", "PipeQuest1", true);
AddUseItemCallback("GetOil", "pipe_piece_2", "PipeArea2", "PipeQuest2", true);
AddUseItemCallback("GetOil", "pipe_piece_3", "PipeArea3", "PipeQuest3", true);
}

///PIPEQUEST
void PipeQuest1(string &in asItem, string &in asEntity)
{
RemoveItem("pipe_piece_1");
SetEntityActive("Pipe1", true);
PlaySoundAtEntity("", "puzzle_place_jar.snt", "Player", 0, false);
}

void PipeQuest2(string &in asItem, string &in asEntity)
{
RemoveItem("pipe_piece_2");
SetEntityActive("Pipe2", true);
PlaySoundAtEntity("", "puzzle_place_jar.snt", "Player", 0, false);
}

void PipeQuest3(string &in asItem, string &in asEntity)
{
RemoveItem("pipe_piece_3");
SetEntityActive("Pipe3", true);
PlaySoundAtEntity("", "puzzle_place_jar.snt", "Player", 0, false);
}



I don't know how to script it to understand when all 3 pipes are placed right it should swap the stuck valve with the unstuck
Help appreciated! Smile

(This post was last modified: 05-23-2011, 04:16 PM by Rownbear.)
05-23-2011, 04:14 PM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#2
RE: Help with a pipe puzzle

You use a local variable.

Try this:

void OnStart()
{
     AddUseItemCallback("GetOil", "pipe_piece_1", "PipeArea1", "PipeQuest1", false);
     AddUseItemCallback("GetOil", "pipe_piece_2", "PipeArea2", "PipeQuest2", false);
     AddUseItemCallback("GetOil", "pipe_piece_3", "PipeArea3", "PipeQuest3", false);
     SetLocalVarInt("Var01", 1);
}
void PipeQuestDone()
{
     [Do whatever you want to happen here]
}
void PipeQuest1(string &in asItem, string &in asEntity)
{
     if (GetLocalVarInt("Var01") == 1)
     {
          RemoveItem("pipe_piece_1");
          SetEntityActive("Pipe1", true);
          PlaySoundAtEntity("", "puzzle_place_jar.snt", "Player", 0, false);
          SetLocalVarInt("Var01", 2);
          return;
     }
     else
     {
          AddUseItemCallback("GetOil", "pipe_piece_1", "PipeArea1", "PipeQuest1", false);
     }
}
void PipeQuest2(string &in asItem, string &in asEntity)
{
     if (GetLocalVarInt("Var01") == 2)
     {
          RemoveItem("pipe_piece_2");
          SetEntityActive("Pipe2", true);
          PlaySoundAtEntity("", "puzzle_place_jar.snt", "Player", 0, false);
          SetLocalVarInt("Var01", 3);
          return;
     }
     else
     {
          AddUseItemCallback("GetOil", "pipe_piece_2", "PipeArea2", "PipeQuest2", false);
     }
}
void PipeQuest3(string &in asItem, string &in asEntity)
{
     if (GetLocalVarInt("Var01") == 3)
     {
          RemoveItem("pipe_piece_3");
          SetEntityActive("Pipe3", true);
          PlaySoundAtEntity("", "puzzle_place_jar.snt", "Player", 0, false);
          PipeQuestDone();
          return;
     }
     else
     {
          AddUseItemCallback("GetOil", "pipe_piece_3", "PipeArea3", "PipeQuest3", false);
     }
}

I think this should fix most of it. Smile

05-23-2011, 09:28 PM
Find
Rownbear Offline
Member

Posts: 157
Threads: 13
Joined: Apr 2011
Reputation: 2
#3
RE: Help with a pipe puzzle

(05-23-2011, 09:28 PM)Kyle Wrote: You use a local variable.

Try this:

void OnStart()
{
     AddUseItemCallback("GetOil", "pipe_piece_1", "PipeArea1", "PipeQuest1", false);
     AddUseItemCallback("GetOil", "pipe_piece_2", "PipeArea2", "PipeQuest2", false);
     AddUseItemCallback("GetOil", "pipe_piece_3", "PipeArea3", "PipeQuest3", false);
     SetLocalVarInt("Var01", 1);
}
void PipeQuestDone()
{
     [Do whatever you want to happen here]
}
void PipeQuest1(string &in asItem, string &in asEntity)
{
     if (GetLocalVarInt("Var01") == 1)
     {
          RemoveItem("pipe_piece_1");
          SetEntityActive("Pipe1", true);
          PlaySoundAtEntity("", "puzzle_place_jar.snt", "Player", 0, false);
          SetLocalVarInt("Var01", 2);
          return;
     }
     else
     {
          AddUseItemCallback("GetOil", "pipe_piece_1", "PipeArea1", "PipeQuest1", false);
     }
}
void PipeQuest2(string &in asItem, string &in asEntity)
{
     if (GetLocalVarInt("Var01") == 2)
     {
          RemoveItem("pipe_piece_2");
          SetEntityActive("Pipe2", true);
          PlaySoundAtEntity("", "puzzle_place_jar.snt", "Player", 0, false);
          SetLocalVarInt("Var01", 3);
          return;
     }
     else
     {
          AddUseItemCallback("GetOil", "pipe_piece_2", "PipeArea2", "PipeQuest2", false);
     }
}
void PipeQuest3(string &in asItem, string &in asEntity)
{
     if (GetLocalVarInt("Var01") == 3)
     {
          RemoveItem("pipe_piece_3");
          SetEntityActive("Pipe3", true);
          PlaySoundAtEntity("", "puzzle_place_jar.snt", "Player", 0, false);
          PipeQuestDone();
          return;
     }
     else
     {
          AddUseItemCallback("GetOil", "pipe_piece_3", "PipeArea3", "PipeQuest3", false);
     }
}

I think this should fix most of it. Smile

Thanks mate, i'll try when I get home, btw could you explain to me what that "SetLocalVarInt("Var01", 1);" or what the var01 does? I can just copy this but I'm not sure how it actually works Tongue

EDIT: Yep, works like a charm, still don't know how it works tho

(This post was last modified: 05-24-2011, 02:59 PM by Rownbear.)
05-24-2011, 02:03 PM
Find
SLAMnesia Offline
Member

Posts: 99
Threads: 39
Joined: May 2011
Reputation: 0
#4
RE: Help with a pipe puzzle

I'd like to know how variables work too Big Grin

I have a problem and I posted it here;
http://www.frictionalgames.com/forum/thr...l#pid74695
And the public says it's a variable problem >.> I have no idea what those are or how to use em but this could help me in some way im sure
06-07-2011, 04:26 PM
Find
DannieWest Offline
Member

Posts: 156
Threads: 13
Joined: Apr 2011
Reputation: 0
#5
RE: Help with a pipe puzzle

Well, it's basically something like when the local variable is 0 something happens, and when it is 1 something else happens, so when you use the "if", the script checks if the variable is equal to 0 or 1. So if you set the local variable to 1 it will do the script you created for local var 1. If, lets say you haven't collected the item, the variable is 0 and will skip the script which had the variable 1 and do whatever is on 0, until you get the necessary items (or w/e it is you use to change the variable to 1) and then it does the script you created for 1 Smile Since english isn't my main language I might've explained a bit confusing, but I hope this helped a little at least xD

The if does exactly what it's named, IF something is 0 the script is activated, else it does the 1 or what the local variable is Smile
(This post was last modified: 06-08-2011, 01:20 PM by DannieWest.)
06-08-2011, 01:19 PM
Find
Rownbear Offline
Member

Posts: 157
Threads: 13
Joined: Apr 2011
Reputation: 2
#6
RE: Help with a pipe puzzle

SOLVED: CANT USE 180, only -1, 0, and 1, figured it out self, sorry for useless bump.

Bumping old instead of making new:

I got a problem with a valve for my script, I got one working but it's not working correctly. So am I not using the right script for this? I just want to turn the valve to 180 and the stuff to happen



void OnStart()
{
SetEntityConnectionStateChangeCallback("Valve_1", "MakeAcid");
}

void MakeAcid(string &in asEntity, int alState)
{
if (alState == 180)
{
SetLeverStuckState("Valve_1", 180, true);
SetEntityActive("13_burner_1", true);
AddTimer("Timer", 3.0, "AcidFinished");
}
}


void AcidFinished(string&in asTimer)
{
SetEntityActive("13_burner_1", false);
SetEntityActive("chemical_container_full_1", true);
}

Please Help.

(This post was last modified: 06-26-2011, 01:40 AM by Rownbear.)
06-26-2011, 01:30 AM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#7
RE: Help with a pipe puzzle

@Rownbear;

Wow, I didn't know that you had to do -1, 0, or 1 for a valve, because I was always trying to do it the way you said you first did it. XD

06-26-2011, 01:49 AM
Find




Users browsing this thread: 2 Guest(s)