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 Script help needed
Steve Offline
Member

Posts: 178
Threads: 17
Joined: Jun 2012
Reputation: 7
#1
Script help needed

Okay I've come here today with another question.
I have this script wich works like this:
when I put four different object in the righ "place" and I pull lever_1 it should complete the puzzle.
but when I should have completedf the puzzle it doesn't work and it still says incorrect combination.
this is the script:
Spoiler below!

void OnStart()
{

SetLocalVarInt("oven_1_correct", 0);
SetLocalVarInt("oven_2_correct", 0);
SetLocalVarInt("oven_3_correct", 0);
SetLocalVarInt("oven_4_correct", 0);
SetLocalVarInt("All_4_Correct", 0);

for(int p=1;p<5;p++)AddEntityCollideCallback("object_"+p, "AreaOven_1", "PutObjectOven_1", false, 0);
for(int p=1;p<5;p++)AddEntityCollideCallback("object_"+p, "AreaOven_2", "PutObjectOven_2", false, 0);
for(int p=1;p<5;p++)AddEntityCollideCallback("object_"+p, "AreaOven_3", "PutObjectOven_3", false, 0);
for(int p=1;p<5;p++)AddEntityCollideCallback("object_"+p, "AreaOven_4", "PutObjectOven_4", false, 0);

SetEntityConnectionStateChangeCallback("Lever_1", "CheckIngredients");
}

////////////LEVER CHECK/////////////////

void CheckIngredients(string &in asEntity, int alState)
{
if(alState == 1)
{
//OVEN 1//
if(GetLocalVarInt("oven_1_correct") == 1)
{
AddLocalVarInt("All_4_Correct", 1);
}
if(GetLocalVarInt("oven_1_correct") == 0)
{
SetMessage("Messages", "IncorrectCombination", 0);
return;
}

//OVEN 2//
if(GetLocalVarInt("oven_2_correct") == 1)
{
AddLocalVarInt("All_4_Correct", 1);
}
if(GetLocalVarInt("oven_2_correct") == 0)
{
SetMessage("Messages", "IncorrectCombination", 0);
return;
}
//OVEN 3//
if(GetLocalVarInt("oven_3_correct") == 1)
{
AddLocalVarInt("All_4_Correct", 1);
}
if(GetLocalVarInt("oven_3_correct") == 0)
{
SetMessage("Messages", "IncorrectCombination", 0);
return;
}
//OVEN 4//
if(GetLocalVarInt("oven_4_correct") == 1)
{
AddLocalVarInt("All_4_Correct", 1);
}
if(GetLocalVarInt("oven_4_correct") == 0)
{
SetMessage("Messages", "IncorrectCombination", 0);
return;
}
if(GetLocalVarInt("All_4_Correct") == 4)
{
AddTimer("youdidit", 1, "completedpuzzle");
}
}
}

////////////OVEN 1//////////////////////

void PutObjectOven_1(string &in asParent, string &in asChild, int alState)
{
if(alState == 1)
{
if(asChild == "object_1")
{
AddLocalVarInt("oven_1_correct", 1);
AddLocalVarInt("4_Items", 1);
}
if(asChild == "object_2")
{
AddLocalVarInt("oven_1_correct", 0);
AddLocalVarInt("4_Items", 1);
}
if(asChild == "object_3")
{
AddLocalVarInt("oven_1_correct", 0);
AddLocalVarInt("4_Items", 1);
}

if(asChild == "object_4")
{
AddLocalVarInt("oven_1_correct", 0);
AddLocalVarInt("4_Items", 1);
}
}
if(alState == -1)
{
if(asChild == "object_1")
{
AddLocalVarInt("oven_1_correct", 0);
AddLocalVarInt("4_Items", -1);
}
if(asChild == "object_2")
{
AddLocalVarInt("oven_1_correct", 0);
AddLocalVarInt("4_Items", -1);
}
if(asChild == "object_3")
{
AddLocalVarInt("oven_1_correct", 0);
AddLocalVarInt("4_Items", -1);
}

if(asChild == "object_4")
{
AddLocalVarInt("oven_1_correct", 0);
AddLocalVarInt("4_Items", -1);
}
}
}

