Page 1 of 1

Tutorial code doesnt work! ~ Solved

Posted: Thu Apr 07, 2011 12:36 pm
by RussHubs
Hi Everyone,

I'm very excited about finding LÖVE

I follow the instructions heres:
Getting Started ~ Making a Game

To make a minimal game, create a folder anywhere, and open up your favorite code editor. Notepad++ is a pretty good one for Windows, and it has Lua support built in. Create a new file in the folder you just created, and name it main.lua. Put the following code in the file, and save it.

Code: Select all

function love.draw()
    love.graphics.print("Hello World", 400, 300)
end
So I followed the instructions (downloaded Notepad++ & Winzip), copied & pasted the code exactly. I created the zip file of the folder (the folder I created the main.lua in), then I changed the .zip extension to .love. I try to execute the game and get this error written in the 800x600 window:

Code: Select all

Error

Boot.lua:296: No code to run
You game might be packaged incorrectly
Make sure main.lua is at the top level of the zip

Traceback

[C]: in function 'error'
[C]: in function 'xp call'
All I can say is im alittle vexed, the very first code I try, using the very first tutorial you have on your website and following that tutorial to the letter, doesn't even work.

If someone could point me to what it is I'm doing wrong and maybe update your website accordingly I would be greatful.

Re: Tutorial code doesnt work!

Posted: Thu Apr 07, 2011 12:58 pm
by bartbes
I'm pretty sure you haven't followed this paragraph exactly:
In both cases, there has to be a file called main.lua in the root path. This file will be loaded when LÖVE starts. If this file is missing, LÖVE will not recognize the folder or .love file as game, and it will complain about a wrongly packaged game. A frequently made mistake is zipping the folder rather than its contents. This stems from very old practice (because when you unzip a folder you don't want it to splash out all over your current directory), but for LÖVE doing that doesn't make sense: you need to zip the game folder's contents only, to get a correct .love.
It very much sounds like your zip file contains the folder, not the files in the folder at the root.

Re: Tutorial code doesnt work!

Posted: Thu Apr 07, 2011 1:26 pm
by RussHubs
Fantastic thats sorted it,

So the folder I create 'Anywhere', I can call my 'Gamder' (game folder) and EVERYTHING thats in it should be zipped, but the main.lua HAS to be in top level within that folder?

Re: Tutorial code doesnt work!

Posted: Thu Apr 07, 2011 1:36 pm
by bartbes
If you have a structure like this:

Code: Select all

epic-game-folder/
  main.lua
  gfx/
    cake.png
  snd/
    bite.mp3
Your zip should contain:

Code: Select all

main.lua
gfx/
  cake.png
snd/
  bite.mp3

Re: Tutorial code doesnt work!

Posted: Thu Apr 07, 2011 2:16 pm
by Lafolie
This confused me when I first started too. Here's a couple of tips I picked up:

-You can drag the root folder onto your Löve app icon and it will run.
-When creating a .love file, as mentioned above, select the files inside your project folder, not the folder itself.

Re: Tutorial code doesnt work!

Posted: Thu Apr 07, 2011 2:21 pm
by RussHubs
Lafolie wrote:This confused me when I first started too. Here's a couple of tips I picked up:

-You can drag the root folder onto your Löve app icon and it will run.
-When creating a .love file, as mentioned above, select the files inside your project folder, not the folder itself.
Thanks LaFolie, Bartbes solved this issue for me so I'd edited the title.

Yes I was zipping the folder i created 'anywhere' not its contents, I've now started working on the file structure with the 'anywhere' folder, so you're saying I don't need to zip it and change the extension to .love, I just need to drop the 'anywhere' folder on the LOVE shortcut?

Re: Tutorial code doesnt work! ~ Solved

Posted: Thu Apr 07, 2011 2:28 pm
by Lafolie
Yeah, that speeds up testing alot right? It works for me on OSX, not sure about windows but I don't see any reason for that not to work.

Re: Tutorial code doesnt work! ~ Solved

Posted: Mon Apr 11, 2011 1:02 am
by shinn497
hmmm I'm having a similar problem

I made a main.lua file in directory

/home/guest/games makings

then I typed

love /home/guest/games makings/main.lua

It didn't work. I'm kind of a noob at this. ><

Re: Tutorial code doesnt work! ~ Solved

Posted: Mon Apr 11, 2011 4:13 am
by BlackBulletIV
shinn497 wrote:hmmm I'm having a similar problem

I made a main.lua file in directory

/home/guest/games makings

then I typed

love /home/guest/games makings/main.lua

It didn't work. I'm kind of a noob at this. ><
1. You can't include spaces in paths, if you want them to be treated as a single argument. You must either surround the path in quotes (if it has spaces), like this:

Code: Select all

love "/home/guest/games makings"
or escape the spaces like this:

Code: Select all

love /home/guest/games\ makings
2. You must specify the directory, or .love file, but not include the main.lua bit. Therefore:

Code: Select all

love "/home/guest/games makings"
Hope that helps. :)