Minenash / CustomHUD

A highly customizable variable-based text HUD for Minecraft
MIT License
80 stars 23 forks source link

Hour variables always return true in numerical conditionals #47

Closed KylerOlsen closed 2 years ago

KylerOlsen commented 2 years ago

The hour, hour12, and hour24 variables always return true when used in a numerical conditional.

{{hour24 >= 6 & hour24 < 18, '&aDay'}}{{hour24 >= 18 & hour24 < 19, '&6Evening'}}{{hour24 >= 19 & hour24 < 5, '&8Night'}}{{hour24 >= 5 & hour24 < 6, '&9Morning'}} Here all four conditionals return true, so at any in-game-time it will say DayEveningNightMorning rather than indicating the current part of the day night cycle.

Minenash commented 2 years ago

So there turned out to be 2 independent bugs causing this

  1. When writing the parser for conditionals, I forgot to allow numbers in variable name. This caused hour24 and hour12 to resolve as hour (and a separate number, which caused some weirdness in of itself)
  2. Apparently I had also accidentally removed the variable hour at some point

I have fixed both in dev and will push a release today (a long with a few other things)

In the future, if a variable/conditional isn't acting as you expect, I'd check the log for more context as I still have some debug stuff in there. For example in this one I saw "unknown variable: hour"

KylerOlsen commented 2 years ago

Thank you!

Minenash commented 2 years ago

Oh, also in {{hour24 >= 19 & hour24 < 5, '&8Night'}} You probably want to replace the & with |

Minenash commented 2 years ago

Fixed in v2.1