(10-27-2012, 11:50 AM)Zaapeer Wrote: Okay so I have a problem. First off, I really appreciate the help i got in my last thread, but I I didn't really understand anything. So okay, here's what I want to do:
I have a machine that the player is supposed to start. In order to start it the player has to fill it with coal, two pieces to be excact. So I put an area in the machine were the coal is put, called "CoalArea". So this is the script I have for tha game to notice that there is coal put in the machine:
void OnStart()
{
if(GetLocalVarInt("Var_coals") == 2)
{
//Whatever is going to happen when the coal is put in the machine
}
AddEntityCollideCallback("Coal_1", "CoalArea", "CoalFunc", true, 1);
}
void CoalFunc(string &in asParent, string &in asChild, int alState)
{
AddLocalVarInt("Var_coals", 1);
}
Now there are several pices of coal that you can put in the furnace. I want to make it so that it doesn't matter wich piece of coal you put in the furnace (since the coal pieces have different names). As long as there is two pieces of coal in the furnace the machine should be able to start. In order to start it, you pull a lever. How do I make it so that the lever only does something when there is two pieces of coal in the furnace? And how can I write so that the "CoalFunc" works with all the pieces of coal?
Please help!
Thank you 
void OnStart ()
{
SetLocalVarInt("Var_coals", 0);
for(int p=1;p<100;p++) AddEntityCollideCallback("coal_"+p, "CoalArea", "Coal_Enter", true, 1);
SetEntityConnectionStateChangeCallback("lever", "lever_puled");
}
void Coal_Enter(string &in asParent, string &in asChild, int alState)
{
AddLocalVarInt("Var_coals", 1);
}
void lever_puled(string &in asEntity, int alState)
{
if (alState==1)
{
if(GetLocalVarInt("Var_coals")<2)
{
//type a message for not enough coals
}
else
{
SetLeverStuckState("lever", 1, true);
}
}
}