Error creating Hello World game

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
patrickjcollins
Prole
Posts: 6
Joined: Thu Oct 28, 2010 5:31 pm

Error creating Hello World game

Post by patrickjcollins »

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
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Error creating Hello World game

Post by Robin »

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.
User avatar
zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Location: In your head.
Contact:

Re: Error creating Hello World game

Post by zac352 »

... 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.
patrickjcollins
Prole
Posts: 6
Joined: Thu Oct 28, 2010 5:31 pm

Re: Error creating Hello World game

Post by patrickjcollins »

Here is a copy of the main.lua file, saved in UTF8.
Attachments
main.lua
(78 Bytes) Downloaded 158 times
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Milwaukee, WI
Contact:

Re: Error creating Hello World game

Post by TechnoCat »

You are using an odd whitespace character on line 2.
Also, it looks like it starts with a BOM.
Attachments
2010-10-28.png
2010-10-28.png (59.3 KiB) Viewed 4590 times
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Error creating Hello World game

Post by Robin »

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. ;)
TechnoCat wrote:Also, it looks like it starts with a BOM.
Now that I think of it, Lua handles BOM probably correctly.
Help us help you: attach a .love.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Milwaukee, WI
Contact:

Re: Error creating Hello World game

Post by TechnoCat »

Robin wrote:Now that I think of it, Lua handles BOM probably correctly.
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.
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Error creating Hello World game

Post by Jasoco »

If it's Windows, I hear NotePad++ is pretty good.
patrickjcollins
Prole
Posts: 6
Joined: Thu Oct 28, 2010 5:31 pm

Re: Error creating Hello World game

Post by patrickjcollins »

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.
User avatar
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

Post by nevon »

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.
I would suggest that you get a different text editor. Coding without whitespace really isn't an option.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot], Semrush [Bot] and 2 guests