The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.17 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



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 Stuck at a lever script
Soskot Offline
Junior Member

Posts: 4
Threads: 1
Joined: Mar 2013
Reputation: 0
#1
Stuck at a lever script

Greetings community of Frictional Games.
This is my first post at the forum and I'm currently working on a custom story together with three other guys for a school project.
And I am doing the scripting-part of the project and I got stuck with a problem, I've tried searching for help, but didn't find any.

Explanation of the puzzle:
I have three simple levers, and I want a certain combination for it to work, for example 1 up and 2 down. I've got so far that I made it work, and the lights above the levers gets lit, the problem is that I can just do it up & down on every lever and then the puzzle is solved.
I need the variable to reset to 0 whenever the lever is pulled to the wrong alState, but it doesn't.
I think I know what I have to do to solve this problem, but the problem is that it doesn't work as I've coded it.
Here's the script:
//Variables
int lev1;
int lev2;
int lev3;
int glev1;
int glev2;
int glev3;
int blev1;
int blev2;
int blev3;
int RedEnabled = 0;
int BlueEnabled = 0;
int GreenEnabled = 0;

void OnStart()
{
PlayMusic("music_threelights.ogg", true, 1.0f, 0, 0, true);
GiveItemFromFile("lantern", "lantern.ent");
GiveItemFromFile("tinderbox", "tinderbox.ent");
//Red Lights
SetEntityConnectionStateChangeCallback("lever_simple01_3", "func_red1");
SetEntityConnectionStateChangeCallback("lever_simple01_5", "func_red2");
SetEntityConnectionStateChangeCallback("lever_simple01_6", "func_red3");
//Green Lights
SetEntityConnectionStateChangeCallback("lever_simple01_7", "func_green1");
SetEntityConnectionStateChangeCallback("lever_simple01_8", "func_green2");
SetEntityConnectionStateChangeCallback("lever_simple01_9", "func_green3");
//Blue Lights
SetEntityConnectionStateChangeCallback("lever_simple01_1", "func_blue1");
SetEntityConnectionStateChangeCallback("lever_simple01_2", "func_blue2");
SetEntityConnectionStateChangeCallback("lever_simple01_4", "func_blue3");
}
void CheckDoorUnlocker()
{
if (RedEnabled == 1 && BlueEnabled == 1 && GreenEnabled == 1)
{
SetSwingDoorLocked("metal_1", false, true);
AddPlayerSanity(25);
}
}
void CheckVariablesForBlue()
{
if (blev1 == 1 && blev2 == 1 && blev3 == 1)
{
SetLampLit("torch_custom_blue_1", true, true);
SetLampLit("torch_custom_blue_2", true, true);
SetLampLit("torch_custom_blue_3", true, true);
SetLampLit("torch_custom_blue_4", true, true);
BlueEnabled = 1;
CheckDoorUnlocker();
}
}
void func_blue1(string &in asEntity, int alState)
{
if (alState == 1)
{
blev1 = 1;
}
if (alState != 1)
{
alState = 0;
}
CheckVariablesForBlue();
}
void func_blue2(string &in asEntity, int alState)
{
if (alState == 1)
{
blev2 = 1;
}
if (alState != 1)
{
alState = 0;
}
CheckVariablesForBlue();
}
void func_blue3(string &in asEntity, int alState)
{
if (alState == 1)
{
blev3 = 1;
}
if (alState != 1)
{
alState = 0;
}

CheckVariablesForBlue();
}

I have tried setting the variables instead of alState to 0 aswell, but it didn't work.

If you had trouble understanding something, please tell me and I'll try to explain it better.

Any help is appreciated!

And btw, it feels great to be a part of the community!

Regards,
Soskot
(This post was last modified: 03-28-2013, 04:38 PM by Soskot.)
03-28-2013, 04:23 PM
Find


Messages In This Thread
Stuck at a lever script - by Soskot - 03-28-2013, 04:23 PM
RE: Stuck at a lever script - by NaxEla - 03-28-2013, 05:20 PM
RE: Stuck at a lever script - by The chaser - 04-08-2013, 06:01 PM
RE: Stuck at a lever script - by NaxEla - 04-08-2013, 06:05 PM
RE: Stuck at a lever script - by Soskot - 03-28-2013, 05:54 PM
RE: Stuck at a lever script - by Soskot - 04-08-2013, 05:21 PM
RE: Stuck at a lever script - by The chaser - 04-08-2013, 06:08 PM
RE: Stuck at a lever script - by Soskot - 04-08-2013, 06:39 PM
RE: Stuck at a lever script - by The chaser - 04-08-2013, 06:55 PM
RE: Stuck at a lever script - by TheGreatCthulhu - 04-08-2013, 09:31 PM



Users browsing this thread: 1 Guest(s)