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 Error 4.0
GoranGaming Offline
Member

Posts: 183
Threads: 30
Joined: Feb 2012
Reputation: 7
#8
RE: Script Error 4.0

Ok lol, I found a bug to the script.

Every time a lever gets pulled to the right position, it adds 1 to the LocalVarInt "Levers", so, you could just pull a lever 6 times, and you would have solved the puzzle, I have a video showing you if you do not undeerstand. Can anyone tell me how to fix this?

http://www.youtube.com/watch?v=L2cz1IP1D...e=youtu.be


Here is the script again, since I have changed a few things:


/////////////////////
//BEGIN LEVER SCRIPT
/////////////////////

void PullLever1(string &in asEntity, int alState)
{
if(alState == 1){

AddDebugMessage("Lever 1 is in the right position", false);
AddLocalVarInt("Levers", 1);
PlaySoundAtEntity("", "lever_mech_min_max", asEntity, 0.0f, false);
}else if(alState == 0){

AddDebugMessage("Lever 1 is in the wrong position", false);
}else if(alState == -1){
PlaySoundAtEntity("", "lever_mech_min_max", asEntity, 0.0f, false);
}

if(GetLocalVarInt("Levers") == 6){

AddDebugMessage("SUCCES", false);

PlayMusic("13_puzzle_machine.ogg", false, 1.0f, 0, 1, false);
SetMessage("Messages", "Succes", 5);
SetPlayerSanity(90);
AddPlayerSanity(10);

//
SetGlobalVarInt("SixLeversComplete", 1);
//

SetLeverStuckState("lever_machine_lever01", 1, false);
SetLeverStuckState("lever_machine_lever02", -1, false);
SetLeverStuckState("lever_machine_lever03", -1, false);
SetLeverStuckState("lever_machine_lever04", 1, false);
SetLeverStuckState("lever_machine_lever05", 1, false);
SetLeverStuckState("lever_machine_lever06", -1, false);

AddTimer("", 5, "TouchLeversAfterCompletion");

}else{

AddDebugMessage("The levers aren't in the right positions", false);

}
}

void PullLever2(string &in asEntity, int alState)
{
if(alState == -1){

AddDebugMessage("Lever 2 is in the right position", false);
AddLocalVarInt("Levers", 1);
}else if(alState == 0){

AddDebugMessage("Lever 2 is in the wrong position", false);

}else if(alState == 1){
PlaySoundAtEntity("", "lever_mech_min_max", asEntity, 0.0f, false);
}

if(GetLocalVarInt("Levers") == 6){

AddDebugMessage("SUCCES", false);

PlayMusic("13_puzzle_machine.ogg", false, 1.0f, 0, 1, false);
SetMessage("Messages", "Succes", 5);
SetPlayerSanity(90);
AddPlayerSanity(10);

//
SetGlobalVarInt("SixLeversComplete", 1);
//

SetLeverStuckState("lever_machine_lever01", 1, false);
SetLeverStuckState("lever_machine_lever02", -1, false);
SetLeverStuckState("lever_machine_lever03", -1, false);
SetLeverStuckState("lever_machine_lever04", 1, false);
SetLeverStuckState("lever_machine_lever05", 1, false);
SetLeverStuckState("lever_machine_lever06", -1, false);

AddTimer("", 5, "TouchLeversAfterCompletion");

}else{

AddDebugMessage("The levers aren't in the right positions", false);

}
}

void PullLever3(string &in asEntity, int alState)
{
if(alState == -1){

AddDebugMessage("Lever 3 is in the right position", false);
AddLocalVarInt("Levers", 1);
}else if(alState == 0){

AddDebugMessage("Lever 3 is in the wrong position", false);

}else if(alState == 1){
PlaySoundAtEntity("", "lever_mech_min_max", asEntity, 0.0f, false);
}

if(GetLocalVarInt("Levers") == 6){

AddDebugMessage("SUCCES", false);

PlayMusic("13_puzzle_machine.ogg", false, 1.0f, 0, 1, false);
SetMessage("Messages", "Succes", 5);
SetPlayerSanity(90);
AddPlayerSanity(10);

//
SetGlobalVarInt("SixLeversComplete", 1);
//

SetLeverStuckState("lever_machine_lever01", 1, false);
SetLeverStuckState("lever_machine_lever02", -1, false);
SetLeverStuckState("lever_machine_lever03", -1, false);
SetLeverStuckState("lever_machine_lever04", 1, false);
SetLeverStuckState("lever_machine_lever05", 1, false);
SetLeverStuckState("lever_machine_lever06", -1, false);

AddTimer("", 5, "TouchLeversAfterCompletion");

}else{

AddDebugMessage("The levers aren't in the right positions", false);

}
}

void PullLever4(string &in asEntity, int alState)
{
if(alState == 1){

AddDebugMessage("Lever 4 is in the right position", false);
AddLocalVarInt("Levers", 1);

}else if(alState == 0){

AddDebugMessage("Lever 4 is in the wrong position", false);

}else if(alState == -1){
PlaySoundAtEntity("", "lever_mech_min_max", asEntity, 0.0f, false);
}

if(GetLocalVarInt("Levers") == 6){

AddDebugMessage("SUCCES", false);

PlayMusic("13_puzzle_machine.ogg", false, 1.0f, 0, 1, false);
SetMessage("Messages", "Succes", 5);
SetPlayerSanity(90);
AddPlayerSanity(10);

//
SetGlobalVarInt("SixLeversComplete", 1);
//

SetLeverStuckState("lever_machine_lever01", 1, false);
SetLeverStuckState("lever_machine_lever02", -1, false);
SetLeverStuckState("lever_machine_lever03", -1, false);
SetLeverStuckState("lever_machine_lever04", 1, false);
SetLeverStuckState("lever_machine_lever05", 1, false);
SetLeverStuckState("lever_machine_lever06", -1, false);

AddTimer("", 5, "TouchLeversAfterCompletion");

}else{

AddDebugMessage("The levers aren't in the right positions", false);

}
}

void PullLever5(string &in asEntity, int alState)
{
if(alState == 1){

AddDebugMessage("Lever 5 is in the right position", false);
AddLocalVarInt("Levers", 1);

}else if(alState == 0){

AddDebugMessage("Lever 5 is in the wrong position", false);

}else if(alState == -1){
PlaySoundAtEntity("", "lever_mech_min_max", asEntity, 0.0f, false);
}

if(GetLocalVarInt("Levers") == 6){

AddDebugMessage("SUCCES", false);

PlayMusic("13_puzzle_machine.ogg", false, 1.0f, 0, 1, false);
SetMessage("Messages", "Succes", 5);
SetPlayerSanity(90);
AddPlayerSanity(10);

//
SetGlobalVarInt("SixLeversComplete", 1);
//

SetLeverStuckState("lever_machine_lever01", 1, false);
SetLeverStuckState("lever_machine_lever02", -1, false);
SetLeverStuckState("lever_machine_lever03", -1, false);
SetLeverStuckState("lever_machine_lever04", 1, false);
SetLeverStuckState("lever_machine_lever05", 1, false);
SetLeverStuckState("lever_machine_lever06", -1, false);

AddTimer("", 5, "TouchLeversAfterCompletion");

}else{

AddDebugMessage("The levers aren't in the right positions", false);

}
}

