I use to be able to use require("|D|filename") but I just upgraded from 2012.2 (something) to 2012.8.1 and now it doesn't work. Does anyone know what has changed?
I haven't tested on 2012.2.x yet but it shouldn't work on it either.
require searches for a Lua loader using the path stored in package.path. If you want, you can change it so that it doesn't prepend "./" in front of module name:
Exactly. And as a side note, it's only used by require command and nothing else. If you want, there are plenty of information here http://www.lua.org/manual/5.1/manual.html (search for package.path)
FWIW - Use of dofile() could get your app rejected by Apple. They do not allow "local" or downloaded code / scripts to be parsed / executed. Could lead to all sorts of nasty issues so there's a blanket stop on it
WhiteTree Games - Home, home on the web, where the bits and bytes they do play! #MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
FWIW - Use of dofile() could get your app rejected by Apple. They do not allow "local" or downloaded code / scripts to be parsed / executed. Could lead to all sorts of nasty issues so there's a blanket stop on it
So, it's OK to save and read text files line by line to |D| using read and write but not to use do file()?
Yeah, actually I was thinking about this and I realized that I'm building my game with dofile in mind. I'm wondering if I'm going to have to change that.
And one of my first concerns with Lua was its ability to execute code from anywhere. I think it is also possible to read a text file using the io library and then execute it. I'm not sure though.
To execute a string use loadstring(). It would be interesting to see if Apple denies any apps that use loadstring(), loadfile(), dofile(), or require().
I guess as long as you are not downloading any text (script) or bytecode from anywhere and then executing that using the dofile, Apple should not have an issue. However, other frameworks have sandboxed the loadstring, dofile and loadfile and thereby gotten a blanket approval for that framework. It is strange that Apple encourages that images and assets are downloaded by the app from a website to keep the app slim, but when a developer wants to download some levels, etc (scripts) and they do not allow that, instead encourage updates that take time to review, can be large in terms of size (20+ MB for updates, no delta patches/updates). Well, that is how it is, they call the shots and since we want to play in that playground, we have to abide by their rules.
Lastly, Apple is not a single entity, but a group of reviewers, some with more common sense than some others. Some more lax than others, so you will see all sort of things happen on the App store. One app with a particular feature will get approved and you might be in strife with a reviewer over the same feature.
Comments
require searches for a Lua loader using the path stored in package.path. If you want, you can change it so that it doesn't prepend "./" in front of module name:
My apps: http://www.yummyyellow.com
Is that means we can download any lua file from the network and save it in the |D| direcory and excute it?
https://sites.google.com/site/xraystudiogame
https://sites.google.com/site/xraystudiogame
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
https://sites.google.com/site/xraystudiogame
My apps: http://www.yummyyellow.com
And one of my first concerns with Lua was its ability to execute code from anywhere. I think it is also possible to read a text file using the io library and then execute it. I'm not sure though.
My apps: http://www.yummyyellow.com
http://www.lua.org/pil/8.html
My apps: http://www.yummyyellow.com
Lastly, Apple is not a single entity, but a group of reviewers, some with more common sense than some others. Some more lax than others, so you will see all sort of things happen on the App store. One app with a particular feature will get approved and you might be in strife with a reviewer over the same feature.
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps