3

loadstring() and loadfile() Lua functions allow loading remote libraries and modules at runtime. As shown in this post it is very simple: How Do I Load Lua Module as a String Instead of a File?

Unfortunately Corona SDK has removed both these function. Here's a list of changes they have.

Is it possible to implement loadstring in lua or load it from a separate module? They seem to provide a solution here but I don't really understand it and I don't think it will work in Corona cause it requires dofile which is also disabled in Corona http://lua-users.org/lists/lua-l/2012-04/msg00875.html

Community
  • 1
  • 1
nest
  • 1,385
  • 1
  • 15
  • 34
  • 2
    You can still use `require`? – hjpotter92 Oct 10 '13 at 23:15
  • require cannot handle a file url outside resource directory. So it does not work to load remote modules – nest Oct 11 '13 at 14:24
  • 2
    Could you please explain what you mean by remote modules? – hjpotter92 Oct 11 '13 at 16:07
  • yes, it means loading modules stored in a server, for example the module could be in `http://myserver/source/myawesomemodule.lua` and it would be loaded the following way: `local awesomeModule=loadfile(http.require"http://myserver/source/myawesomemodule.lua")` instated of `require("myawesomemodule.lua")`. Thanks! – nest Oct 13 '13 at 21:38

1 Answers1

0

loadstring() and dofile() are disabled per Apple's rules for allowing interpreted language apps to work on their devices. Apple will reject any app that has any dynamic programming features.

Rob Miracle
  • 3,053
  • 1
  • 13
  • 12
  • I only mean to use it during development. Is there a way to have those functions available again? I noticed that they are available in Corona Enterprise but it would be cool to have them in Corona Pro as well. – nest Oct 14 '13 at 09:46