Skip to content
#1174
Auto-translated
2RedHeavenHero:
Whether to use constants or not is up to you.
Of course. The question was why the numbers are "magical," and I provided a detailed answer. Whether to use constants or not is a personal matter for everyone. Essentially, it's just a matter of legible or illegible handwriting.
Regarding the unclear expression: everything is on the language developer's website, lua.org, including the order of operations. I just used the available features, and ten extra parentheses won't make a difference.
No one will memorize the order of operations, as such implementation details vary in different programming languages. And referring to reference materials to decipher the code is also not very good. Therefore, parentheses are needed for human readability (it's like punctuation in "to execute or not to execute"), if they help understand the order of operations. If parentheses are not used, don't be surprised by such questions.

If you understand what is written in that expression, then please explain what
GetPlayerState(...) == 1 or 0
means? Does it mean that the number is compared with both 0 and 1, and the operation returns true (1) if it is equal to one of them? In this case, what does the status PLAYER_NOT_IN_GAME = 0, which was used in the comparison, have to do with it? In other words, why is zero here?
RedHeavenHero
Here's the deal. GetPlayerState returns:
1 - player is participating
2 - player won
3 - player lost
4 - they weren't there at the beginning.
There are many mistakes in the manual.
But in the file advmap-startup.lua, which is connected to the game, it says:
-- Player states
--
PLAYER_NOT_IN_GAME = 0
PLAYER_ACTIVE = 1
PLAYER_WON = 2
PLAYER_LOST = 3
And there is no 4. So, was the number 4 obtained manually? And, after all, what is better to use, comparing the status with 1 (0?) or with 4? Or does it not matter?

Statistics

Welcome our newest member: Emil

Users Online 3 users 1442 guests