Frictional Games Forum (read-only)
Help, again... :P - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Help, again... :P (/thread-18952.html)



Help, again... :P - Zaapeer - 10-27-2012

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 Smile


RE: Help, again... :P - ZodiaC - 10-27-2012

how many coals are there going to be in the room?


RE: Help, again... :P - i3670 - 10-27-2012

void OnStart()
{

for(int i=1;i<=5;i++){
AddEntityCollideCallback("Coal_"+i+"", "CoalArea", "CoalFunc", false, 1);
}

}

void CoalFunc(string &in asParent, string &in asChild, int alState)
{

AddLocalVarInt("Var_coals", 1);
CoalLocal();

}

void CoalLocal()
{
if(GetLocalVarInt("Var_coals") == 2)
{
SetEntityConnectionStateChangeCallback("LEVERNAME", "func_furnace");
}
}

void func_furnace(string &in asEntity, int alState)
{
if (alState == 1)
{
whatever happends when the lever is pulled and 2 coals are inside
}
}

I think that should work.


RE: Help, again... :P - ZodiaC - 10-27-2012

(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 Smile
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);

}
}
}


RE: Help, again... :P - Zaapeer - 10-27-2012

(10-27-2012, 12:49 PM)i3670 Wrote: void OnStart()
{

for(int i=1;i<=5;i++){
AddEntityCollideCallback("Coal_"+i+"", "CoalArea", "CoalFunc", false, 1);
}

}

void CoalFunc(string &in asParent, string &in asChild, int alState)
{

AddLocalVarInt("Var_coals", 1);
CoalLocal();

}

void CoalLocal()
{
if(GetLocalVarInt("Var_coals") == 2)
{
SetEntityConnectionStateChangeCallback("LEVERNAME", "func_furnace");
}
}

void func_furnace(string &in asEntity, int alState)
{
if (alState == 1)
{
whatever happends when the lever is pulled and 2 coals are inside
}
}

I think that should work.


Thank you, that worked! Smile I just changed some stuff, for exampel alState. I changed it to -1 so that the machine will start working when you pull the lever down instead of up Smile I have another question though. Under void Onstart() I use "SetPropEffectActive("Coal_"+i+"", false, false);", wich makes the coal black. How do I make it so that when I pull the lever, only the coal inside it starts glowing? "SetPropEffectActive("Coal_"+i+"", true, false);" is the command to make coal glow.


RE: Help, again... :P - i3670 - 10-27-2012

hmm, i think that if you were to place an area inside the furnace and then by using if-statements to see which coals are inside and then set them alight.


RE: Help, again... :P - Zaapeer - 10-27-2012

(10-27-2012, 03:44 PM)i3670 Wrote: hmm, i think that if you were to place an area inside the furnace and then by using if-statements to see which coals are inside and then set them alight.
How do I check wich are inside? Tongue


RE: Help, again... :P - i3670 - 10-27-2012

Try this. Set the script area inside the furnace inactive and when you pull the lever it activates the area.

You then have another AddEntityCollideCallback for the area inside the furnace with all the coals in the map.

I believe this will result in that only the coals inside the furnace changes.

I'll try coming up with a script.

void OnStart()
{
for(int i=1;i<=5;i++){
AddEntityCollideCallback("Coal_"+i+"", "FurnaceArea", "Furnace", false, 0);
}

void func_furnace(string &in asEntity, int alState)
{
if (alState == 1)
{
SetEntityActive("FurnaceArea", true);
}
}

void Furnace(string &in asParent, string &in asChild, int alState)
{
{
if (alState == 1)
{
for(int i=1;i<=5;i++){
SetPropEffectActive("Coal_"+i+"", true, false);
}
}
if(alState == -1)
{

}
}
}


RE: Help, again... :P - Zaapeer - 10-27-2012

(10-27-2012, 05:12 PM)i3670 Wrote: Try this. Set the script area inside the furnace inactive and when you pull the lever it activates the area.

You then have another AddEntityCollideCallback for the area inside the furnace with all the coals in the map.

I believe this will result in that only the coals inside the furnace changes.

I'll try coming up with a script.

void OnStart()
{
for(int i=1;i<=5;i++){
AddEntityCollideCallback("Coal_"+i+"", "FurnaceArea", "Furnace", false, 0);
}

void func_furnace(string &in asEntity, int alState)
{
if (alState == 1)
{
SetEntityActive("FurnaceArea", true);
}
}

void Furnace(string &in asParent, string &in asChild, int alState)
{
{
if (alState == 1)
{
for(int i=1;i<=5;i++){
SetPropEffectActive("Coal_"+i+"", true, false);
}
}
if(alState == -1)
{

}
}
}


That didn't work for me.. Sad


RE: Help, again... :P - i3670 - 10-27-2012

Did you get an error or did it just not work?