So, I haven't been programming for very long but I'm trying to use the command line.
I would like to know how to open a main.lua (it's just a "Hello World") in Löve from the command line.
I'm using Mac OS X (Mavericks). My knowledge of the Terminal doesn't extend beyond some basic commands (cd, ls, mkdir) and a bit of Vim. the Getting started page mentioned something about .bash_profile but I need some help understanding this.
Thank you for your patience.
Noob trying to execute a "Hello World" from the Command Line
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Noob trying to execute a "Hello World" from the Command
Basically it's simple. Kind of.
Basically you're going to launch the "love" binary with the .love file as its first argument. The "love" binary is inside the love.app package. You can find it by right-clicking on the .app and "Show Contents". Then navigate to /Contents/MacOS. The love binary is in that folder.
ALTERNATIVELY: Assuming the love.app is in /Applications/, the path to the love binary below will be /Applications/love.app/Contents/MacOS/love.
Open a Terminal window and do two things. First drag the love binary to the Terminal window. Then drag the .love. The command should appear something like this:
Press Enter/Return and it will launch. All "print()" calls will also print to this window as a bonus for debugging.
I created a run.command file to handle this for me. Basically you'd create a new plain text file and use this as the contents:
Then rename it to run.command, place it in the same directory as your main.lua and make it Executable by using this command:
The strange string above with the $ and {} characters simply means it will pass the current folder (That the .command file is in) as the argument.
Don't worry if you think something might screw something up, these commands are safe. And you couldn't destroy anything without using sudo anyway.
Remember to replace /Path/to/ with the actual path. (Dragging and dropping is the easiest way to put a file path into a Terminal window without typing. Also see ALTERNATIVELY above.)
Now you can just double-click the .command file or assign it to a hotkey with a program or put it in your Dock and launch your project easily complete with debugging console. I set mine to Command+Shift+R.
Also: I'm not sure if the chmod program requires Xcode to be installed or not. If it does, there are probably other ways to make it executable.
Basically you're going to launch the "love" binary with the .love file as its first argument. The "love" binary is inside the love.app package. You can find it by right-clicking on the .app and "Show Contents". Then navigate to /Contents/MacOS. The love binary is in that folder.
ALTERNATIVELY: Assuming the love.app is in /Applications/, the path to the love binary below will be /Applications/love.app/Contents/MacOS/love.
Open a Terminal window and do two things. First drag the love binary to the Terminal window. Then drag the .love. The command should appear something like this:
Code: Select all
/Path/to/love.app/Contents/MacOS/love /Path/to/project.love
I created a run.command file to handle this for me. Basically you'd create a new plain text file and use this as the contents:
Code: Select all
#!/bin/bash
~/Documents/Projects/LÖVE/Apps/love.app/Contents/MacOS/love "${0%/*}"
Code: Select all
chmod +x /path/to/run.command
Don't worry if you think something might screw something up, these commands are safe. And you couldn't destroy anything without using sudo anyway.
Remember to replace /Path/to/ with the actual path. (Dragging and dropping is the easiest way to put a file path into a Terminal window without typing. Also see ALTERNATIVELY above.)
Now you can just double-click the .command file or assign it to a hotkey with a program or put it in your Dock and launch your project easily complete with debugging console. I set mine to Command+Shift+R.
Also: I'm not sure if the chmod program requires Xcode to be installed or not. If it does, there are probably other ways to make it executable.
Re: Noob trying to execute a "Hello World" from the Command
If you don't have a .love-file, but the main.lua, then you can call it directly. Go to the folder that contains the main.lua and run
Mind the dot.
Code: Select all
love .
Check out my blog on gamedev
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Noob trying to execute a "Hello World" from the Command
I have an alias in my .zshrc file (I think it will work the same in a .bashrc file):
Once that line is added to the file, open a new terminal (so it reloads .bashrc/.zshrc) and try executing:
If you see the baby inspector, then that means you are set up. Then you can do this:
Notice the dot on the second line.
Code: Select all
alias love="/Applications/love.app/Contents/MacOS/love"
Code: Select all
$ love
Code: Select all
$ cd path/to/your/game/folder
$ love .
When I write def I mean function.
Who is online
Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Google [Bot] and 6 guests