# Is it possible to have the main callback functions in different files with love2d?

Is it possible to have love.load(), love.draw() and love.update() in different files? and if so how would I go about doing that?

EDIT

It seems I misunderstood your question; you are not asking how to switch between different callbacks, you want to have them in different files.

The principle is the same:

load_module = require "main_load"


I've written a scene manager to do just that. I will open source it some day but to give you an idea here's how it is used:

-- main.lua
scene_manager.change("foo")
end


The change method looks like this:

  unload_scene()
current_scene = scenes[scene_name]

Basically you need to iterate over the various methods (load, update as well as mousereleased for instance) and then do love[method_name] = nil.
Then in load_scene you need to set it love[method_name] = current_scene[method_name].