Tutorial code doesnt work! ~ Solved

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.
Post Reply
RussHubs
Prole
Posts: 6
Joined: Thu Apr 07, 2011 12:15 pm

Tutorial code doesnt work! ~ Solved

Post 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.
Last edited by RussHubs on Thu Apr 07, 2011 2:18 pm, edited 1 time in total.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Tutorial code doesnt work!

Post 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.
RussHubs
Prole
Posts: 6
Joined: Thu Apr 07, 2011 12:15 pm

Re: Tutorial code doesnt work!

Post 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?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Tutorial code doesnt work!

Post 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
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: Tutorial code doesnt work!

Post 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.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
RussHubs
Prole
Posts: 6
Joined: Thu Apr 07, 2011 12:15 pm

Re: Tutorial code doesnt work!

Post 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?
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: Tutorial code doesnt work! ~ Solved

Post 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.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
shinn497
Prole
Posts: 1
Joined: Mon Apr 11, 2011 12:44 am

Re: Tutorial code doesnt work! ~ Solved

Post 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. ><
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Tutorial code doesnt work! ~ Solved

Post 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. :)
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests