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
Help, again... :P
Zaapeer Offline
Junior Member

Posts: 32
Threads: 9
Joined: Dec 2011
Reputation: 0
#1
Help, again... :P

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
10-27-2012, 11:50 AM
Find
ZodiaC Offline
Member

Posts: 120
Threads: 8
Joined: Oct 2012
Reputation: 2
#2
RE: Help, again... :P

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

[Image: 2H1Mc.jpg]
10-27-2012, 12:15 PM
Find
i3670 Offline
Posting Freak

Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation: 36
#3
RE: Help, again... :P

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.

"What you think is irrelevant" - A character of our time

A Christmas Hunt
(This post was last modified: 10-27-2012, 12:53 PM by i3670.)
10-27-2012, 12:49 PM
Find
ZodiaC Offline
Member

Posts: 120
Threads: 8
Joined: Oct 2012
Reputation: 2
#4
RE: Help, again... :P

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

}
}
}

[Image: 2H1Mc.jpg]
10-27-2012, 12:57 PM
Find
Zaapeer Offline
Junior Member

Posts: 32
Threads: 9
Joined: Dec 2011
Reputation: 0
#5
RE: Help, again... :P

(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.
10-27-2012, 03:30 PM
Find
i3670 Offline
Posting Freak

Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation: 36
#6
RE: Help, again... :P

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.

"What you think is irrelevant" - A character of our time

A Christmas Hunt
10-27-2012, 03:44 PM
Find
Zaapeer Offline
Junior Member

Posts: 32
Threads: 9
Joined: Dec 2011
Reputation: 0
#7
RE: Help, again... :P

(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
10-27-2012, 04:24 PM
Find
i3670 Offline
Posting Freak

Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation: 36
#8
RE: Help, again... :P

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)
{

}
}
}

"What you think is irrelevant" - A character of our time

A Christmas Hunt
(This post was last modified: 10-27-2012, 05:20 PM by i3670.)
10-27-2012, 05:12 PM
Find
Zaapeer Offline
Junior Member

Posts: 32
Threads: 9
Joined: Dec 2011
Reputation: 0
#9
RE: Help, again... :P

(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
10-27-2012, 08:00 PM
Find
i3670 Offline
Posting Freak

Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation: 36
#10
RE: Help, again... :P

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

"What you think is irrelevant" - A character of our time

A Christmas Hunt
10-27-2012, 08:05 PM
Find




Users browsing this thread: 3 Guest(s)