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
Making a lever puzzles...
Slanderous Offline
Posting Freak

Posts: 1,606
Threads: 78
Joined: Dec 2012
Reputation: 63
#1
Making a lever puzzles...

Hey

I was wondering how can I make a puzzle, that player pulls down four levers and then water entity disappears. I was trying with many scripts, but I can't get it to work. Can someone help me?
12-03-2013, 11:34 AM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#2
RE: Making a lever puzzles...

You need to use variables.

Variables work like this. You automaticly create one by writing:
AddLocalVarInt("LeverPuzzle", 1).

Now the variable is called "LeverPuzzle", and has the number 1.

Now what you want is that each lever makes the variable go up.
Each lever must call a callback called "LeverCallback". YOu write this in the ConnectionState in the entity's properties in the level editor..

Here is the script for the levers.

void LeverPuzzle(string &in asEntity, int alState)
{
if(alState == 1) //If the levers are pulled a specific way.
{
AddLocalVarInt("LeverPuzzle", 1)

}

if(GetLocalVarInt("LeverPuzzle") == 4) //If the variable is 4, which means all levers are pulled.
{
SetEntityActive("WaterEntity", false);
}
}

This is the simple version.

Trying is the first step to success.
12-03-2013, 12:11 PM
Find
Slanderous Offline
Posting Freak

Posts: 1,606
Threads: 78
Joined: Dec 2012
Reputation: 63
#3
RE: Making a lever puzzles...

(12-03-2013, 12:11 PM)FlawlessHair Wrote: You need to use variables.

Variables work like this. You automaticly create one by writing:
AddLocalVarInt("LeverPuzzle", 1).

Now the variable is called "LeverPuzzle", and has the number 1.

Now what you want is that each lever makes the variable go up.
Each lever must call a callback called "LeverCallback". YOu write this in the ConnectionState in the entity's properties in the level editor..

Here is the script for the levers.

void LeverPuzzle(string &in asEntity, int alState)
{
if(alState == 1) //If the levers are pulled a specific way.
{
AddLocalVarInt("LeverPuzzle", 1)

}

if(GetLocalVarInt("LeverPuzzle") == 4) //If the variable is 4, which means all levers are pulled.
{
SetEntityActive("WaterEntity", false);
}
}

This is the simple version.

Oh, thanks for help Tongue I'm going to check it and I will let ya know if it works.

It's not working Sad

Here is my script

void OnStart()
{
AddLocalVarInt("LeverPuzzle", 1);
AddEntityCollideCallback("Player", "questPrison", "GetSearchQuest", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_1", "GetRW", true, 1);
}

void GetSearchQuest(string &in asParent, string &in asChild, int alState)
{
AddQuest("memento05", "Memento05");
}
void GetRW(string &in asParent, string &in asChild, int alState)
{
AddQuest("memento06", "Memento06");
}

void LeverPuzzle(string &in asEntity, int alState)
{
if(alState == 1) //If the levers are pulled a specific way.
{
AddLocalVarInt("LeverPuzzle", 1);

}

if(GetLocalVarInt("LeverPuzzle") == 1) //If the variable is 4, which means all levers are pulled.
{
SetEntityActive("childsnake_floor_water_normal_1", false);
}
}

It gives me a fatal error; 23,1 - expected ";"
What should I do then?
(This post was last modified: 12-03-2013, 02:41 PM by Slanderous.)
12-03-2013, 12:34 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#4
RE: Making a lever puzzles...

Try this.

void OnStart()
{
AddEntityCollideCallback("Player", "questPrison", "GetSearchQuest", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_1", "GetRW", true, 1);
}

void GetSearchQuest(string &in asParent, string &in asChild, int alState)
{
AddQuest("memento05", "Memento05");
}
void GetRW(string &in asParent, string &in asChild, int alState)
{
AddQuest("memento06", "Memento06");
}

void LeverPuzzle(string &in asEntity, int alState)
{
if(alState == 1)
{
AddLocalVarInt("LeverPuzzle", 1);
}

if(alState == -1)
{
AddLocalVarInt("LeverPuzzle", -1);
}

if(GetLocalVarInt("LeverPuzzle") == 4)
{
if(GetLocalVarInt("LeverDone") == 1)
{
return;
}
SetEntityActive("childsnake_floor_water_normal_1", false);
SetLocalVarInt("LeverDone", 1);
}
}

Trying is the first step to success.
(This post was last modified: 12-03-2013, 05:41 PM by FlawlessHappiness.)
12-03-2013, 05:41 PM
Find
Slanderous Offline
Posting Freak

Posts: 1,606
Threads: 78
Joined: Dec 2012
Reputation: 63
#5
RE: Making a lever puzzles...

(12-03-2013, 05:41 PM)FlawlessHair Wrote: Try this.

void OnStart()
{
AddEntityCollideCallback("Player", "questPrison", "GetSearchQuest", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_1", "GetRW", true, 1);
}

void GetSearchQuest(string &in asParent, string &in asChild, int alState)
{
AddQuest("memento05", "Memento05");
}
void GetRW(string &in asParent, string &in asChild, int alState)
{
AddQuest("memento06", "Memento06");
}

void LeverPuzzle(string &in asEntity, int alState)
{
if(alState == 1)
{
AddLocalVarInt("LeverPuzzle", 1);
}

if(alState == -1)
{
AddLocalVarInt("LeverPuzzle", -1);
}

if(GetLocalVarInt("LeverPuzzle") == 4)
{
if(GetLocalVarInt("LeverDone") == 1)
{
return;
}
SetEntityActive("childsnake_floor_water_normal_1", false);
SetLocalVarInt("LeverDone", 1);
}
}

It works now! Thanks ! Rep+
12-03-2013, 06:22 PM
Find




Users browsing this thread: 2 Guest(s)