Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Evaine

ACS Question

Recommended Posts

This is my first time using a forum, posting a thread, etc. I'm not great at this and my English still needs a lot of work, so I'm apologizing in advance if I do anything that an expert forum user would consider "dumb" or "noob" or whatever. Please go easy on me, if all possible.

Now that I've gotten that out of the way...
I wanted to know if there were a way to check for values of floors, ceilings, etc via Action Code Script. Like I could run a script that would see if 3 floor heights were equal to 64 or something. If I'm totally retarded and this isn't possible, please feel free to crush my dreams.

Thanks!

~Evaine

Share this post


Link to post

Thanks for you help! I'm pretty sure this is what I need, but I just can't seem to get it working. I need the game to check to see if 4 sectors' floor heights are the same, then if so, proceed to execute a Floor_LowerToValue command.
I'm sure I use an UNTIL loop, right? I've never tried ACS this complicated before.

Share this post


Link to post

Hmm, as I said, I'm not familiar with these commands. It might be better if you post the actual ACS script you've written, or even better, post a link to your map with the ACS script included. I may not be able to help you directly, but I'm sure someone here will.

Share this post


Link to post

Okay, here's what I have. I know for a fact this is wrong, because it's not compiling, but I've never tried something this complex before, so I'm not sure exactly how to do this.

SCRIPT 80 OPEN //イベントの要件を確認します
{
    until(
        (GetSectorFloorZ (101,0,0) = 152);
        (GetSectorFloorZ (102,0,0) = 152);
        (GetSectorFloorZ (103,0,0) = 152);
        (GetSectorFloorZ (104,0,0) = 152);
        )
        Floor_MoveToValue(11,6,144);
}
What I'm trying to make happen, is if all 4 floor heights are the same, then an action is executed. I'm not really sure how to go about doing this. I've never used any statement other than "if". I'm not really sure how "until" works, and it's hard for me to grasp it by reading the wiki.

Share this post


Link to post

I'm not sure what wiki you're reading, but the syntax certainly isn't even close to that.
This seems to be what you want:

SCRIPT 80 OPEN // As a note, I have no idea if ACC will properly handle non-ansi encoding
{
	while(GetSectorFloorZ (101,0,0) != 152.0 || // Remember, fixed point values need to be identified as such.
		GetSectorFloorZ (102,0,0) != 152.0 ||
		GetSectorFloorZ (103,0,0) != 152.0 ||
		GetSectorFloorZ (104,0,0) != 152.0)
	{
		delay(1); // Not all floors are at 152.0. Delay and loop again.
	}
	
	// All floors at 152.0. Lower other floor.
	Floor_MoveToValue(11, 6, 144, 0);
	
	// Script ends forever.
}
Or the inverse using until instead of while:
SCRIPT 80 OPEN // As a note, I have no idea if ACC will properly handle non-ansi encoding
{
	until(GetSectorFloorZ (101,0,0) == 152.0 && // Remember, fixed point values need to be identified as such.
		GetSectorFloorZ (102,0,0) == 152.0 &&
		GetSectorFloorZ (103,0,0) == 152.0 &&
		GetSectorFloorZ (104,0,0) == 152.0)
	{
		delay(1); // Not all floors are at 152.0. Delay and loop again.
	}
	
	// All floors at 152.0. Lower other floor.
	Floor_MoveToValue(11, 6, 144, 0);
	
	// Script ends forever.
}
You can find out more about loops here: http://zdoom.org/wiki/FOR_and_WHILE_loops

Share this post


Link to post

Evaine was on the right path. The biggest problem was that they forgot to use { } brackets.
Also, make sure you use the ZDoom Wiki's "Operators" page for reference. Operators can be kind of tricky. (there's a difference between = and == )

Both of Edward850's code examples work, but keep in mind: WHILE will lower the other floor when ANY of the conditions has been met (is that a bug?). UNTIL waits until ALL conditions are met. I've set up a quick WAD demonstrating the difference: FloorWhileUntilACS.wad Fixed, both examples work exactly the same now. Operators are tricky!

Share this post


Link to post
3noneTwo said:

WHILE will lower the other floor when ANY of the conditions has been met (is that a bug?)

I mucked up the logic on that one. Logical AND will fall back the moment any condition is false (check all conditions), and thus I was supposed to use logical OR to check any condition. Fixed.

Share this post


Link to post
Evaine said:

Okay, here's what I have. I know for a fact this is wrong, because it's not compiling, but I've never tried something this complex before, so I'm not sure exactly how to do this.

SCRIPT 80 OPEN //イベントの要件を確認します
{
    until(
        (GetSectorFloorZ (101,0,0) = 152);
        (GetSectorFloorZ (102,0,0) = 152);
        (GetSectorFloorZ (103,0,0) = 152);
        (GetSectorFloorZ (104,0,0) = 152);
        )
        Floor_MoveToValue(11,6,144);
}


The biggest and most obvious error here is that you're using the assignment operator (=) instead of the comparison operator (==). If you want to compare whether two values are identical, you need to use == in ACS, just like in the C language family (C, C++, C#, Java, Perl, etc.).

The second mistake is using ; instead of a logical combination operator (like &&, ||, etc.). The semi-colon terminates an instruction so it won't actually use the next three lines for the "until" loop.

The last mistake is that you're missing a delay instruction. Anytime you make a loop with an exit condition that cannot be reached within the same tic, you need to put a delay so that the script will not run away and freeze the game.

Share this post


Link to post
Gez said:

The last mistake is that you're missing a delay instruction. Anytime you make a loop with an exit condition that cannot be reached within the same tic, you need to put a delay so that the script will not run away and freeze the game.


This is probably a mistake a lot of people make, simply because it isn't obvious. I often simply forget to put the delay in. Thankfully, ZDoom just prints a nice message about a runaway script and terminates said script, preventing the game from freezing.. Well, usually.

Share this post


Link to post

Yeah, it's not something that's generally touched upon in "intro to programming" guides because tutorials usually don't cover having loops waiting for events external to the program.

Share this post


Link to post

Heh, yeah... I've never done anything so tough before. I'm not surprised the syntax was bad >//< Also, when I read the wiki, my head hurts. My English is limited to small words and phrases. I really appreciate all of the help I was given! I learned a lot through this. Thank you so much, everyone!

Share this post


Link to post

Hey Evaine, good to see you posting at last. Remeber to use the { } brackets instead of the ( ). I don't know much else about these particular commands. Anyways, you see why I said these forums were the way to go when you have ACS doubts? Tons of knowledgeable folks. And your english is perfect (I guess, i'm not a native speaker myself either)

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×