//////////OVEN 2////////////////////

void PutObjectOven_2(string &in asParent, string &in asChild, int alState)
{
if(alState == 1)
{
if(asChild == "object_1")
{
AddLocalVarInt("oven_2_correct", 0);
AddLocalVarInt("4_Items", 1);
}
if(asChild == "object_2")
{
AddLocalVarInt("oven_2_correct", 1);
AddLocalVarInt("4_Items", 1);
}
if(asChild == "object_3")
{
AddLocalVarInt("oven_2_correct", 0);
AddLocalVarInt("4_Items", 1);
}

if(asChild == "object_4")
{
AddLocalVarInt("oven_2_correct", 0);
AddLocalVarInt("4_Items", 1);
}
}
if(alState == -1)
{
if(asChild == "object_1")
{
AddLocalVarInt("oven_2_correct", 0);
AddLocalVarInt("4_Items", -1);
}
if(asChild == "object_2")
{
AddLocalVarInt("oven_2_correct", 0);
AddLocalVarInt("4_Items", -1);
}
if(asChild == "object_3")
{
AddLocalVarInt("oven_2_correct", 0);
AddLocalVarInt("4_Items", -1);
}

if(asChild == "object_4")
{
AddLocalVarInt("oven_2_correct", 0);
AddLocalVarInt("4_Items", -1);
}
}
}

///////////OVEN 3///////////////////

void PutObjectOven_3(string &in asParent, string &in asChild, int alState)
{
if(alState == 1)
{
if(asChild == "object_1")
{
AddLocalVarInt("oven_3_correct", 0);
AddLocalVarInt("4_Items", 1);
}
if(asChild == "object_2")
{
AddLocalVarInt("oven_3_correct", 0);
AddLocalVarInt("4_Items", 1);
}
if(asChild == "object_3")
{
AddLocalVarInt("oven_3_correct", 1);
AddLocalVarInt("4_Items", 1);
}

if(asChild == "object_4")
{
AddLocalVarInt("oven_3_correct", 0);
AddLocalVarInt("4_Items", 1);
}
}
if(alState == -1)
{
if(asChild == "object_1")
{
AddLocalVarInt("oven_3_correct", 0);
AddLocalVarInt("4_Items", -1);
}
if(asChild == "object_2")
{
AddLocalVarInt("oven_3_correct", 0);
AddLocalVarInt("4_Items", -1);
}
if(asChild == "object_3")
{
AddLocalVarInt("oven_3_correct", 0);
AddLocalVarInt("4_Items", -1);
}

if(asChild == "object_4")
{
AddLocalVarInt("oven_3_correct", 0);
AddLocalVarInt("4_Items", -1);
}
}
}

///////////////OVEN 4////////////////////

void PutObjectOven_4(string &in asParent, string &in asChild, int alState)
{
if(alState == 1)
{
if(asChild == "object_1")
{
AddLocalVarInt("oven_4_correct", 0);
AddLocalVarInt("4_Items", 1);
}
if(asChild == "object_2")
{
AddLocalVarInt("oven_4_correct", 0);
AddLocalVarInt("4_Items", 1);
}
if(asChild == "object_3")
{
AddLocalVarInt("oven_4_correct", 0);
AddLocalVarInt("4_Items", 1);
}

if(asChild == "object_4")
{
AddLocalVarInt("oven_4_correct", 1);
AddLocalVarInt("4_Items", 1);
}
}
if(alState == -1)
{
if(asChild == "object_1")
{
AddLocalVarInt("oven_4_correct", 0);
AddLocalVarInt("4_Items", -1);
}
if(asChild == "object_2")
{
AddLocalVarInt("oven_44_correct", 0);
AddLocalVarInt("4_Items", -1);
}
if(asChild == "object_3")
{
AddLocalVarInt("oven_4_correct", 0);
AddLocalVarInt("4_Items", -1);
}

if(asChild == "object_4")
{
AddLocalVarInt("oven_4_correct", 0);
AddLocalVarInt("4_Items", -1);
}
}
}

