Dear fellow lovers,
I'm straight out of the blocks, into the first hurdle and BAM!, I have fallen flat on my face. Been googling around, and searched this forum, can't find the solution to my problem.
I've downloaded and installed the latest version of Love for Mac (0.6.2). I can run the bundled demos. However, when I try and create and run my own game I'm seeing the following error :
syntax error: main.lua:2: unexpected symbol near 'Â'
This is the code that I copied from the wiki :
function love.draw()
love.graphics.print("Hello World", 400, 300)
end
To run the game, I'm dragging the folder that contains main.lua onto the Love icon.
I have tried creating the file with both TextEdit and TextWrangler. I suspect this problem may be due the text encoding used to save the file. In TextWrangler I have tried UTF8, UTF16, BOM and no BOM, and a wild variety of other settings in vain. I notice that the unexpected symbol in the error message changes when I change the encoding.
Any assistance would be greatly appreciated.
Patrick
Error creating Hello World game
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Error creating Hello World game
Could you upload the exact file to the forums? It should work with UTF-8 without BOM, as that is backwards compatible with ASCII.
Help us help you: attach a .love.
Re: Error creating Hello World game
... I use GEdit. I [usually] save in a western encoding, because I have GEdit for windows, because I don't have the packages to use Love for Linux.
Hello, I am not dead.
-
- Prole
- Posts: 6
- Joined: Thu Oct 28, 2010 5:31 pm
Re: Error creating Hello World game
Here is a copy of the main.lua file, saved in UTF8.
- Attachments
-
- main.lua
- (78 Bytes) Downloaded 161 times
- TechnoCat
- Inner party member
- Posts: 1611
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Milwaukee, WI
- Contact:
Re: Error creating Hello World game
You are using an odd whitespace character on line 2.
Also, it looks like it starts with a BOM.
Also, it looks like it starts with a BOM.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Error creating Hello World game
Your indentation uses weird characters: 0xc2 0xa0 (194 160 in decimal), which is a non-breaking space. You might need to tweak some settings to produce simple 0x20 (32) spaces. Or use a better text editor.
Now that I think of it, Lua handles BOM probably correctly.TechnoCat wrote:Also, it looks like it starts with a BOM.
Help us help you: attach a .love.
- TechnoCat
- Inner party member
- Posts: 1611
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Milwaukee, WI
- Contact:
Re: Error creating Hello World game
I had to remove the 3 bytes at the beginning and the bad whitespace to get it to run. BOM should be 4 bytes IIRC.Robin wrote:Now that I think of it, Lua handles BOM probably correctly.
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Error creating Hello World game
If it's Windows, I hear NotePad++ is pretty good.
-
- Prole
- Posts: 6
- Joined: Thu Oct 28, 2010 5:31 pm
Re: Error creating Hello World game
Thanks chaps. To get it working I had to delete the spaces before "love.graphics.print" and save the file as UTF without BOM. Talk about a rocky start.
- nevon
- Commander of the Circuloids
- Posts: 938
- Joined: Thu Feb 14, 2008 8:25 pm
- Location: Stockholm, Sweden
- Contact:
Re: Error creating Hello World game
I would suggest that you get a different text editor. Coding without whitespace really isn't an option.patrickjcollins wrote:Thanks chaps. To get it working I had to delete the spaces before "love.graphics.print" and save the file as UTF without BOM. Talk about a rocky start.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 4 guests