Page 1 of 1

[Solved] Strange error with field

Posted: Sun Apr 26, 2020 6:20 pm
by alberto_lara
So I'm creating a small GUI library and I'm running out of ideas on a Lua-level error I'm getting, and this is pretty basic stuff, that's the weirdest thing.

Image

The code is behaving like if I'm setting something like:

Code: Select all

obj.x = 123
and then calling:

Code: Select all

obj['x ']
but I'm never doing such thing, I'm just calling

Code: Select all

obj.x
This is probably a stupid mistake but I'm really stuck... Here's the love file:
gui.love
(2.55 KiB) Downloaded 99 times

Re: Strange error with field

Posted: Sun Apr 26, 2020 7:17 pm
by NormalKarl
Hi there, alberto_lara.

I had this problem when I was developing on mac. Specifically in Xcode. It happens to be something that you can't see but its quite straight forward. It happens to be some hidden characters in the code. Probably doesn't show up because its a non-printable character. If you simple rewrote the line again you will notice there are less characters than the line you already had. If you write the line again and select the line you can see there are 3 more characters on the line you have right now. It happens, you must have just accidentally hit a few keys and inserted some hidden characters.

Code: Select all

self.value = (x - (self.x + self.padding)) * (self.w - self.padding * 2) --3 Extra characters that are hidden
self.value = (x - (self.x + self.padding)) * (self.w - self.padding * 2) --This line works
P.S this may not translate into the forum because it probably culls hidden characters in posts.

Re: Strange error with field

Posted: Sun Apr 26, 2020 7:54 pm
by pgimeno
There is an unbreakable space (U+00A0) in 'self.x '. Just delete it and replace with a normal space.

Re: Strange error with field

Posted: Sun Apr 26, 2020 8:04 pm
by alberto_lara
That did the trick, how could I forget about those characters.. Thanks a lot.