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
Script Help Multiple Levers
i3670 Offline
Posting Freak

Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation: 36
#1
Multiple Levers

Hi!

I have these levers that need to be pulled in a certain order for a door to open. The problem is of course that it isn't working.

void OnStart()
{
SetLocalVarInt("Var1", 0);
SetEntityPlayerInteractCallback("button_1", "func1", true);
SetEntityPlayerInteractCallback("button_2", "func2", true);
SetEntityPlayerInteractCallback("button_3", "func3", true);
SetEntityPlayerInteractCallback("button_4", "func4", true);
}

void func1(string &in asEntity)
{
AddLocalVarInt("Var1", 1);
func5();
}

void func2(string &in asEntity)
{
AddLocalVarInt("Var1", 1);
func5();
}

void func3(string &in asEntity)
{
AddLocalVarInt("Var1", 1);
func5();
}

void func4(string &in asEntity)
{
AddLocalVarInt("Var1", 1);
func5();
}

void func5()
{
if(GetLocalVarInt("Var1") == 4)
{
SetEntityActive("castle_gate_arched01_1", false);
SetEntityActive("castle_gate_arched01_2", true);
}
}


01-22-2012, 12:08 PM
Find
Tripication Offline
Member

Posts: 172
Threads: 19
Joined: Dec 2011
Reputation: 6
#2
RE: Multiple Levers

Is there an error report, or will it just not work?
and are you sure you dont want
castle_gate_arched01_open?
oh, you used the wrong callback(if your using levers)

you should have

void OnStart()
{
SetLocalVarInt("Var1", 0);
SetEntityConnectionStateChangeCallback("lever", "func1");
SetEntityConnectionStateChangeCallback("lever", "func2");
SetEntityConnectionStateChangeCallback("lever", "func3");
SetEntityConnectionStateChangeCallback("lever", "func4");
}

void func1(string &in asEntity)
{
AddLocalVarInt("Var1", 1);
func5();
}

void func2(string &in asEntity)
{
AddLocalVarInt("Var1", 1);
func5();
}

void func3(string &in asEntity)
{
AddLocalVarInt("Var1", 1);
func5();
}

void func4(string &in asEntity)
{
AddLocalVarInt("Var1", 1);
func5();
}

void func5()
{
if(GetLocalVarInt("Var1") == 4)
{
SetEntityActive("castle_gate_arched01_1", false);
SetEntityActive("castle_gate_arched01_2", true);
}
}

[Image: speedart__2___yoshimitsu_by_kamofudge-d4yo6kk.png]
(This post was last modified: 01-22-2012, 12:20 PM by Tripication.)
01-22-2012, 12:09 PM
Find
i3670 Offline
Posting Freak

Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation: 36
#3
RE: Multiple Levers

(01-22-2012, 12:09 PM)Tripication Wrote: Is there an error report, or will it just not work?
and are you sure you dont want
castle_gate_arched01_open?
I can enter the map in game without an error message. But when I pull the levers nothing happens.

The door in question is the great big castle door which cannot be opened so I did it like this with SetEntityActive.

01-22-2012, 12:20 PM
Find
Tripication Offline
Member

Posts: 172
Threads: 19
Joined: Dec 2011
Reputation: 6
#4
RE: Multiple Levers

Previous post(i edited it)
And there is a seperate entity that is already open, cracked enough so the player can get through
fuck, hang on, that wont be all to the script...
There, This script should be right.

It should make it so that when the player pulls down on each lever, it will add 1 to the Variable. When the variable is fulfilled, it will process func5



void OnStart()
{
SetLocalVarInt("Var1", 0);//CREATES VARIABLE
SetEntityConnectionStateChangeCallback("lever", "func1");//CREATES FUNC1
SetEntityConnectionStateChangeCallback("lever", "func2");//CREATES FUNC2
SetEntityConnectionStateChangeCallback("lever", "func3");//CREATES FUNC3
SetEntityConnectionStateChangeCallback("lever", "func4");//CREATES FUNC4
}

void func1(string &in asEntity)//STARTS FUNC1
{
if (alState == 1)//IF THE LEVER IS PULLED DOWN, IT WILL EXECUTE THE FOLLOWING
{
AddLocalVarInt("Var1", 1);
func5();//SENDS THE SCRIPT TO FUNC5 TO CHECK IF COMPLETE
}
}

void func2(string &in asEntity)//IF THE LEVER IS PULLED DOWN, IT WILL EXECUTE THE FOLLOWING
{
if (alState == 1)
{
AddLocalVarInt("Var1", 1);
func5();//SENDS THE SCRIPT TO FUNC5 TO CHECK IF COMPLETE
}
}

void func3(string &in asEntity)//IF THE LEVER IS PULLED DOWN, IT WILL EXECUTE THE FOLLOWING
{
if (alState == 1)
{
AddLocalVarInt("Var1", 1);
func5();//SENDS THE SCRIPT TO FUNC5 TO CHECK IF COMPLETE
}
}

void func4(string &in asEntity)//IF THE LEVER IS PULLED DOWN, IT WILL EXECUTE THE FOLLOWING
{
if (alState == 1)
{
AddLocalVarInt("Var1", 1);
func5();//SENDS THE SCRIPT TO FUNC5 TO CHECK IF COMPLETE
}
}

void func5()//STARTS FUNC5
{
if(GetLocalVarInt("Var1") == 4)//IF VARIABLE IS FULFILLED, IT WILL EXECUTE THE FOLLOWING
{
SetEntityActive("castle_gate_arched01_1", false);
SetEntityActive("castle_gate_arched01_2", true);
}
}


