[PROJECT] Löve2D boilerplate

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
FireZenk
Prole
Posts: 25
Joined: Tue Apr 09, 2013 4:14 pm
Location: Valencia, Spain
Contact:

[PROJECT] Löve2D boilerplate

Post by FireZenk »

Hi,
I am new to Löve2D but I have quite expenciencia in programming world.
I thought that together we could make a "starter kit" to have a full stuff to begin each new project with Löve2D,
for now I've started on github and I hope your help.

The idea is that every time someone needs to start a new project can simply clone the repository and have a good template for a quick start to develop.

GitHub: https://github.com/FireZenk/L-ve2D-boilerplate

Git clone: https://github.com/FireZenk/L-ve2D-boilerplate.git

ZIP: https://github.com/FireZenk/L-ve2D-boil ... master.zip

:neko:
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: [PROJECT] Löve2D boilerplate

Post by MarekkPie »

Looks neat, but I'd move away from using the module function to create your modules. It's depreciated in Lua 5.2, so if LOVE ever makes the switch you'd need to restructure all your modules.
FireZenk
Prole
Posts: 25
Joined: Tue Apr 09, 2013 4:14 pm
Location: Valencia, Spain
Contact:

Re: [PROJECT] Löve2D boilerplate

Post by FireZenk »

MarekkPie wrote:Looks neat, but I'd move away from using the module function to create your modules. It's depreciated in Lua 5.2, so if LOVE ever makes the switch you'd need to restructure all your modules.
Thanks, and how modules are now created with LUA 5.2?
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: [PROJECT] Löve2D boilerplate

Post by MarekkPie »

I usually just wrap all my module functions in a table as the end of the file, and return it:

Code: Select all


local function foo(a)
  --...
end

local function bar(a)
  --...
end

return {
  foo = foo,
  bar = bar,
}
Alternatively, if you'd rather not write local all the time, declare a table and make functions values in the table:

Code: Select all

local Module = {}

function Module.foo(a)
  --...
end

function Module.bar(a)
  --...
end

return Module
FireZenk
Prole
Posts: 25
Joined: Tue Apr 09, 2013 4:14 pm
Location: Valencia, Spain
Contact:

Re: [PROJECT] Löve2D boilerplate

Post by FireZenk »

Ok, thanks! will update ASAP! :awesome:

EDIT:
I need to do something to access these modules from the main.lua using your second option? with "require" does not work.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: [PROJECT] Löve2D boilerplate

Post by Nixola »

Code: Select all

--module.lua
local module = {}
module.foo = function()--[[...]]end
module.bar = function()--[[...]]end
return module

--main.lua
fooBar = require 'module'
fooBar.foo()
fooBar.bar()
Last edited by Nixola on Wed Apr 10, 2013 12:11 pm, edited 1 time in total.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
FireZenk
Prole
Posts: 25
Joined: Tue Apr 09, 2013 4:14 pm
Location: Valencia, Spain
Contact:

Re: [PROJECT] Löve2D boilerplate

Post by FireZenk »

Done :megagrin:
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 7 guests