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
[Solved] Puzzle Script Problem?
Vale Offline
Member

Posts: 92
Threads: 13
Joined: Mar 2014
Reputation: 7
#1
[Solved] Puzzle Script Problem?

Alright, few things here.

First off is the problem I'm having.
Im creating a script for a puzzle in my custom story which works smoothly for the most part. The only error is in the fact that you can still move the pieces of the puzzle once it's completed, though the if()'s in the script should prevent that.
Here is the script below.

Spoiler below!

void OnStart()
{
AddEntityCollideCallback("Player", "script_shelf_fall", "func_shelf_fall", true, 1);
AddEntityCollideCallback("shelf_fall", "shelf_impact_area", "func_shelf_impact", true, 1);
FadeGlobalSoundVolume(0.00f, 0.01f);
AddTimer("", 5.0f, "fix_volume");
SetEntityPlayerInteractCallback("leverarea_1", "func_leverpuzzle1", false);
SetEntityPlayerInteractCallback("leverarea_2", "func_leverpuzzle2", false);
SetEntityPlayerInteractCallback("leverarea_3", "func_leverpuzzle3", false);
SetEntityPlayerInteractCallback("leverarea_4", "func_leverpuzzle4", false);
SetEntityPlayerInteractCallback("leverarea_5", "func_leverpuzzle5", false);
SetEntityPlayerInteractCallback("leverarea_6", "func_leverpuzzle6", false);
SetLocalVarInt("leverpuzzle_var", 2);
SetLocalVarInt("levers_functional", 1);
SetLocalVarInt("lever1_state", 2);
SetLocalVarInt("lever2_state", 1);
SetLocalVarInt("lever3_state", 2);
SetLocalVarInt("lever4_state", 2);
SetLocalVarInt("lever5_state", 2);
SetLocalVarInt("lever6_state", 1);
}
//This is where I add in callbacks for the script, blahblah
//main script below.
void func_leverpuzzle1(string &in asEntity)
{
if(GetLocalVarInt("levers_functional") == 0)
{

}
else if(GetLocalVarInt("levers_functional") == 1)
{
if(GetLocalVarInt("leverpuzzle_var") < 6)
{
PlayGuiSound("lock_door.snt", 1.0f);
switch(GetLocalVarInt("lever1_state"))
{
case 1:
SetLocalVarInt("lever1_state", 2);
AddLocalVarInt("leverpuzzle_var", -1);
SetEntityActive("lever1_up", true);
SetEntityActive("lever1_down", false);
break;
case 2:
SetLocalVarInt("lever1_state", 1);
AddLocalVarInt("leverpuzzle_var", 1);
SetEntityActive("lever1_down", true);
SetEntityActive("lever1_up", false);
break;
}
switch(GetLocalVarInt("lever3_state"))
{
case 1:
SetLocalVarInt("lever3_state", 2);
AddLocalVarInt("leverpuzzle_var", -1);
SetEntityActive("lever3_up", true);
SetEntityActive("lever3_down", false);
break;
case 2:
SetLocalVarInt("lever3_state", 1);
AddLocalVarInt("leverpuzzle_var", 1);
SetEntityActive("lever3_down", true);
SetEntityActive("lever3_up", false);
break;
}
switch(GetLocalVarInt("lever1_state"))
{
case 1:
SetLocalVarInt("lever5_state", 2);
AddLocalVarInt("leverpuzzle_var", -1);
SetEntityActive("lever5_up", true);
SetEntityActive("lever5_down", false);
break;
case 2:
SetLocalVarInt("lever5_state", 1);
AddLocalVarInt("leverpuzzle_var", 1);
SetEntityActive("lever5_down", true);
SetEntityActive("lever5_up", false);
break;

}
}
}
}
///////////
void func_leverpuzzle2(string &in asEntity)
{
if(GetLocalVarInt("levers_functional") == 0)
{

}
else if(GetLocalVarInt("levers_functional") == 1)
{
if(GetLocalVarInt("leverpuzzle_var") < 6)
{
PlayGuiSound("lock_door.snt", 1.0f);
switch(GetLocalVarInt("lever2_state"))
{
case 1:
SetLocalVarInt("lever2_state", 2);
AddLocalVarInt("leverpuzzle_var", -1);
SetEntityActive("lever2_up", true);
SetEntityActive("lever2_down", false);
break;
case 2:
SetLocalVarInt("lever2_state", 1);
AddLocalVarInt("leverpuzzle_var", 1);
SetEntityActive("lever2_down", true);
SetEntityActive("lever2_up", false);
break;
}
switch(GetLocalVarInt("lever3_state"))
{
case 1:
SetLocalVarInt("lever3_state", 2);
AddLocalVarInt("leverpuzzle_var", -1);
SetEntityActive("lever3_up", true);
SetEntityActive("lever3_down", false);
break;
case 2:
SetLocalVarInt("lever3_state", 1);
AddLocalVarInt("leverpuzzle_var", 1);
SetEntityActive("lever3_down", true);
SetEntityActive("lever3_up", false);
break;
}
switch(GetLocalVarInt("lever6_state"))
{
case 1:
SetLocalVarInt("lever6_state", 2);
AddLocalVarInt("leverpuzzle_var", -1);
SetEntityActive("lever6_up", true);
SetEntityActive("lever6_down", false);
break;
case 2:
SetLocalVarInt("lever6_state", 1);
AddLocalVarInt("leverpuzzle_var", 1);
SetEntityActive("lever6_down", true);
SetEntityActive("lever6_up", false);
break;
}
}
}
}
/////////
void func_leverpuzzle3(string &in asEntity)
{
if(GetLocalVarInt("levers_functional") == 0)
{

}
else if(GetLocalVarInt("levers_functional") == 1)
{
if(GetLocalVarInt("leverpuzzle_var") < 6)
{
PlayGuiSound("lock_door.snt", 1.0f);
switch(GetLocalVarInt("lever3_state"))
{
case 1:
SetLocalVarInt("lever3_state", 2);
AddLocalVarInt("leverpuzzle_var", -1);
SetEntityActive("lever3_up", true);
SetEntityActive("lever3_down", false);
break;
case 2:
SetLocalVarInt("lever3_state", 1);
AddLocalVarInt("leverpuzzle_var", 1);
SetEntityActive("lever3_down", true);
SetEntityActive("lever3_up", false);
break;
}
switch(GetLocalVarInt("lever4_state"))
{
case 1:
SetLocalVarInt("lever4_state", 2);
AddLocalVarInt("leverpuzzle_var", -1);
SetEntityActive("lever4_up", true);
SetEntityActive("lever4_down", false);
break;
case 2:
SetLocalVarInt("lever4_state", 1);
AddLocalVarInt("leverpuzzle_var", 1);
SetEntityActive("lever4_down", true);
SetEntityActive("lever4_up", false);
break;
}
switch(GetLocalVarInt("lever6_state"))
{
case 1:
SetLocalVarInt("lever6_state", 2);
AddLocalVarInt("leverpuzzle_var", -1);
SetEntityActive("lever6_up", true);
SetEntityActive("lever6_down", false);
break;
case 2:
SetLocalVarInt("lever6_state", 1);
AddLocalVarInt("leverpuzzle_var", 1);
SetEntityActive("lever6_down", true);
SetEntityActive("lever6_up", false);
break;
}
}
}
}
//////////////
void func_leverpuzzle4(string &in asEntity)
{
if(GetLocalVarInt("levers_functional") == 0)
{

}
else if(GetLocalVarInt("levers_functional") == 1)
{
if(GetLocalVarInt("leverpuzzle_var") < 6)
{
PlayGuiSound("lock_door.snt", 1.0f);
switch(GetLocalVarInt("lever4_state"))
{
case 1:
SetLocalVarInt("lever4_state", 2);
AddLocalVarInt("leverpuzzle_var", -1);
SetEntityActive("lever4_up", true);
SetEntityActive("lever4_down", false);
break;
case 2:
SetLocalVarInt("lever4_state", 1);
AddLocalVarInt("leverpuzzle_var", 1);
SetEntityActive("lever4_down", true);
SetEntityActive("lever4_up", false);
break;
}
switch(GetLocalVarInt("lever1_state"))
{
case 1:
SetLocalVarInt("lever1_state", 2);
AddLocalVarInt("leverpuzzle_var", -1);
SetEntityActive("lever1_up", true);
SetEntityActive("lever1_down", false);
break;
case 2:
SetLocalVarInt("lever1_state", 1);
AddLocalVarInt("leverpuzzle_var", 1);
SetEntityActive("lever1_down", true);
SetEntityActive("lever1_up", false);
break;
}
switch(GetLocalVarInt("lever2_state"))
{
case 1:
SetLocalVarInt("lever2_state", 2);
AddLocalVarInt("leverpuzzle_var", -1);
SetEntityActive("lever2_up", true);
SetEntityActive("lever2_down", false);
break;
case 2:
SetLocalVarInt("lever2_state", 1);
AddLocalVarInt("leverpuzzle_var", 1);
SetEntityActive("lever2_down", true);
SetEntityActive("lever2_up", false);
break;
}
}
}
}
////////////
void func_leverpuzzle5(string &in asEntity)
{
if(GetLocalVarInt("levers_functional") == 0)
{

}
else if(GetLocalVarInt("levers_functional") == 1)
{
if(GetLocalVarInt("leverpuzzle_var") < 6)
{
PlayGuiSound("lock_door.snt", 1.0f);
switch(GetLocalVarInt("lever5_state"))
{
case 1:
SetLocalVarInt("lever5_state", 2);
AddLocalVarInt("leverpuzzle_var", -1);
SetEntityActive("lever5_up", true);
SetEntityActive("lever5_down", false);
break;
case 2:
SetLocalVarInt("lever5_state", 1);
AddLocalVarInt("leverpuzzle_var", 1);
SetEntityActive("lever5_down", true);
SetEntityActive("lever5_up", false);
break;
}
switch(GetLocalVarInt("lever2_state"))
{
case 1:
SetLocalVarInt("lever2_state", 2);
AddLocalVarInt("leverpuzzle_var", -1);
SetEntityActive("lever2_up", true);
SetEntityActive("lever2_down", false);
break;
case 2:
SetLocalVarInt("lever2_state", 1);
AddLocalVarInt("leverpuzzle_var", 1);
SetEntityActive("lever2_down", true);
SetEntityActive("lever2_up", false);
break;
}
}
}
}
//////////
void func_leverpuzzle6(string &in asEntity)
{
if(GetLocalVarInt("levers_functional") == 0)
{

}
else if(GetLocalVarInt("levers_functional") == 1)
{
if(GetLocalVarInt("leverpuzzle_var") < 6)
{
PlayGuiSound("lock_door.snt", 1.0f);
switch(GetLocalVarInt("lever6_state"))
{
case 1:
SetLocalVarInt("lever6_state", 2);
AddLocalVarInt("leverpuzzle_var", -1);
SetEntityActive("lever6_up", true);
SetEntityActive("lever6_down", false);
break;
case 2:
SetLocalVarInt("lever6_state", 1);
AddLocalVarInt("leverpuzzle_var", 1);
SetEntityActive("lever6_down", true);
SetEntityActive("lever6_up", false);
break;
}
}
}
}
/////////////

