wtf
February 9th, 2005, 12:13 PM
I don't remember seeing this mentioned here or in the documentation, but NetRemote.GetVariable() appears to always return a string type. And since lua doesn't apply coercion during equality tests, you have to be careful when manipulating numbers returned using GetVariable().
x = NetRemote.GetVariable(..)
y = NetRemote.GetVariable(..)
x==y is true/false as expected, but if you then do:
y=y+1
x==y is always false since y was silently converted to an integer
So the safe solution is to always do:
x = NetRemote.GetVariable() + 0
if you are using the variables as integers.
I ran into this while creating my NetRemote jukebox, when detecting if I am at the lowest tree level to display a different message and add to playlist if selected.
x = NetRemote.GetVariable(..)
y = NetRemote.GetVariable(..)
x==y is true/false as expected, but if you then do:
y=y+1
x==y is always false since y was silently converted to an integer
So the safe solution is to always do:
x = NetRemote.GetVariable() + 0
if you are using the variables as integers.
I ran into this while creating my NetRemote jukebox, when detecting if I am at the lowest tree level to display a different message and add to playlist if selected.