Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
puzzle help needed
FlawlessHappiness Offline
Posting Freak

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

There is.... Ok i will give it a try... give me a couple of minutes...

EDIT: OK I'm done.

Ok so assuming that you already know how to display messages, then here is the script.
Tell me if you need explanation.

I did not make the "Not enough ingredients"-part. Instead it just says "Incorrect combination". Because that is technically also an incorrect combination.

object_1 = first object
object_2 = second object
object_3 = third object
object_4 = fourth object

Lever_1 = lever. Pull it UP to trigger function

AreaOven_1 = A script area in first oven. It has "ItemInteraction" checked
AreaOven_2 = A script area in second oven. It has "ItemInteraction" checked
AreaOven_3 = A script area in third oven. It has "ItemInteraction" checked
AreaOven_4 = A script area in fourth oven. It has "ItemInteraction" checked
Spoiler below!


That took some time

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++)AddUseItemCallback("", "object_"+p, "AreaOven_1", "PutObjectOven_1", false, 0);
for(int p=1;p<5;p++)AddUseItemCallback("", "object_"+p, "AreaOven_2", "PutObjectOven_2", false, 0);
for(int p=1;p<5;p++)AddUseItemCallback("", "object_"+p, "AreaOven_3", "PutObjectOven_3", false, 0);
for(int p=1;p<5;p++)AddUseItemCallback("", "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);
AddTimer("Redo_timer", 1, "Redo_timer");
return;
}

//OVEN 2//

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

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

//OVEN 3//

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

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

//OVEN 4//

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

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

if(GetLocalVarInt("All_4_Correct") > 4) //NOT COMPLETELY SURE ABOUT THAT SYMBOL: >
{
SetMessage("Messages", "IncorrectCombination", 0);
AddTimer("Redo_timer", 1, "Redo_timer");
}

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

////////////REDO TIMER//////////////////

void Redo_timer(string &in asTimer)
{
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++)SetEntityActive("object_1_oven_"+p, false);
for(int p=1;p<5;p++)SetEntityActive("object_2_oven_"+p, false);
for(int p=1;p<5;p++)SetEntityActive("object_3_oven_"+p, false);
for(int p=1;p<5;p++)SetEntityActive("object_4_oven_"+p, false);

SetEntityActive("AreaOven_1", true);
SetEntityActive("AreaOven_2", true);
SetEntityActive("AreaOven_3", true);
SetEntityActive("AreaOven_4", true);

RemoveItem("object_1");
RemoveItem("object_2");
RemoveItem("object_3");
RemoveItem("object_4");

GiveItem("object_1", "Puzzle", "object_1", "object_1.tga", 1);
GiveItem("object_2", "Puzzle", "object_2", "object_2.tga", 1);
GiveItem("object_3", "Puzzle", "object_3", "object_3.tga", 1);
GiveItem("object_4", "Puzzle", "object_4", "object_4.tga", 1);
}

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

void PutObjectOven_1(string &in asItem, string &in asEntity)
{
if(asItem == "object_1")
{
RemoveItem("object_1");
SetEntityActive("object_1_oven_1", true);
SetLocalVarInt("oven_1_correct", 1);
SetEntityActive("AreaOven_1", false);
AddLocalVarInt("4_Items", 1);
}

if(asItem == "object_2")
{
RemoveItem("object_2");
SetEntityActive("object_2_oven_1", true);
SetLocalVarInt("oven_1_correct", 0);
SetEntityActive("AreaOven_1", false);
AddLocalVarInt("4_Items", 1);
}

if(asItem == "object_3")
{
RemoveItem("object_3");
SetEntityActive("object_3_oven_1", true);
SetLocalVarInt("oven_1_correct", 0);
SetEntityActive("AreaOven_1", false);
AddLocalVarInt("4_Items", 1);
}

if(asItem == object_4)
{
RemoveItem("object_4");
SetEntityActive("object_4_oven_1", true);
SetLocalVarInt("oven_1_correct", 0);
SetEntityActive("AreaOven_1", false);
AddLocalVarInt("4_Items", 1);
}
}

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

void PutObjectOven_2(string &in asItem, string &in asEntity)
{
if(asItem == "object_1")
{
RemoveItem("object_1");
SetEntityActive("object_1_oven_2", true);
SetLocalVarInt("oven_2_correct", 0);
SetEntityActive("AreaOven_2", false);
AddLocalVarInt("4_Items", 1);
}

if(asItem == "object_2")
{
RemoveItem("object_2");
SetEntityActive("object_2_oven_2", true);
SetLocalVarInt("oven_2_correct", 1);
SetEntityActive("AreaOven_2", false);
AddLocalVarInt("4_Items", 1);
}

if(asItem == "object_3")
{
RemoveItem("object_3");
SetEntityActive("object_3_oven_2", true);
SetLocalVarInt("oven_2_correct", 0);
SetEntityActive("AreaOven_2", false);
AddLocalVarInt("4_Items", 1);
}

if(asItem == object_4)
{
RemoveItem("object_4");
SetEntityActive("object_4_oven_2", true);
SetLocalVarInt("oven_2_correct", 0);
SetEntityActive("AreaOven_2", false);
AddLocalVarInt("4_Items", 1);
}
}

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