The puzzle involves pressing levers into their slots, which will toggle the position of certain other levers. When they're all pushed down, the variable "leverpuzzle_var" should equal 6 (for 6 switches pressed.) However, theres either an error in control flow or with the variable, as I can still toggle the levers after I push all 6 in.
Anyone see the problem here?
Oh, and the if "levers_functional" is for another part I'm adding later, but for now its set to be true (aka '1') as default, so Ignore that.

Oh, and secondly. When theyre all pushed in I want to have another function run. What is the best way of doing that?

THANKS
(This post was last modified: 07-28-2014, 04:33 AM by Vale.)
07-27-2014, 02:07 AM
Find


Messages In This Thread
[Solved] Puzzle Script Problem? - by Vale - 07-27-2014, 02:07 AM
RE: Puzzle Script Problem? - by Daemian - 07-27-2014, 04:24 AM
RE: Puzzle Script Problem? - by Vale - 07-27-2014, 05:09 AM
RE: Puzzle Script Problem? - by PutraenusAlivius - 07-27-2014, 06:27 AM
RE: Puzzle Script Problem? - by Daemian - 07-27-2014, 05:29 AM
RE: Puzzle Script Problem? - by Mudbill - 07-27-2014, 06:29 AM
RE: Puzzle Script Problem? - by Vale - 07-27-2014, 02:05 PM



Users browsing this thread: 1 Guest(s)