void completedpuzzle(string& asTimer)
{
SetSwingDoorLocked("extaction_oven_6", false, true);
SetMessage("Messages", "correctcombinationchemicals", 0);
}

CURRENTLY WORKING ON:
Final Light = 40%
Need of voice actors.
09-11-2012, 03:35 PM
Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#2
RE: Script help needed

Okay!

I think I figured it out.
Big Grin

void OnStart()
{


    AddEntityCollideCallback(*objectthing*,*area*,"oven_check_x",true,1);
    *Add your other collides, etc*

    SetEntityConnectionStateChangeCallback("Lever1","CheckIngredients");
    
    SetLocalVarInt("AllCorrect",0);
    SetLocalVarInt("check",0);
}

void CheckIngredients(string &in asEntity, int alState)
{    
    int StateSwitch = GetLocalVarInt("oven_correct");
    
    if(alState == 1)
    {
    
    switch(StateSwitch)
    {
        case 0:
          //Do whatever if order of said objects isn't correct///
        break;
        
        case 1:
             //This case will execute if the order is correct///
            AddLocalVarInt("AllCorrect",1);
            AllCorrectFunc();
        break;
    }
        
    }
}

void oven_check_x(string &in asParent, string &in asChild, int alState)
{
   *repeat this function for as many objects you have*
    ///Will add if the object is in correct place///
    AddLocalVarInt("check",1);
    Setlocal();
    
}

void AllCorrectFunc()
{
    if(GetLocalVarInt("AllCorrect") == 1)
    {
    ///Do whatever if everything is correct///
    }
}

void Setlocal()
{
    if(GetLocalVarInt("check") == *how ever many number of objects that you have in ovens*)
    {
    SetLocalVarInt("oven_correct",1);
    }
}

Then again, I'm not too confident, but try something like this and see if it works.

RAISE YOUR DONGERS ヽ༼ຈل͜ຈ༽ノ
(This post was last modified: 09-11-2012, 06:43 PM by Tomato Cat.)
09-11-2012, 06:02 PM
Find
Steve Offline
Member

Posts: 178
Threads: 17
Joined: Jun 2012
Reputation: 7
#3
RE: Script help needed

Well thank you mr credits but Beecake already found the error(not on this topic) +rep anywayBig Grin
It works now but I still have one prbolem when you put in all the objects', get on out pull the lever no texts appears and nothing happens, but when I put the object back in it works.
this is my code now:
Spoiler below!

