Begineer: How do you insert a library

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
xenogia
Prole
Posts: 4
Joined: Fri Oct 15, 2010 11:43 am

Begineer: How do you insert a library

Post by xenogia »

I've noticed people create libraries to help with game development in Love2D? I know this is a stupid question but how do you include it via lua. Is it something like include "blah.lua"?
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Begineer: How do you insert a library

Post by kikito »

It's usually require.

Code: Select all

require 'blah.lua'
The '.lua' part is added automatically if you don't add it.

Sooner or later you will start adding folders. Then you can do

Code: Select all

require 'afolder.asubfolder.blah'
Edit: Note that require only works 'the first time'. If for some reason you need to include the same file more than once, you can use dofile instead.
When I write def I mean function.
xenogia
Prole
Posts: 4
Joined: Fri Oct 15, 2010 11:43 am

Re: Begineer: How do you insert a library

Post by xenogia »

Thanks Kikito, truly appreciated :)
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Begineer: How do you insert a library

Post by bartbes »

kikito wrote: you can use dofile instead.
Actually, you can't, use love.filesystem.load("<filename>")().
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google Adsense [Bot] and 18 guests