Zaapeer
Junior Member
Posts: 32
Threads: 9
Joined: Dec 2011
Reputation:
0
|
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
|
|
10-27-2012, 11:50 AM |
|
ZodiaC
Member
Posts: 120
Threads: 8
Joined: Oct 2012
Reputation:
2
|
RE: Help, again... :P
how many coals are there going to be in the room?
|
|
10-27-2012, 12:15 PM |
|
i3670
Posting Freak
Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation:
36
|
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.
(This post was last modified: 10-27-2012, 12:53 PM by i3670.)
|
|
10-27-2012, 12:49 PM |
|
ZodiaC
Member
Posts: 120
Threads: 8
Joined: Oct 2012
Reputation:
2
|
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 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);
}
}
}
|
|
10-27-2012, 12:57 PM |
|
Zaapeer
Junior Member
Posts: 32
Threads: 9
Joined: Dec 2011
Reputation:
0
|
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! 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 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 |
|
i3670
Posting Freak
Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation:
36
|
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.
|
|
10-27-2012, 03:44 PM |
|
Zaapeer
Junior Member
Posts: 32
Threads: 9
Joined: Dec 2011
Reputation:
0
|
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?
|
|
10-27-2012, 04:24 PM |
|
i3670
Posting Freak
Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation:
36
|
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)
{
}
}
}
(This post was last modified: 10-27-2012, 05:20 PM by i3670.)
|
|
10-27-2012, 05:12 PM |
|
Zaapeer
Junior Member
Posts: 32
Threads: 9
Joined: Dec 2011
Reputation:
0
|
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..
|
|
10-27-2012, 08:00 PM |
|
i3670
Posting Freak
Posts: 1,308
Threads: 74
Joined: Oct 2011
Reputation:
36
|
RE: Help, again... :P
Did you get an error or did it just not work?
|
|
10-27-2012, 08:05 PM |
|
|