void OnStart()
{

SetLocalVarInt("oven_1_correct", 0);
SetLocalVarInt("oven_2_correct", 0);
SetLocalVarInt("oven_3_correct", 0);
SetLocalVarInt("oven_4_correct", 0);
SetLocalVarInt("All_4_Correct", 0);

for(int p=1;p<5;p++)AddEntityCollideCallback("object_"+p, "AreaOven_1", "PutObjectOven_1", false, 0);
for(int p=1;p<5;p++)AddEntityCollideCallback("object_"+p, "AreaOven_2", "PutObjectOven_2", false, 0);
for(int p=1;p<5;p++)AddEntityCollideCallback("object_"+p, "AreaOven_3", "PutObjectOven_3", false, 0);
for(int p=1;p<5;p++)AddEntityCollideCallback("object_"+p, "AreaOven_4", "PutObjectOven_4", false, 0);

SetEntityConnectionStateChangeCallback("Lever_1", "CheckIngredients");
}
////////////RESET///////////////////////
void Reset()
{
if(GetEntitiesCollide("object_1", "AreaOven_1") == false)
{
SetLocalVarInt("oven_1_correct", 0);
AddLocalVarInt("All_4_Correct", -1);
}

if(GetEntitiesCollide("object_2", "AreaOven_2") == false)
{
SetLocalVarInt("oven_2_correct", 0);
AddLocalVarInt("All_4_Correct", -1);
}

if(GetEntitiesCollide("object_3", "AreaOven_3") == false)
{
SetLocalVarInt("oven_3_correct", 0);
AddLocalVarInt("All_4_Correct", -1);
}

if(GetEntitiesCollide("object_4", "AreaOven_4") == false)
{
SetLocalVarInt("oven_4_correct", 0);
AddLocalVarInt("All_4_Correct", -1);
}
}
////////////LEVER CHECK/////////////////
void CheckIngredients(string &in asEntity, int alState)
{
if(alState == 1)
{
//OVEN 1//
if(GetLocalVarInt("oven_1_correct") == 1)
{
AddLocalVarInt("All_4_Correct", 1);
}

if(GetLocalVarInt("oven_1_correct") == 0)
{
SetMessage("Messages", "IncorrectCombination", 0);
Reset();
return;
}

//OVEN 2//

if(GetLocalVarInt("oven_2_correct") == 1)
{
AddLocalVarInt("All_4_Correct", 1);
}

if(GetLocalVarInt("oven_2_correct") == 0)
{
SetMessage("Messages", "IncorrectCombination", 0);
Reset();
return;
}

//OVEN 3//

if(GetLocalVarInt("oven_3_correct") == 1)
{
AddLocalVarInt("All_4_Correct", 1);
}

if(GetLocalVarInt("oven_3_correct") == 0)
{
SetMessage("Messages", "IncorrectCombination", 0);
Reset();
return;
}

//OVEN 4//

if(GetLocalVarInt("oven_4_correct") == 1)
{
AddLocalVarInt("All_4_Correct", 1);
}

if(GetLocalVarInt("oven_4_correct") == 0)
{
SetMessage("Messages", "IncorrectCombination", 0);
Reset();
return;
}


if(GetLocalVarInt("All_4_Correct") == 4)
{
AddTimer("completedpuzzle", 1, "completedpuzzle");
}
}
}

////////////OVEN 1//////////////////////

void PutObjectOven_1(string &in asParent, string &in asChild, int alState)
{
if(alState == 1)
{
if(asParent == "object_1")
{
AddLocalVarInt("oven_1_correct", 1);
AddLocalVarInt("4_Items", 1);
}
if(asParent == "object_2")
{
AddLocalVarInt("oven_1_correct", 0);
AddLocalVarInt("4_Items", 1);
}
if(asParent == "object_3")
{
AddLocalVarInt("oven_1_correct", 0);
AddLocalVarInt("4_Items", 1);
}

if(asParent == "object_4")
{
AddLocalVarInt("oven_1_correct", 0);
AddLocalVarInt("4_Items", 1);
}
}
if(alState == -1)
{
if(asChild == "object_1")
{
AddLocalVarInt("oven_1_correct", 0);
AddLocalVarInt("4_Items", -1);
}
if(asParent == "object_2")
{
AddLocalVarInt("oven_1_correct", 0);
AddLocalVarInt("4_Items", -1);
}
if(asParent == "object_3")
{
AddLocalVarInt("oven_1_correct", 0);
AddLocalVarInt("4_Items", -1);
}

if(asParent == "object_4")
{
AddLocalVarInt("oven_1_correct", 0);
AddLocalVarInt("4_Items", -1);
}
}
}

//////////OVEN 2////////////////////

