in a module without the scene functions of composer, so I have access to (for example) the composer.state tables and values inside the module?
Can this cause problems during a scene change?
With module I mean something like this:
local mod={} local composer=require "composer" loca dostuff=function() -- code here composer.state.money=1000 end mod.dostuff=dostuff return mod
I then require the module inside a “normal” composer scene at top of this scene with:
local module=require("module")
Can this be done without “problems” during a scene change, reload of the scene, etc.?
you can safely do this anywhere, as all it does it pull in a reference to the already-loaded* composer module.
*the only time you might encounter something weird is if you include a module (that includes composer) early on, in main.lua, before main.lua itself had required composer. in that case your module’s require will load composer and main’s require will pull the reference. even that should work properly for 99% of all “normal” uses. only if you have some very special requirements about the timing of the composer load (because it does do some work at load time) might this be an issue. if this makes no sense to you then you’re not in the 1% that needs to even consider it.
you can safely do this anywhere, as all it does it pull in a reference to the already-loaded* composer module.
*the only time you might encounter something weird is if you include a module (that includes composer) early on, in main.lua, before main.lua itself had required composer. in that case your module’s require will load composer and main’s require will pull the reference. even that should work properly for 99% of all “normal” uses. only if you have some very special requirements about the timing of the composer load (because it does do some work at load time) might this be an issue. if this makes no sense to you then you’re not in the 1% that needs to even consider it.