void PullLever6(string &in asEntity, int alState)
{
if(alState == -1){

AddDebugMessage("Lever 6 is in the right position", false);
AddLocalVarInt("Levers", 1);


}else if(alState == 0){

AddDebugMessage("Lever 6 is in the wrong position", false);

}else if(alState == 1){
PlaySoundAtEntity("", "lever_mech_min_max", asEntity, 0.0f, false);
}

if(GetLocalVarInt("Levers") == 6){

AddDebugMessage("SUCCES", false);

PlayMusic("13_puzzle_machine.ogg", false, 1.0f, 0, 1, false);
SetMessage("Messages", "Succes", 5);
SetPlayerSanity(90);
AddPlayerSanity(10);

//
SetGlobalVarInt("SixLeversComplete", 1);
//

SetLeverStuckState("lever_machine_lever01", 1, false);
SetLeverStuckState("lever_machine_lever02", -1, false);
SetLeverStuckState("lever_machine_lever03", -1, false);
SetLeverStuckState("lever_machine_lever04", 1, false);
SetLeverStuckState("lever_machine_lever05", 1, false);
SetLeverStuckState("lever_machine_lever06", -1, false);

AddTimer("", 5, "TouchLeversAfterCompletion");

}else{

AddDebugMessage("The levers aren't in the right positions", false);

}
}

void TouchLeversAfterCompletion(string &in Timer)
{
SetEntityPlayerInteractCallback("lever_machine_lever01", "TouchSixLeversStuck", false);
SetEntityPlayerInteractCallback("lever_machine_lever02", "TouchSixLeversStuck", false);
SetEntityPlayerInteractCallback("lever_machine_lever03", "TouchSixLeversStuck", false);
SetEntityPlayerInteractCallback("lever_machine_lever04", "TouchSixLeversStuck", false);
SetEntityPlayerInteractCallback("lever_machine_lever05", "TouchSixLeversStuck", false);
SetEntityPlayerInteractCallback("lever_machine_lever06", "TouchSixLeversStuck", false);
}
void TouchSixLeversStuck(string &in asEntity)
{
SetMessage("Messages", "TouchSixLeversStuck", 5);
}

//////////////////
//END LEVER SCRIPT
//////////////////

void OnStart()
{
//BEGIN LEVER SCRIPT
SetEntityConnectionStateChangeCallback("lever_machine_lever01", "PullLever1");
SetEntityConnectionStateChangeCallback("lever_machine_lever02", "PullLever2");
SetEntityConnectionStateChangeCallback("lever_machine_lever03", "PullLever3");
SetEntityConnectionStateChangeCallback("lever_machine_lever04", "PullLever4");
SetEntityConnectionStateChangeCallback("lever_machine_lever05", "PullLever5");
SetEntityConnectionStateChangeCallback("lever_machine_lever06", "PullLever6");

SetLocalVarInt("Levers", 0);
//END LEVER SCRIPT
}

Current projects:

The Dark Prison 85 % (Stopped working on this one)

Unnamed Project 7 %
06-23-2012, 12:11 PM
Website Find


Messages In This Thread
Script Error 4.0 - by GoranGaming - 06-20-2012, 09:59 PM
RE: Script Error 4.0 - by Cruzore - 06-20-2012, 10:07 PM
RE: Script Error 4.0 - by GoranGaming - 06-20-2012, 10:14 PM
RE: Script Error 4.0 - by Cruzore - 06-20-2012, 10:16 PM
RE: Script Error 4.0 - by GoranGaming - 06-20-2012, 10:20 PM
RE: Script Error 4.0 - by Cruzore - 06-20-2012, 10:20 PM
RE: Script Error 4.0 - by GoranGaming - 06-20-2012, 10:22 PM
RE: Script Error 4.0 - by GoranGaming - 06-23-2012, 12:11 PM
RE: Script Error 4.0 - by Cruzore - 06-23-2012, 12:44 PM
RE: Script Error 4.0 - by GoranGaming - 06-23-2012, 01:18 PM
RE: Script Error 4.0 - by Cruzore - 06-23-2012, 01:24 PM
RE: Script Error 4.0 - by GoranGaming - 06-23-2012, 01:33 PM
RE: Script Error 4.0 - by Cruzore - 06-23-2012, 02:02 PM
RE: Script Error 4.0 - by GoranGaming - 06-23-2012, 02:11 PM
RE: Script Error 4.0 - by Cruzore - 06-23-2012, 02:24 PM



Users browsing this thread: 2 Guest(s)