void PutObjectOven_2(string &in asParent, string &in asChild, int alState)
{
if(alState == 1)
{
if(asParent == "object_1")
{
AddLocalVarInt("oven_2_correct", 0);
AddLocalVarInt("4_Items", 1);
}
if(asParent == "object_2")
{
AddLocalVarInt("oven_2_correct", 1);
AddLocalVarInt("4_Items", 1);
}
if(asParent == "object_3")
{
AddLocalVarInt("oven_2_correct", 0);
AddLocalVarInt("4_Items", 1);
}

if(asParent == "object_4")
{
AddLocalVarInt("oven_2_correct", 0);
AddLocalVarInt("4_Items", 1);
}
}
if(alState == -1)
{
if(asParent == "object_1")
{
AddLocalVarInt("oven_2_correct", 0);
AddLocalVarInt("4_Items", -1);
}
if(asParent == "object_2")
{
AddLocalVarInt("oven_2_correct", 0);
AddLocalVarInt("4_Items", -1);
}
if(asParent == "object_3")
{
AddLocalVarInt("oven_2_correct", 0);
AddLocalVarInt("4_Items", -1);
}

if(asParent == "object_4")
{
AddLocalVarInt("oven_2_correct", 0);
AddLocalVarInt("4_Items", -1);
}
}
}

///////////OVEN 3///////////////////

void PutObjectOven_3(string &in asParent, string &in asChild, int alState)
{
if(alState == 1)
{
if(asParent == "object_1")
{
AddLocalVarInt("oven_3_correct", 0);
AddLocalVarInt("4_Items", 1);
}
if(asParent == "object_2")
{
AddLocalVarInt("oven_3_correct", 0);
AddLocalVarInt("4_Items", 1);
}
if(asParent == "object_3")
{
AddLocalVarInt("oven_3_correct", 1);
AddLocalVarInt("4_Items", 1);
}

if(asParent == "object_4")
{
AddLocalVarInt("oven_3_correct", 0);
AddLocalVarInt("4_Items", 1);
}
}
if(alState == -1)
{
if(asParent == "object_1")
{
AddLocalVarInt("oven_3_correct", 0);
AddLocalVarInt("4_Items", -1);
}
if(asParent == "object_2")
{
AddLocalVarInt("oven_3_correct", 0);
AddLocalVarInt("4_Items", -1);
}
if(asParent == "object_3")
{
AddLocalVarInt("oven_3_correct", 0);
AddLocalVarInt("4_Items", -1);
}

if(asParent == "object_4")
{
AddLocalVarInt("oven_3_correct", 0);
AddLocalVarInt("4_Items", -1);
}
}
}

///////////////OVEN 4////////////////////

void PutObjectOven_4(string &in asParent, string &in asChild, int alState)
{
if(alState == 1)
{
if(asParent == "object_1")
{
AddLocalVarInt("oven_4_correct", 0);
AddLocalVarInt("4_Items", 1);
}
if(asParent == "object_2")
{
AddLocalVarInt("oven_4_correct", 0);
AddLocalVarInt("4_Items", 1);
}
if(asParent == "object_3")
{
AddLocalVarInt("oven_4_correct", 0);
AddLocalVarInt("4_Items", 1);
}

if(asParent == "object_4")
{
AddLocalVarInt("oven_4_correct", 1);
AddLocalVarInt("4_Items", 1);
}
}
if(alState == -1)
{
if(asParent == "object_1")
{
AddLocalVarInt("oven_4_correct", 0);
AddLocalVarInt("4_Items", -1);
}
if(asParent == "object_2")
{
AddLocalVarInt("oven_4_correct", 0);
AddLocalVarInt("4_Items", -1);
}
if(asParent == "object_3")
{
AddLocalVarInt("oven_4_correct", 0);
AddLocalVarInt("4_Items", -1);
}

if(asParent == "object_4")
{
AddLocalVarInt("oven_4_correct", 0);
AddLocalVarInt("4_Items", -1);
}
}
}

void completedpuzzle(string &in asTimer)
{
SetSwingDoorLocked("extaction_oven_6", false, true);
SetMessage("Messages", "correctcombinationchemicals", 0);
}

CURRENTLY WORKING ON:
Final Light = 40%
Need of voice actors.
09-11-2012, 06:46 PM
Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#4
RE: Script help needed

You haven't declared the "4_items" local variable. Fix that and then see if it works. Tongue

RAISE YOUR DONGERS ヽ༼ຈل͜ຈ༽ノ
09-11-2012, 10:24 PM
Find
Steve Offline
Member

Posts: 178
Threads: 17
Joined: Jun 2012
Reputation: 7
#5
RE: Script help needed

sorry but where haven't I declared it? :|

CURRENTLY WORKING ON:
Final Light = 40%
Need of voice actors.
09-12-2012, 07:35 AM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#6
RE: Script help needed

I would recommend you use sticky areas for this.

Tutorials: From Noob to Pro
09-12-2012, 02:11 PM
Website Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#7
RE: Script help needed

That's actually a good idea!

Trying is the first step to success.
09-12-2012, 02:21 PM
Find
Steve Offline
Member

Posts: 178
Threads: 17
Joined: Jun 2012
Reputation: 7
#8
RE: Script help needed

okay now I tried it with the stickyarea's like YC suggested but now it doesnt'work when it should be solved.
this is my script
Spoiler below!

void OnStart()
{
SetLocalVarInt("oven_1_correct", 0);
SetLocalVarInt("oven_2_correct", 0);
SetLocalVarInt("oven_3_correct", 0);
SetLocalVarInt("oven_4_correct", 0);
SetLocalVarInt("All_4_Correct", 0);
SetEntityConnectionStateChangeCallback("Lever_1", "CheckIngredients");
}

////////////LEVER CHECK/////////////////
void CheckIngredients(string &in asEntity, int alState)
{
if(alState == 1)
{
//OVEN 1//
if(GetLocalVarInt("oven_1_correct") == 1)
{
AddLocalVarInt("All_4_Correct", 1);
}

if(GetLocalVarInt("oven_1_correct") == 0)
{
SetMessage("Messages", "IncorrectCombination", 0);
}

//OVEN 2//

if(GetLocalVarInt("oven_2_correct") == 1)
{
AddLocalVarInt("All_4_Correct", 1);
}

if(GetLocalVarInt("oven_2_correct") == 0)
{
SetMessage("Messages", "IncorrectCombination", 0);
}

//OVEN 3//

if(GetLocalVarInt("oven_3_correct") == 1)
{
AddLocalVarInt("All_4_Correct", 1);
}

if(GetLocalVarInt("oven_3_correct") == 0)
{
SetMessage("Messages", "IncorrectCombination", 0);
}

//OVEN 4//

if(GetLocalVarInt("oven_4_correct") == 1)
{
AddLocalVarInt("All_4_Correct", 1);
}

if(GetLocalVarInt("oven_4_correct") == 0)
{
SetMessage("Messages", "IncorrectCombination", 0);
}


if(GetLocalVarInt("All_4_Correct") == 4)
{
AddTimer("completedpuzzle", 1, "completedpuzzle");
}
}
}

////////////OVEN 1//////////////////////

void PutObjectOven_1(string &in asStickyArea, string &in asBodyName)
{
if(asBodyName == "object_1")
{
SetLocalVarInt("oven_1_correct", 1);
}
if(asBodyName == "object_2")
{
SetLocalVarInt("oven_1_correct", 0);
}
if(asBodyName == "object_3")
{
SetLocalVarInt("oven_1_correct", 0);
}

if(asBodyName == "object_4")
{
SetLocalVarInt("oven_1_correct", 0);
}
}
void DetachObjectOven_1(string &in asStickyArea, string &in asBodyName)
{
if(asStickyArea == "AreaOven_1")
{
SetLocalVarInt("oven_1_correct", 0);
}
}

//////////OVEN 2////////////////////

