7
\$\begingroup\$

I've just started with LÖVE and Lua. I'm interested in LÖVE because I want to play around with something different from my day job (I'm a web developer). Since it uses Lua and is interpreted, I thought it would be a great way to try out the API.

But I couldn't figure out how to run my LÖVE game directly from the Lua interpreter. I'm finding it bothersome to package the game each time I make a little test with the API.

\$\endgroup\$

5 Answers 5

8
\$\begingroup\$

LÖVE isn't as a library that you import into Lua. What it does is embed the Lua interpreter and expose its game functionality to that interpreter.

If you'd like to interactive play with the API, there's a couple of libraries built for debugging and live coding:

Source: https://love2d.org/forums/viewtopic.php?t=8537&p=52985

[EDIT] The debug function can also be useful in a limited context.

[EDIT EDIT] The love-console library was apparently built on an older version of LÖVE, but at least it's a starting point for building your own prompt.

If you're not specifically looking to work with Lua and a game-centric SDL-based framework, another fun one to try out is ruby-processing. It wraps JRuby, making it more convenient to access the Processing library, and has a mode where it will watch a sketch and recompile it every time you save the file. There's also a "live coding" mode but I haven't gotten it to work for me.

[EDIT x 3] Also look at PyProcessing. It has the advantage of having to not bundle JRuby, and can be imported into a standard python interpreter (provided you have all the dependency modules installed, which is Pyglet (which requires PyObjC on OS X).

\$\endgroup\$
3
\$\begingroup\$

To run a game you made in Löve2D, you have to drag its folder (the one containing the main.lua) to the Love2D executable. It's the easiest way to run it. If you want to export you game into an executable itself, you have to package the folder and embed it into the Love2D executable.

If you made a .love file, the same applies, just drag the .love file to the Love2D executable. Make sure main.lua is in its root folder, though. If you installed Love2D in your computer instead of running its portable version, you should be able to play it by just double-clicking the .love file though.

\$\endgroup\$
2
\$\begingroup\$

I'm not sure it counts as running it through the lua interpreter, but you should be able to run it without packaging:

On a terminal, navigate to the directory with your main.lua file, and just enter "love ."

I'm pulling that from memory, but this is where I found it originally: Love wiki

\$\endgroup\$
2
\$\begingroup\$

Here's what I did that works for quick running.

I created a main.lua file which has only one line

require('main2')

I put that file in a zip by itself, gave it the .love extension, and put it in the root of my project folder. Now, I can just double click that whenever I need to test.

Then, main2.lua is my actual main file. You don't even need to make the actual main file a proper module. Writing the love.load(), love.update(dt), and love.draw() functions will write to the global definitions.

\$\endgroup\$
1
\$\begingroup\$

If you're not "married" to a particular editor, I really recommend ZeroBrane Studio IDE: It's open-source, implemented in Lua itself (using wxLua), very lightweight but also very powerful and convenient.

ZBS allows you not only to re-run your code with a single keypress, but also to debug it and even do "live-coding" for Löve and a few other game frameworks.

I've been using it for a few weeks now, and can wholeheartedly recommend it.

\$\endgroup\$

You must log in to answer this question.

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