hi,
it would be useful to have a way of including the contents of another file into my lua script
eg
setup.lua
1 | initStuff() |
level1.lua
1 2 | loadfile("setup.lua") doStuff() |
level2.lua
1 2 | loadfile("setup.lua") doStuff() |
i wanted to try do this when amending the Ghosts project so all the duplicate code could just be moved into a couple of generic include files
thanks
j
@jmp909: I also looked into this when creating the sample app. I plan on eventually expanding on the sample app, using different graphics and changing a lot of things up to create a fully-functional game. Once I find the best way to modularize that code I'll share it, hopefully you come up with a solution before me :-)
loadfile and dofile are in effect disable to to restrictions on the Apple SDK Developer Agreement.
Carlos
ok thanks carlos
i can just restructure with a module
regards
j
Thanks to Lua's flexibility it's not particularly hard to modularize repetitious code. Here's an example I wrote with one approach to doing that:
http://developer.anscamobile.com/forum/2010/12/12/finding-objects-parent#comment-14209
why does it have to be compiled while runtime???
Couldn't it be done, we as Devs just get that feature from Corona
and CORONA ... before creating our iOS/Android Code, does create
LUA Files that put that pieces together.
That would help us Devs to program even more effective and Apple
gets one piece of code :)
Logic??
chris
It's for security reasons (apple's point of view)
It's for security reasons (apple's point of view)
ie level1.lua is effectively
variables defined local in setup.lua would actually be local to level1.lua (ie setup.lua isn't parsed directly, it's code is just included into level1.lua)