void PutObjectOven_2(string &in asStickyArea, string &in asBodyName)
{
if(asBodyName == "object_1")
{
SetLocalVarInt("oven_2_correct", 0);
}
if(asBodyName == "object_2")
{
SetLocalVarInt("oven_2_correct", 1);
}
if(asBodyName == "object_3")
{
SetLocalVarInt("oven_2_correct", 0);
}

if(asBodyName == "object_4")
{
SetLocalVarInt("oven_2_correct", 0);
}
}
void DetachObjectOven_2(string &in asStickyArea, string &in asBodyName)
{
if(asStickyArea == "AreaOven_2")
{
SetLocalVarInt("oven_2_correct", 0);
}
}

///////////OVEN 3///////////////////

void PutObjectOven_3(string &in asStickyArea, string &in asBodyName)
{
if(asBodyName == "object_1")
{
SetLocalVarInt("oven_3_correct", 0);
}
if(asBodyName == "object_2")
{
SetLocalVarInt("oven_3_correct", 0);
}
if(asBodyName == "object_3")
{
SetLocalVarInt("oven_3_correct", 1);
}

if(asBodyName == "object_4")
{
SetLocalVarInt("oven_3_correct", 0);
}
}
void DetachObjectOven_3(string &in asStickyArea, string &in asBodyName)
{
if(asStickyArea == "AreaOven_3")
{
SetLocalVarInt("oven_3_correct", 0);
}
}

///////////////OVEN 4////////////////////

void PutObjectOven_4(string &in asStickyArea, string &in asBodyName)
{
if(asBodyName == "object_1")
{
SetLocalVarInt("oven_4_correct", 0);
}
if(asBodyName == "object_2")
{
SetLocalVarInt("oven_4_correct", 0);
}
if(asBodyName == "object_3")
{
SetLocalVarInt("oven_4_correct", 0);
}

if(asBodyName == "object_4")
{
SetLocalVarInt("oven_4_correct", 1);
}
}

void DetachObjectOven_4(string &in asStickyArea, string &in asBodyName)
{
if(asStickyArea == "AreaOven_4")
{
SetLocalVarInt("oven_4_correct", 0);
}
}

void completedpuzzle(string &in asTimer)
{
SetSwingDoorLocked("extaction_oven_6", false, true);
SetMessage("Messages", "correctcombinationchemicals", 0);
}

CURRENTLY WORKING ON:
Final Light = 40%
Need of voice actors.
09-16-2012, 09:18 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#9
RE: Script help needed

Oh... yea i see we need something that makes "All_4_Correct" drop to 0 again if the combination is wrong...

Trying is the first step to success.
09-16-2012, 09:29 PM
Find
Steve Offline
Member

Posts: 178
Threads: 17
Joined: Jun 2012
Reputation: 7
#10
RE: Script help needed

If I'm correct You mean something like this:
although that doesn't fix it.
Spoiler below!

void OnStart()
{
SetLocalVarInt("oven_1_correct", 0);
SetLocalVarInt("oven_2_correct", 0);
SetLocalVarInt("oven_3_correct", 0);
SetLocalVarInt("oven_4_correct", 0);
SetLocalVarInt("All_4_Correct", 0);
SetEntityConnectionStateChangeCallback("Lever_1", "CheckIngredients");
}

////////////LEVER CHECK/////////////////
void CheckIngredients(string &in asEntity, int alState)
{
if(alState == 1)
{
//OVEN 1//
if(GetLocalVarInt("oven_1_correct") == 1)
{
AddLocalVarInt("All_4_Correct", 1);
}

if(GetLocalVarInt("oven_1_correct") == 0)
{
SetMessage("Messages", "IncorrectCombination", 0);
}

//OVEN 2//

if(GetLocalVarInt("oven_2_correct") == 1)
{
AddLocalVarInt("All_4_Correct", 1);
}

if(GetLocalVarInt("oven_2_correct") == 0)
{
SetMessage("Messages", "IncorrectCombination", 0);
}

//OVEN 3//

if(GetLocalVarInt("oven_3_correct") == 1)
{
AddLocalVarInt("All_4_Correct", 1);
}

if(GetLocalVarInt("oven_3_correct") == 0)
{
SetMessage("Messages", "IncorrectCombination", 0);
}

//OVEN 4//

if(GetLocalVarInt("oven_4_correct") == 1)
{
AddLocalVarInt("All_4_Correct", 1);
}

if(GetLocalVarInt("oven_4_correct") == 0)
{
SetMessage("Messages", "IncorrectCombination", 0);
}
if(GetLocalVarInt("All_4_Correct") > 4)
{
SetMessage("Messages", "IncorrectCombination", 0);
SetLocalVarInt("All_4_Correct", 0);
}

if(GetLocalVarInt("All_4_Correct") == 4)
{
AddTimer("completedpuzzle", 1, "completedpuzzle");
}
}
}

