help with (if) statements
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
-
- Posts: 340
- Joined: Wed Jan 24, 2007 8:54 pm
help with (if) statements
I need a combination of 3 switches to raise an elevator while each performs a function of its own.
all three switches raise support beams for the elevator near where each particular switch is located but its not until all three switches are presed that the elevator will function.
now because the switches are all on the elevator I don't want it set up to where one switch has to be pressed for another to function. I don't want any guess work for the player on this one so whatever button they happen to run to first should perform its function whether or not the other two have been pressed. It would only be the actual climbing of the elevator that would be dependent on all three switches having been pressed.
Problem is I have a low understanding of ACS (if) statements and variables and have always been best at design rather than programing although I do have many of the ACS basics understood.
all three switches raise support beams for the elevator near where each particular switch is located but its not until all three switches are presed that the elevator will function.
now because the switches are all on the elevator I don't want it set up to where one switch has to be pressed for another to function. I don't want any guess work for the player on this one so whatever button they happen to run to first should perform its function whether or not the other two have been pressed. It would only be the actual climbing of the elevator that would be dependent on all three switches having been pressed.
Problem is I have a low understanding of ACS (if) statements and variables and have always been best at design rather than programing although I do have many of the ACS basics understood.
if you got it so you can only press each switch once you can just have a map var then add to it and then check it.
example:
example:
Code: Select all
int sw = 0;
script 1 (void)//swtich script
{
//beam stuff
sw++;
if(sw == 3)
{
//elevator stuff
}
}
-
- Posts: 340
- Joined: Wed Jan 24, 2007 8:54 pm
int sw = 0;
script 1 (void)//swtich script
{
//beam stuff
sw++;
if(sw == 3)
{
//elevator stuff
}
Yes each switch would be a one time hit, and there is no 4th switch as I forgot to mention. So in other words the third switch pressed lowers the last support beam, then raises the elevator.
Just to get your script understood I use it exactly as you have it but substitute //beam stuff, with the individual rise sectors for the support beams and //elevator stuff with the lines I have in ACS that operate my lift?
script 1 (void)//swtich script
{
//beam stuff
sw++;
if(sw == 3)
{
//elevator stuff
}
Yes each switch would be a one time hit, and there is no 4th switch as I forgot to mention. So in other words the third switch pressed lowers the last support beam, then raises the elevator.
Just to get your script understood I use it exactly as you have it but substitute //beam stuff, with the individual rise sectors for the support beams and //elevator stuff with the lines I have in ACS that operate my lift?
-
- Posts: 340
- Joined: Wed Jan 24, 2007 8:54 pm
Isle wrote:yeah
Ok its working but a problem I expected is occurring. Maybe you know what I'm doing wrong.
I need to individualize each button. This is how the script is set now......
Each switch in the game is set up with H script execute (80)
script 1 (void)//swtich script
{
Floor_RaiseByValue (10,5,319);
Ceiling_LowerByValue (11,5,116);
Ceiling_LowerByValue (12,5,116);
sw++;
if(sw == 3)
{
Floor_LowerByValue (10,12,11610);
Ceiling_LowerByValue (10,12,11610);
FloorAndCeiling_RaiseByValue (1,4,3870);
FloorAndCeiling_LowerByValue (9,12,11610);
delay(100);
Thing_Spawn (1,T_ZOMBIE,0,0);
delay(100);
Thing_Spawn (2,T_ZOMBIE,0,0);
delay(100);
Thing_Spawn (1,T_ZOMBIE,0,0);
Thing_Spawn (2,T_ZOMBIE,0,0);
delay(100);
Thing_Spawn (1,T_ZOMBIE,0,0);
Thing_Spawn (2,T_ZOMBIE,0,0);
delay(100);
Thing_Spawn (1,T_IMP,0,0);
Thing_Spawn (2,T_IMP,0,0);
}
}
however each switch performs all three actions....
Floor_RaiseByValue (10,5,319);
Ceiling_LowerByValue (11,5,116);
Ceiling_LowerByValue (12,5,116);
I need each switch to do one of these at a time before raising the lift, not all three each time the switch is hit.
you could make the switches pass a varible to know what one was switched.
change the first part to
then put the tag # thats suposed to move by the switch in the third arg of the line special.
change the first part to
Code: Select all
script 1 (int tag)
{
if(tag == 10)
Floor_RaiseByValue (10,5,319);
else
Ceiling_LowerByValue (tag,5,116);
sw++;
//etc
-
- Posts: 340
- Joined: Wed Jan 24, 2007 8:54 pm
I'm not sure what you mean, could you show me an example script? Maybe its my inexperience with scripts of this kind but I just don't get it.Isle wrote:you could make the switches pass a varible to know what one was switched.
change the first part tothen put the tag # thats suposed to move by the switch in the third arg of the line special.Code: Select all
script 1 (int tag) { if(tag == 10) Floor_RaiseByValue (10,5,319); else Ceiling_LowerByValue (tag,5,116); sw++; //etc
ok, the whole script would be
and for the switch line speclals (in the map, not the acs script) one needs to be:
ACS_EXECUTE(1, 0, 10, 0 ,0) for the floor tagged 10 one
ACS_EXECUTE(1, 0, 11, 0 ,0) for the celing tagged 11 one and
ACS_EXECUTE(1, 0, 12, 0 ,0) for the celing tagged 12 one
Code: Select all
script 1 (int tag)
{
if(tag == 10)
Floor_RaiseByValue (10,5,319);
else
Ceiling_LowerByValue (tag,5,116);
sw++;
if(sw == 3)
{
Floor_LowerByValue (10,12,11610);
Ceiling_LowerByValue (10,12,11610);
FloorAndCeiling_RaiseByValue (1,4,3870);
FloorAndCeiling_LowerByValue (9,12,11610);
delay(100);
Thing_Spawn (1,T_ZOMBIE,0,0);
delay(100);
Thing_Spawn (2,T_ZOMBIE,0,0);
delay(100);
Thing_Spawn (1,T_ZOMBIE,0,0);
Thing_Spawn (2,T_ZOMBIE,0,0);
delay(100);
Thing_Spawn (1,T_ZOMBIE,0,0);
Thing_Spawn (2,T_ZOMBIE,0,0);
delay(100);
Thing_Spawn (1,T_IMP,0,0);
Thing_Spawn (2,T_IMP,0,0);
}
}
ACS_EXECUTE(1, 0, 10, 0 ,0) for the floor tagged 10 one
ACS_EXECUTE(1, 0, 11, 0 ,0) for the celing tagged 11 one and
ACS_EXECUTE(1, 0, 12, 0 ,0) for the celing tagged 12 one
-
- Posts: 340
- Joined: Wed Jan 24, 2007 8:54 pm
That works, I have some work to do with delays and height values but its doing what I want it to, I don't understand parts of the script, but as long as the basic functionality of the script does what its supposed to the rest I can work with.
Part of what I was confused about before was whether or not to set the arguments in ACS or in the editor, now I'm good, well I think unless the script has some unforeseen lasting effect on the sectors it moved that would prevent further changes in speed or height, I doubt it but I'll post back here if I have another problem.
Thanks
Part of what I was confused about before was whether or not to set the arguments in ACS or in the editor, now I'm good, well I think unless the script has some unforeseen lasting effect on the sectors it moved that would prevent further changes in speed or height, I doubt it but I'll post back here if I have another problem.
Thanks
No, once the sectors stop moving, they are available to be moved again.
<randominfo>
Also, if you need an effect to occur when a moving floor stops, you can use TagWait(sectortag), which will wait until the sector with the specified tag stops moving before continuing, which could be handy for, say, timing an entrance door to open at the end of the elevator ride. </randominfo>
<randominfo>
Also, if you need an effect to occur when a moving floor stops, you can use TagWait(sectortag), which will wait until the sector with the specified tag stops moving before continuing, which could be handy for, say, timing an entrance door to open at the end of the elevator ride. </randominfo>