Evaine Posted September 6, 2015 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 0 Share this post Link to post
Dave The Daring Posted September 6, 2015 Your English seems fine to me. Anyway try this and this. I haven't used these commands myself, so you'll probably have to experiment a bit. Hope this helps. 0 Share this post Link to post
Evaine Posted September 6, 2015 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. 0 Share this post Link to post
Dave The Daring Posted September 6, 2015 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. 0 Share this post Link to post
Evaine Posted September 6, 2015 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. 0 Share this post Link to post
Edward850 Posted September 6, 2015 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 0 Share this post Link to post
Lollie Posted September 6, 2015 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! 0 Share this post Link to post
Edward850 Posted September 6, 2015 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. 0 Share this post Link to post
Gez Posted September 6, 2015 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. 0 Share this post Link to post
scifista42 Posted September 6, 2015 Evaine said: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. Any basic C/C++ course or online tutorial would teach you. Or look here: http://zdoom.org/wiki/A_quick_beginner%27s_guide_to_ACS#Flow_Control http://zdoom.org/wiki/Operators 0 Share this post Link to post
Dave The Daring Posted September 6, 2015 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. 0 Share this post Link to post
Gez Posted September 6, 2015 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. 0 Share this post Link to post
Evaine Posted September 7, 2015 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! 0 Share this post Link to post
Lycaon Posted September 8, 2015 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) 0 Share this post Link to post