Im going to have to thank Statyk, flamez, your computer, Elven, russ money and Apjjm(and anyone else that doesn't come to mind) for helping me out with alot of this. They taught me most I know and I really appreciate it. Big Grin

[Image: speedart__2___yoshimitsu_by_kamofudge-d4yo6kk.png]
(This post was last modified: 01-22-2012, 12:36 PM by Tripication.)
01-22-2012, 12:21 PM
Find
i3670 Offline
Posting Freak

Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation: 36
#5
RE: Multiple Levers

Ok tried to start the map now, gave me error: 'alState' is not declared Expression must be of boolean type.

256,5
256,5
265,5
265,5
274,5
274,5
283,5
283,5





void func1(string &in asEntity) /254
{
if (alState == 1)
{
AddLocalVarInt("Var1", 1);
func5();
}
}

void func2(string &in asEntity)
{
if (alState == 1)
{
AddLocalVarInt("Var1", 1);
func5();
}
}

void func3(string &in asEntity)
{
if (alState == 1)
{
AddLocalVarInt("Var1", 1);
func5();
}
}

void func4(string &in asEntity)
{
if (alState == 1)
{
AddLocalVarInt("Var1", 1);
func5();
}
}

void func5()
{
01-22-2012, 12:37 PM
Find
Tripication Offline
Member

Posts: 172
Threads: 19
Joined: Dec 2011
Reputation: 6
#6
RE: Multiple Levers

make sure you changed the names of the levers in the void OnStart

[Image: speedart__2___yoshimitsu_by_kamofudge-d4yo6kk.png]
01-22-2012, 12:40 PM
Find
i3670 Offline
Posting Freak

Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation: 36
#7
RE: Multiple Levers

(01-22-2012, 12:40 PM)Tripication Wrote: make sure you changed the names of the levers in the void OnStart
yes they're called button_1 in the map editor and it is button_1 in the OnStart
01-22-2012, 12:41 PM
Find
Tripication Offline
Member

Posts: 172
Threads: 19
Joined: Dec 2011
Reputation: 6
#8
RE: Multiple Levers

Oh sorry again, wrong syntax this time

ill fix here


void OnStart()
{
SetLocalVarInt("Var1", 0);//CREATES VARIABLE
SetEntityConnectionStateChangeCallback("LEVER1", "func1");//CREATES FUNC1
SetEntityConnectionStateChangeCallback("LEVER2", "func2");//CREATES FUNC2
SetEntityConnectionStateChangeCallback("LEVER3", "func3");//CREATES FUNC3
SetEntityConnectionStateChangeCallback("LEVER4", "func4");//CREATES FUNC4
}

void func1(string &in asEntity, int alState)//STARTS FUNC1
{
if (alState == 1)//IF THE LEVER IS PULLED DOWN, IT WILL EXECUTE THE FOLLOWING
{
AddLocalVarInt("Var1", 1);
func5();//SENDS THE SCRIPT TO FUNC5 TO CHECK IF COMPLETE
}
}

void func2(string &in asEntity, int alState)//IF THE LEVER IS PULLED DOWN, IT WILL EXECUTE THE FOLLOWING
{
if (alState == 1)
{
AddLocalVarInt("Var1", 1);
func5();//SENDS THE SCRIPT TO FUNC5 TO CHECK IF COMPLETE
}
}

void func3(string &in asEntity, int alState)//IF THE LEVER IS PULLED DOWN, IT WILL EXECUTE THE FOLLOWING
{
if (alState == 1)
{
AddLocalVarInt("Var1", 1);
func5();//SENDS THE SCRIPT TO FUNC5 TO CHECK IF COMPLETE
}
}

void func4(string &in asEntity, int alState)//IF THE LEVER IS PULLED DOWN, IT WILL EXECUTE THE FOLLOWING
{
if (alState == 1)
{
AddLocalVarInt("Var1", 1);
func5();//SENDS THE SCRIPT TO FUNC5 TO CHECK IF COMPLETE
}
}

void func5()//STARTS FUNC5
{
if(GetLocalVarInt("Var1") == 4)//IF VARIABLE IS FULFILLED, IT WILL EXECUTE THE FOLLOWING
{
SetEntityActive("castle_gate_arched01_1", false);
SetEntityActive("castle_gate_arched01_2", true);
}
}



[Image: speedart__2___yoshimitsu_by_kamofudge-d4yo6kk.png]
(This post was last modified: 01-22-2012, 12:48 PM by Tripication.)
01-22-2012, 12:44 PM
Find
i3670 Offline
Posting Freak

Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation: 36
#9
RE: Multiple Levers

Hehe, well the script is sorta working. I can get the things to activate, but not the way I want them to. I'll list the problems:

1. The lever wont stick in the "ON" position.
2. I can just pull any lever 4 times and the script will trigger, activating the gate.
01-22-2012, 12:52 PM
Find
Tripication Offline
Member

Posts: 172
Threads: 19
Joined: Dec 2011
Reputation: 6
#10
RE: Multiple Levers

Also In this following post, you want the levers to stay stuck afterward, use this addition
______________________________________________________________________________


void OnStart()
{
SetLocalVarInt("Var1", 0);
SetEntityConnectionStateChangeCallback("Lever1", "func1");
SetEntityConnectionStateChangeCallback("Lever2", "func2");
SetEntityConnectionStateChangeCallback("Lever3", "func3");
SetEntityConnectionStateChangeCallback("Lever4", "func4");
}

void func1(string &in asEntity, int alState)
{
if (alState == 1)
{
AddLocalVarInt("Var1", 1);
SetLeverStuckState(Lever1, 1, true);
func5();
}
}

void func2(string &in asEntity, int alState)
{
if (alState == 1)
{
AddLocalVarInt("Var1", 1);
SetLeverStuckState(Lever2, 1, true);
func5();
}
}

void func3(string &in asEntity, int alState)
{
if (alState == 1)
{
AddLocalVarInt("Var1", 1);
SetLeverStuckState(Lever3, 1, true);
func5();
}
}

void func4(string &in asEntity, int alState)
{
if (alState == 1)
{
AddLocalVarInt("Var1", 1);
SetLeverStuckState(Lever4, 1, true);
func5();
}
}

void func5()
{
if(GetLocalVarInt("Var1") == 4)
{
SetEntityActive("castle_gate_arched01_1", false);
SetEntityActive("castle_gate_arched01_2", true);
}
}


Just add the stuck states
Oh you wanted certain order...well theres the Staying in on position, i'll see if i can set something up for the specific order, but i've never done it before...What was the order you wanted?

[Image: speedart__2___yoshimitsu_by_kamofudge-d4yo6kk.png]
(This post was last modified: 01-22-2012, 12:55 PM by Tripication.)
01-22-2012, 12:53 PM
Find




Users browsing this thread: 1 Guest(s)