Page 1 of 1

Can anyone explain how examples.love works?

Posted: Sat Oct 19, 2013 7:08 pm
by timmeh42
(Apologies for the hideous title, I have no idea how to explain it concisely)

In the Love wiki tutorials section ([wiki]Category:Tutorials[/wiki]) there is a .love file of a large number of example .loves combined into one (bottom of the list), with a main window giving the user the option to choose different files to load. However, each file seems to be completely separate and independent from the main loader.
How does the main window load each example love and so easily return to the main window? I have looked at the code, but amongst all the functions for displaying the scrollbox in the window, and considering the fact that I am not familiar with the functions used in the first place, I can't see how it works.

Re: Can anyone explain how examples.love works?

Posted: Sun Oct 20, 2013 1:26 am
by Azhukar
Line 140 of main.lua inside the .love : love.filesystem.load(file)()

It calls the specified file as if it was a function. The examples override keys in the global variable "love", which are afterwards called from the framework and main.lua.

Re: Can anyone explain how examples.love works?

Posted: Sun Oct 20, 2013 2:49 pm
by timmeh42
Ah, thank you for that - much easier for me to unravel it all now.