display object from external file

Hi, i have too many lines of code based on the levels in my game, what i want to do is use external (require) file to load images/objects for that level, these will be reused throughout the level. so what i am asking is…

  1. how do you create the function in the required file to load the image?

  2. how do you call it into your local file to display in the display group?

Any help is appreciated.

Apple does  not permit loading of executable code.  However any data you can put in a Lua table can be saved out using JSON (json.encode) and loaded back in and turned back into a table using json.decode.  You can’t save out live image data or functions, but you could save out filenames and coordinates, speed, etc. and load that in for each level.  Then you could use the filenames to create the images to build the levels.

Apple does  not permit loading of executable code.  However any data you can put in a Lua table can be saved out using JSON (json.encode) and loaded back in and turned back into a table using json.decode.  You can’t save out live image data or functions, but you could save out filenames and coordinates, speed, etc. and load that in for each level.  Then you could use the filenames to create the images to build the levels.