////////////OVEN 1//////////////////////

void PutObjectOven_1(string &in asStickyArea, string &in asBodyName)
{
if(asBodyName == "object_1")
{
SetLocalVarInt("oven_1_correct", 1);
}
if(asBodyName == "object_2")
{
SetLocalVarInt("oven_1_correct", 0);
}
if(asBodyName == "object_3")
{
SetLocalVarInt("oven_1_correct", 0);
}

if(asBodyName == "object_4")
{
SetLocalVarInt("oven_1_correct", 0);
}
}
void DetachObjectOven_1(string &in asStickyArea, string &in asBodyName)
{
if(asStickyArea == "AreaOven_1")
{
SetLocalVarInt("oven_1_correct", 0);
}
}

//////////OVEN 2////////////////////

void PutObjectOven_2(string &in asStickyArea, string &in asBodyName)
{
if(asBodyName == "object_1")
{
SetLocalVarInt("oven_2_correct", 0);
}
if(asBodyName == "object_2")
{
SetLocalVarInt("oven_2_correct", 1);
}
if(asBodyName == "object_3")
{
SetLocalVarInt("oven_2_correct", 0);
}

if(asBodyName == "object_4")
{
SetLocalVarInt("oven_2_correct", 0);
}
}
void DetachObjectOven_2(string &in asStickyArea, string &in asBodyName)
{
if(asStickyArea == "AreaOven_2")
{
SetLocalVarInt("oven_2_correct", 0);
}
}

///////////OVEN 3///////////////////

void PutObjectOven_3(string &in asStickyArea, string &in asBodyName)
{
if(asBodyName == "object_1")
{
SetLocalVarInt("oven_3_correct", 0);
}
if(asBodyName == "object_2")
{
SetLocalVarInt("oven_3_correct", 0);
}
if(asBodyName == "object_3")
{
SetLocalVarInt("oven_3_correct", 1);
}

if(asBodyName == "object_4")
{
SetLocalVarInt("oven_3_correct", 0);
}
}
void DetachObjectOven_3(string &in asStickyArea, string &in asBodyName)
{
if(asStickyArea == "AreaOven_3")
{
SetLocalVarInt("oven_3_correct", 0);
}
}

///////////////OVEN 4////////////////////

void PutObjectOven_4(string &in asStickyArea, string &in asBodyName)
{
if(asBodyName == "object_1")
{
SetLocalVarInt("oven_4_correct", 0);
}
if(asBodyName == "object_2")
{
SetLocalVarInt("oven_4_correct", 0);
}
if(asBodyName == "object_3")
{
SetLocalVarInt("oven_4_correct", 0);
}

if(asBodyName == "object_4")
{
SetLocalVarInt("oven_4_correct", 1);
}
}

void DetachObjectOven_4(string &in asStickyArea, string &in asBodyName)
{
if(asStickyArea == "AreaOven_4")
{
SetLocalVarInt("oven_4_correct", 0);
}
}

void completedpuzzle(string &in asTimer)
{
SetSwingDoorLocked("extaction_oven_6", false, true);
SetMessage("Messages", "correctcombinationchemicals", 0);
}

CURRENTLY WORKING ON:
Final Light = 40%
Need of voice actors.
09-19-2012, 05:32 PM
Find




Users browsing this thread: 2 Guest(s)