freshbrood Posted May 13, 2020 Share Posted May 13, 2020 (edited) Example: if player1y<76 then e=14 : if f{1} then e=13 vs if player1y<76 then e=14 if player1y<76 && f{1} then e=13 ----------------------------------------------- Both of these examples seem to work perfectly fine in my code. The top example uses less memory. But I have been advised to never use 2 or more if statements on the same line. Why? Is it because it's generally bad practice and can lead to confusing code? Or does it actually cause a glitch and make the game crash upon reading? Because in terms of memory usage, if the top line reads correctly every time, obviously it would be preferable. Edited May 13, 2020 by freshbrood Quote Link to comment Share on other sites More sharing options...
Lillapojkenpåön Posted May 13, 2020 Share Posted May 13, 2020 (edited) I actually didn't know you could do that, but the first example would be split up on several lines like this if player1y>=76 then skip e=14 if f{1} then e=13 skip It's easier to read, especially if you add more stuff or if statements down the line. You might want to try this instead btw if f{1} then e=13 else e=14 Another good thing is that it's more similar to the assembly it turns into, if you do this.. if player1y>=76 then skip if !f{1} then a e=13 goto skip a e=14 skip you're pretty much writing assembly Edited May 13, 2020 by Lillapojkenpåön 1 Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted May 13, 2020 Share Posted May 13, 2020 The bB page says these things: "Using multiple if…thens in a single line might not work correctly if you are using boolean operators." "If you use || in an if…then statement, the statement must be located at the beginning of a line. At this time, compilation will succeed but your program will probably not work correctly. This issue will probably be fixed in a later version." "The else keyword might not work correctly in a statement containing &&. The else keyword may also not work as expected when there is more than one if…then on a single line." 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.