temnix Posted May 4, 2021 Share Posted May 4, 2021 No, those are not Roman numerals. It's the types of OR. What is the difference between them? Does the difference make a difference in a tp2? (race = 3 | race = 7) vs. (race = 3 || race = 7)? Quote Link to comment
Jarno Mikkola Posted May 4, 2021 Share Posted May 4, 2021 (edited) Yes, see there's no 1 as that is BOR, and so only two = or. Edited May 4, 2021 by Jarno Mikkola Quote Link to comment
Mike1072 Posted May 5, 2021 Share Posted May 5, 2021 || is a logical operator and the better representation of how we use the word "or" in everyday language. | is a bitwise operator that determines a result by evaluating two bit strings bit-by-bit. For more information, see here. Here are some examples to compare the behaviour. 0 || 0 is 0 0 | 0 is 0 1 || 0 is 1 1 | 0 is 1 2 || 0 is 1 2 | 0 is 2 5 || 12 is 1 5 | 12 is 13 The logical operator || will only ever return 0 or 1, while the bitwise operator | can return other numbers. WeiDU treats the condition on an IF statement as true when it evaluates to any number other than 0, so PATCH_IF (x || y) would evaluate exactly same as PATCH_IF (x | y). However, I would encourage using || for clarity if you are intending a logical comparison. || is a synonym for OR, so you could also use OR. Similarly, I'd suggest using the logical operator && (also known as AND) over the bitwise operator & within conditions. Here are some examples to compare those two: 0 && 0 is 0 0 & 0 is 0 1 && 0 is 0 1 & 0 is 0 1 && 1 is 1 1 & 1 is 1 2 && 0 is 0 2 & 0 is 0 2 && 1 is 1 2 & 1 is 0 2 && 2 is 1 2 & 2 is 2 5 && 12 is 1 5 & 12 is 4 The behaviour of the bitwise operator & does not always match our usage of the word "and" in everyday language, demonstrated by 2 & 1 equalling 0. The bitwise operators are best reserved for dealing with values that are stored bitwise, like usability flags within .itm files. Quote Link to comment
temnix Posted May 6, 2021 Author Share Posted May 6, 2021 They are the same, then. That's what I wanted to know. Quote Link to comment
Mike1072 Posted May 6, 2021 Share Posted May 6, 2021 In certain circumstances, as described above. Quote Link to comment
Recommended Posts
Join the conversation
You are posting as a guest. 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.