void PutObjectOven_3(string &in asItem, string &in asEntity)
{
if(asItem == "object_1")
{
RemoveItem("object_1");
SetEntityActive("object_1_oven_3", true);
SetLocalVarInt("oven_3_correct", 0);
SetEntityActive("AreaOven_3", false);
AddLocalVarInt("4_Items", 1);
}

if(asItem == "object_2")
{
RemoveItem("object_2");
SetEntityActive("object_2_oven_3", true);
SetLocalVarInt("oven_3_correct", 0);
SetEntityActive("AreaOven_3", false);
AddLocalVarInt("4_Items", 1);
}

if(asItem == "object_3")
{
RemoveItem("object_3");
SetEntityActive("object_3_oven_3", true);
SetLocalVarInt("oven_3_correct", 1);
SetEntityActive("AreaOven_3", false);
AddLocalVarInt("4_Items", 1);
}

if(asItem == object_4)
{
RemoveItem("object_4");
SetEntityActive("object_4_oven_3", true);
SetLocalVarInt("oven_3_correct", 0);
SetEntityActive("AreaOven_3", false);
AddLocalVarInt("4_Items", 1);
}
}

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

void PutObjectOven_4(string &in asItem, string &in asEntity)
{
if(asItem == "object_1")
{
RemoveItem("object_1");
SetEntityActive("object_1_oven_4", true);
SetLocalVarInt("oven_4_correct", 0);
SetEntityActive("AreaOven_4", false);
AddLocalVarInt("4_Items", 1);
}

if(asItem == "object_2")
{
RemoveItem("object_2");
SetEntityActive("object_2_oven_4", true);
SetLocalVarInt("oven_4_correct", 0);
SetEntityActive("AreaOven_4", false);
AddLocalVarInt("4_Items", 1);
}

if(asItem == "object_3")
{
RemoveItem("object_3");
SetEntityActive("object_3_oven_4", true);
SetLocalVarInt("oven_4_correct", 0);
SetEntityActive("AreaOven_4", false);
AddLocalVarInt("4_Items", 1);
}

if(asItem == object_4)
{
RemoveItem("object_4");
SetEntityActive("object_4_oven_4", true);
SetLocalVarInt("oven_4_correct", 0);
SetEntityActive("AreaOven_4", false);
AddLocalVarInt("4_Items", 1);
}
}



Trying is the first step to success.
(This post was last modified: 09-08-2012, 06:12 PM by FlawlessHappiness.)
09-08-2012, 05:34 PM
Find


Messages In This Thread
puzzle help needed - by Steve - 09-08-2012, 12:19 PM
RE: puzzle help needed - by Theforgot3n1 - 09-08-2012, 01:45 PM
RE: puzzle help needed - by Steve - 09-08-2012, 05:00 PM
RE: puzzle help needed - by Dutton - 09-08-2012, 05:07 PM
RE: puzzle help needed - by Steve - 09-08-2012, 05:28 PM
RE: puzzle help needed - by FlawlessHappiness - 09-08-2012, 05:34 PM
RE: puzzle help needed - by Steve - 09-08-2012, 06:37 PM
RE: puzzle help needed - by FlawlessHappiness - 09-08-2012, 06:39 PM
RE: puzzle help needed - by Steve - 09-08-2012, 06:41 PM
RE: puzzle help needed - by FlawlessHappiness - 09-08-2012, 06:47 PM
RE: puzzle help needed - by Steve - 09-08-2012, 06:50 PM
RE: puzzle help needed - by FlawlessHappiness - 09-08-2012, 06:52 PM
RE: puzzle help needed - by Steve - 09-08-2012, 06:56 PM
RE: puzzle help needed - by Steve - 09-09-2012, 11:34 AM
RE: puzzle help needed - by FlawlessHappiness - 09-09-2012, 11:39 AM
RE: puzzle help needed - by Steve - 09-09-2012, 01:32 PM
RE: puzzle help needed - by FlawlessHappiness - 09-09-2012, 03:33 PM
RE: puzzle help needed - by Steve - 09-09-2012, 05:27 PM
RE: puzzle help needed - by FlawlessHappiness - 09-09-2012, 06:33 PM
RE: puzzle help needed - by Steve - 09-09-2012, 08:20 PM
RE: puzzle help needed - by FlawlessHappiness - 09-10-2012, 06:59 AM



Users browsing this thread: 2 Guest(s)