Heya
I'm pretty new here and had a quick question. I'd like to separate some of the functionality in other files, however I'm not sure how to include their functionality in the love.draw(), love.update() and etc. functions.
To be more specific, I'd like to create a window and have all the information for it in a separate file (so I can keep the main file readable) and then to call it in love.draw(), love.update() and to also call functions that might have been declared in that file.
I read about "require", however I am not sure how to create the object I've declared in the other file.
Thanks in advance.
Using separate files for some functionality
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Using separate files for some functionality
Sorry, after some trial and error it turned out that I can define functions in any file, then "require" it, and then call those functions under whichever LOVE function I want.
Well, since I already wasted your time reading this thread, I think I'd at least say that the engine is great and a whole lot of fun to work with. Thanks for making it
Well, since I already wasted your time reading this thread, I think I'd at least say that the engine is great and a whole lot of fun to work with. Thanks for making it
Re: Using separate files for some functionality
you should also know that you can return a value (in most cases a table) from a file and save that value when you require it, that way you don't have to pollute the global scope with everything you use.Neekoy wrote:Sorry, after some trial and error it turned out that I can define functions in any file, then "require" it, and then call those functions under whichever LOVE function I want.
Well, since I already wasted your time reading this thread, I think I'd at least say that the engine is great and a whole lot of fun to work with. Thanks for making it
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 5 guests