FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
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.