0

When I try and load a game on Love2D (for GD50), I am unable to get the game to work. I know that there is no problem in the code, as I tried with different codes, even with code downloaded from the course's website. No game at all is running. The file that I try to run is called main.lua, and the error is

Error

boot.lua:577: Cannot load game at path 'C:/Users/Arnav Khanna/Downloads/main.lua'.
Make sure a folder exists at the specified path.


Traceback

[C]: in function 'error'
[C]: in function 'xpcall'
[C]: in function 'xpcall'

Code:

--[[
    GD50 2018
    Pong Remake

    pong-0
    "The Day-0 Update"

    -- Main Program --

    Author: Colton Ogden
    cogden@cs50.harvard.edu

    Originally programmed by Atari in 1972. Features two
    paddles, controlled by players, with the goal of getting
    the ball past your opponent's edge. First to 10 points wins.

    This version is built to more closely resemble the NES than
    the original Pong machines or the Atari 2600 in terms of
    resolution, though in widescreen (16:9) so it looks nicer on 
    modern systems.
]]

WINDOW_WIDTH = 1280
WINDOW_HEIGHT = 720

--[[
    Runs when the game first starts up, only once; used to initialize the game.
]]
function love.load()
    love.window.setMode(WINDOW_WIDTH, WINDOW_HEIGHT, {
        fullscreen = false,
        resizable = false,
        vsync = true
    })
end

--[[
    Called after update by LÖVE2D, used to draw anything to the screen, updated or otherwise.
]]
function love.draw()
    love.graphics.printf(
        'Hello Pong!',          -- text to render
        0,                      -- starting X (0 since we're going to center it based on width)
        WINDOW_HEIGHT / 2 - 6,  -- starting Y (halfway down the screen)
        WINDOW_WIDTH,           -- number of pixels to center within (the entire screen here)
        'center')               -- alignment mode, can be 'center', 'left', or 'right'
end

Even if I run it in different directories or with a terminal window, it doesn't work. Please may somebody help?

7
  • 1
    Which assignment? This C:/Users/Arnav Khanna/Downloads/main (1).lua is not a path, it is a file name. The path is C:/Users/Arnav Khanna/Downloads. but as far as I know love looks for a file named "main.lua" in the path. What is boot.lua? Mar 23, 2020 at 17:48
  • Hey DinoCoderSaurus, sorry for the confusion. The error message up above is an old message, I renamed the file to main.lua and it still didn't work (I have updated the error message above). The code is not an assignment, it is just the first example code from the first lecture. I have posted it above as well. As I am relatively new to Lua, I am not sure what boot.lua is, but I presume that it is some sort of library/program that Love2D runs to start my code, which raises an error. If you could please tell me what I am doing wrong I would be very grateful to you.
    – AK2150
    Mar 25, 2020 at 15:54
  • Even when I directly download some lecture code from GitHub, without ever passing it through my IDE, it fails to work, leading me to believe that there is nothing wrong with the code itself.
    – AK2150
    Mar 25, 2020 at 16:01
  • Review the Getting Started - LOVE and launch it from the command line. Mar 25, 2020 at 18:09
  • Thank you, DinoCoderSaurus! It turns out that I was just opening the file the wrong way, so an error came. Thank you so much!! :)
    – AK2150
    Mar 27, 2020 at 16:35

4 Answers 4

2

You can try to open the folder instead of lua file

1

But I wasn't able to open file yet, I tried many ways as the process is given above. Please help me out.

4
  • If you are on a windows, just drag and drop the file that contains main.lua at the root level onto the love icon
    – AK2150
    May 16, 2020 at 5:19
  • i have tried everything that you have listed but no of those things are working are there any other ways for me to open this May 28, 2020 at 1:28
  • having the same issue on a mac. Tried the different ways to do it from the LOVE getting started doc. no luck Jun 15, 2020 at 17:24
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review
    – MARS
    Jun 18, 2020 at 14:15
1

From here: https://love2d.org/forums/viewtopic.php?t=85111

"Re: Error while loading game Post by nfnarvaez » Tue Jul 16, 2019 12:24 pm

I had the same issue. The solution is calling the path but with not main.lua . For example: love.exe C:\luaprojects\project1 instead of love.exe c:\luaprojects\luaproject\main.lua. I hope it helps."

0

I called my file main.lua and put it on a .zip file and it worked.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .