GitHub-TC / EmpyrionScripting

Displays various informations directly and live on LCD screens and will support conveyor and construction control
GNU General Public License v3.0
34 stars 5 forks source link

Math Operations Interfere With Integer Comparisons #31

Closed shiribailem closed 11 months ago

shiribailem commented 1 year ago

I ran into a weird behavior around math operations... turns out any operation you do on a variable, ironically even (int x) turns it into a string. In most cases this doesn't matter, but it causes a problem with comparisons in test.

Example:

{{set 'test' 3}}

{{#test (int @data.test) 'geq' 10}}
  True
{{else}}
  False
{{/test}}

The expected outcome is False because 3 is less than 10... but you get True because in string comparisons "3" is greater than "10".

GitHub-TC commented 11 months ago

The "int" returns an integer but in an "stringinterpreted" environment `{{set 'test' 3}}

{{#test @data.test 'geq' 10}} True {{else}} False {{/test}}`

works