DogDog
DogDog

Reputation: 4920

Executing Love2D scripts

The only way I found out to execute my script with the Love2d framework is to zip all of it and then rename the zip to love. This kinds of take a lot of time for a small modification. Is there a faster way to do it? I tried to command line and I get this error

'love' is not recognized as an internal or external command,
operable program or batch file.

Upvotes: 2

Views: 9671

Answers (8)

Romeo Swarovski
Romeo Swarovski

Reputation: 29

simple way:

  • create folder /path/to/Game
  • put your files (main.lua, conf.lua, ...) in folder /path/to/Game

you can run script like this:

love /path/to/Game/

or if you use Linux, you can go in folder (cd /path/to/Game) and type just:

love .

(dot means that you want to run it form in folder

Upvotes: 2

Rasmus
Rasmus

Reputation: 1

If you use Sublime Text, you can make a build which runs your application. https://love2d.org/wiki/Sublime_Text

While in Sublime Text press CMD + B or Ctrl + B

Upvotes: 0

IOD
IOD

Reputation: 32

If you're yousing Notepad++ to write your code, just open your main.lua file, then go to Run and add there this text including quotes:

"Path" "$(CURRENT_DIRECTORY)"

Where Path is a Full path to love.exe. The save it to a key combination and now you can test your code by using this combination in any script at Notepad++.

Upvotes: 0

Cinzia Nicoletti
Cinzia Nicoletti

Reputation: 305

I found a simple solution for save time. You have to create a file .bat with this simple command:

del Project.love
7z.exe a Project.zip ..\Project\*
ren Project.zip Project.love

For do this you need to download 7zip and insert this file (file.bat) into the folder of your project. Like this:

Example

Good work!

Upvotes: 0

ericariello
ericariello

Reputation: 111

If you're using Mac OS, you should run using:

open -a love xxx.love

To recreate a file as .love, you can run in command line:

zip xxx.love file1.lua file2

If you just want to replace a file in .love:

zip -r xxx.love file1.lua

I think this will make your work easier.

Upvotes: 1

Aster
Aster

Reputation: 247

LÖVE runs the contents of a folder if it can find a main.lua in it (Like Bill said).
[Note that it doesn't check subfolders].

There are three ways to run a love2D program, you can:

a) Drag the folder over the love.exe binary/link (This works in Win and *Nix, I don't know about OS X).

b) Navigate to the directory that is one level above the folder and type love [folder containing main.lua]

or

c) Zip it up and rename the .zip to a .love. Then double click the .love file


Option 'b' will fail if the binary is not in the %PATH%(Windows) or $PATH(*Nix) variable

(It will spout an error message like 'love' is not recognized as an internal or external command, operable program or batch file. on windows and bash: love: command not found on linux).

There are two ways to solve this:
(Both require ADMIN/root privileges, )
1) Add the love binary to the PATH variable. Here's how to do this in windows and in linux (In linux you want to do something like this: PATH=$PATH:$HOME/where/ever/you/put/love/)

2) You can add a link to the love2D binary in C:\WINDOWS\system32 or /usr/bin/.
In windows you create a shortcut to the love.exe (wherever you installed it to) and then drag it into C:\WINDOWS\system32. In linux you can run this:
sudo link /path/to/love/binary /usr/bin/love && sudo chmod ugo+rwx /usr/bin/love

I hope this helps!

Sources: Google (the links above), Love2D and my knowledge :D

Upvotes: 4

Daniel Del Core
Daniel Del Core

Reputation: 3221

I found this to be very helpful when i started. Hope this helps

A Guide to Getting Started With Love2d

Upvotes: 1

Bill Meltsner
Bill Meltsner

Reputation: 61

LÖVE also executes folders if they have the main.lua in them - you can just drag and drop the folder onto the application, or call it from the command line with the folder as the argument if you prefer.

Upvotes: 5

Related Questions