Customizing Geany for LOVE

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Customizing Geany for LOVE

Post by MarekkPie »

The topic discussing everyone's favorite IDE/text editor has got me wanting to pimp out my current favorite IDE, Geany (http://www.geany.org/). It's lightweight, feature-rich, but not overbearing. I've found a few nice ways to make it more compatible with LOVE.

Customizing Geany for LOVE

(This is written from a Linux perspective, but it should be fairly similar for anyone using different OS's. This is also written for Geany 0.20, so any other version may or may not have the same functionality. See the manual (http://www.geany.org/manual/current/index.html) for better integration with your setup.)

Creating a main.lua template:

You can simplify the start-up of your game by creating a template that will create the main.lua file with whatever useful LOVE functions you normally use for your games. First, create the main.lua file with your most used LOVE functions. Don't go overboard; if you're needing to erase significant portions of your template every time you start making a game, you're doing it wrong. My template is this:

Code: Select all

function love.load()
end

function love.update(dt)
end

function love.draw()
end

function love.keypressed(k)
	if k == "escape" then
		love.event.push("q");
	end
end
Four functions, three of which are completely bare, and one to quickly close the program for use during debugging.

You can customize the template even more, with header comments and the like, but that is a bit beyond the scope of my simple tutorial, so I will merely provide a link to the necessary portions of the Geany manual (http://www.geany.org/manual/current/ind ... -templates).

When you are satisfied with your template, you need to save it in the template directory with a file name that will identify what the template describes (in my case, I saved it as LoveBasicGame.lua, but you can do whatever. This name will have no affect on the filename of any files created from this template). For Linux distributions, the template directory is usually:

~/.config/geany/templates/files/

(If you are trying to access this via the GUI, be sure to enable hidden files to find the .config directory.)

And you're done! Now, whenever you are starting a new project, all you need to do is: File – New (from Template) – LoveBasicGame.lua and your new main.lua will appear. Alternatively, the drop-down arrow next to the New File icon on the toolbar lists the current templates as well. The only issue is that this file will be untitled, so when you first save it, you'll need to save it as main.lua.

Customizing a project for LOVE:

Geany has a a very simple project system. It will reopen all the files that were open the last time the project and/or Geany was closed, and you can customize a few of the properties of the project to take advantage of some built-in Geany functionality. Our main concern is changing the “Execute” command so that the current LOVE game can be run at the push of a button.

After you have created a new project (Project – New), go to Project – Properties, and select the Build tab. Under the heading Execute Commands, change the first list item's command (the second column) to love %p. This will run the love command using the absolute path to your current project's base path. As long as your main.lua file in at the top of that directory, your LOVE game will run using Geany's internal terminal. Now just click the Execute button on the toolbar (the gears) or use the default keybinding F5, and you're set!

Note: As of 1/8/12, it doesn't seem that Geany supports a custom project type (like they do with the templates). Therefore you will need to do this step every time you make a new project for your LOVE games. There may be ways to make it so that this command will run for every .lua file, regardless of its project association, but there are many caveats to this approach, so I will leave that to you to figure out.

---

That's all I have for now. If any other Geany users have any other neat tricks to help implement LOVE into this nice little IDE then feel free to post them here.
User avatar
josefnpat
Inner party member
Posts: 955
Joined: Wed Oct 05, 2011 1:36 am
Location: your basement
Contact:

Re: Customizing Geany for LOVE

Post by josefnpat »

This is very cool. I'm going to have to try this out at some point :)
Missing Sentinel Software | Twitter

FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
User avatar
hryx
Party member
Posts: 110
Joined: Mon Mar 29, 2010 2:28 am
Location: SF<CA<USA

Re: Customizing Geany for LOVE

Post by hryx »

Nice. Since Notepad++ hasn't been ported and probably never will be, Geany will have to do.

In a similar fashion to your example, I made a template from the love.conf example on the wiki, because I always forget what all the config variables are called.
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Customizing Geany for LOVE

Post by MarekkPie »

Thanks for the compliments, guys!
hryx wrote:In a similar fashion to your example, I made a template from the love.conf example on the wiki, because I always forget what all the config variables are called.
I do this as well, but I figured rewriting essentially the same steps over again would be a waste of space.
trev0006
Prole
Posts: 1
Joined: Tue May 08, 2012 2:03 am

Re: Customizing Geany for LOVE

Post by trev0006 »

Was having trouble with Geany, your example cleared most of the questions I had. Thanks

MarekkPie wrote:The topic discussing everyone's favorite IDE/text editor has got me wanting to pimp out my current favorite IDE, Geany (http://www.geany.org/). It's lightweight, feature-rich, but not overbearing. I've found a few nice ways to make it more compatible with LOVE.

Customizing Geany for LOVE

(This is written from a Linux perspective, but it should be fairly similar for anyone using different OS's. This is also written for Geany 0.20, so any other version may or may not have the same functionality. See the manual (http://www.geany.org/manual/current/index.html) for better integration with your setup.)

Creating a main.lua template:

You can simplify the start-up of your game by creating a template that will create the main.lua file with whatever useful LOVE functions you normally use for your games. First, create the main.lua file with your most used LOVE functions. Don't go overboard; if you're needing to erase significant portions of your template every time you start making a game, you're doing it wrong. My template is this:

Code: Select all

function love.load()
end

function love.update(dt)
end

function love.draw()
end

function love.keypressed(k)
	if k == "escape" then
		love.event.push("q");
	end
end
Four functions, three of which are completely bare, and one to quickly close the program for use during debugging.

You can customize the template even more, with header comments and the like, but that is a bit beyond the scope of my simple tutorial, so I will merely provide a link to the necessary portions of the Geany manual (http://www.geany.org/manual/current/ind ... -templates).

When you are satisfied with your template, you need to save it in the template directory with a file name that will identify what the template describes (in my case, I saved it as LoveBasicGame.lua, but you can do whatever. This name will have no affect on the filename of any files created from this template). For Linux distributions, the template directory is usually:

~/.config/geany/templates/files/

(If you are trying to access this via the GUI, be sure to enable hidden files to find the .config directory.)

And you're done! Now, whenever you are starting a new project, all you need to do is: File – New (from Template) – LoveBasicGame.lua and your new main.lua will appear. Alternatively, the drop-down arrow next to the New File icon on the toolbar lists the current templates as well. The only issue is that this file will be untitled, so when you first save it, you'll need to save it as main.lua.

Customizing a project for LOVE:

Geany has a a very simple project system. It will reopen all the files that were open the last time the project and/or Geany was closed, and you can customize a few of the properties of the project to take advantage of some built-in Geany functionality. Our main concern is changing the “Execute” command so that the current LOVE game can be run at the push of a button.

After you have created a new project (Project – New), go to Project – Properties, and select the Build tab. Under the heading Execute Commands, change the first list item's command (the second column) to love %p. This will run the love command using the absolute path to your current project's base path. As long as your main.lua file in at the top of that directory, your LOVE game will run using Geany's internal terminal. Now just click the Execute button on the toolbar (the gears) or use the default keybinding F5, and you're set!

Note: As of 1/8/12, it doesn't seem that Geany supports a custom project type (like they do with the templates). Therefore you will need to do this step every time you make a new project for your LOVE games. There may be ways to make it so that this command will run for every .lua file, regardless of its project association, but there are many caveats to this approach, so I will leave that to you to figure out.

---

That's all I have for now. If any other Geany users have any other neat tricks to help implement LOVE into this nice little IDE then feel free to post them here.
Manufacturing car tires and sports cars
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests