I've hit a snag making my first game, a tiled roguelike. I started out coding in SublimeText2 and have since switched to TextWrangler - unfortunately I don't have access to Notepad++ because I'm usually coding on my Macbook. When I try to run my game, this is the error I get:
Error
graphics.lua.1273: Decoding error: Invalid UTF-8
Traceback
[C]: in function 'printf1'
graphics.lua.1273: in function 'printf'
[C]: ?
[C]:in function 'require'
[C]: in function 'xpcall'
I've already tried the fix that involves saving the code in UTF-8 w/o BOM - that should be the state the attached code is in. This is pretty strange to me because I had my game running for a long time before something switched on me and caused this to start happening. Another fix I saw involved taking out invalid characters from the path, but that doesn't seem to apply to my situation either since my game is stored in OSX_user_root_folder/game. Any suggestions are greatly appreciated!
Error: Syntax error: main.lua:211: unexpected symbol near '�'
stack traceback:
[C]: ?
[C]: in function 'require'
[string "boot.lua"]:331: in function <[string "boot.lua"]:227>
[C]: in function 'xpcall'
Error: [string "graphics.lua"]:1273: Decoding error: Invalid UTF-8
stack traceback:
[C]: in function 'printf1'
[string "graphics.lua"]:1273: in function 'printf'
[string "boot.lua"]:723: in function 'draw'
[string "boot.lua"]:727: in function <[string "boot.lua"]:682>
[C]: ?
[C]: in function 'require'
[string "boot.lua"]:331: in function <[string "boot.lua"]:227>
[C]: in function 'xpcall'
That suggests you have a weird character in main.lua near line 211.
Oh yes, that is kind of awkward, the error handler is trying to display your error, but that isn't valid utf-8, probably because the character parsing fails on isn't.
In main.lua on line 211 you have 2 no-break spaces that, in UTF-8, are encoded with two bytes (file offset 5596: 0xC2 0xA0). Lua doesn't understand that and errors with the unexpected byte in the message. The LÖVE error handler doesn't like the byte above 127 and explodes.
A few other things.
Don't call love.graphics.newFont every frame. This creates a lot of font objects that will take up a lot of memory and you only need one. Load them in love.load or once when the game state changes.
Try not to use a variable called 'string'. The global variable 'string' points to the Lua string library and you may want still be able to access it in a comfortable way.
The function require has a specific syntax for module names. Instead of slashes, use periods to separate directories.
Boolsheet wrote:In main.lua on line 211 you have 2 no-break spaces that, in UTF-8, are encoded with two bytes (file offset 5596: 0xC2 0xA0). Lua doesn't understand that and errors with the unexpected byte in the message. The LÖVE error handler doesn't like the byte above 127 and explodes.
That raises the question: why the hell does the error message for invalid UTF-8 include the invalid byte sequence, unescaped and everything? Who thought that was a good idea?
Thank you all for the help! I've eliminated the offending characters, I'm not even sure how they got in there.
Boolsheet wrote:
Don't call love.graphics.newFont every frame. This creates a lot of font objects that will take up a lot of memory and you only need one. Load them in love.load or once when the game state changes.
Try not to use a variable called 'string'. The global variable 'string' points to the Lua string library and you may want still be able to access it in a comfortable way.
The function require has a specific syntax for module names. Instead of slashes, use periods to separate directories.
I'll keep those suggestions in mind. I didn't notice that I left newFont inside draw(), I learned my lesson about not leaving incrementing calls in draw() the hard way after I had an infinitely-looping info dialog giving me grief. Thanks again!
Robin wrote:
That raises the question: why the hell does the error message for invalid UTF-8 include the invalid byte sequence, unescaped and everything? Who thought that was a good idea?