Apple Corona Basic Functions Changes to Lua
Functions Removed
For security reasons, you cannot dynamically load raw Lua code. Consequently, the following standard Lua functions are not available in Corona:
功能移除
出於安全原因,您不能動態加載原始的Lua代碼。因此,下面的標準的Lua功能不可用在電暈:
dofile()
load()
loadfile()
loadstring()
Using Lua as a configuration language
Sometimes Lua scripts are used as a human-readable configuration files. In these cases, you have data stored as Lua tables in a raw Lua file. However, because of the above changes to Lua, you cannot load uncompiled Lua scripts dynamically in Corona. Instead, we recommend several options:
使用Lua作為配置語言
有時 Lua腳本被用來作為人類可讀的配置文件。在這種情況下,你有數據表的形式存儲在原始的Lua Lua的文件。但是,由於上述變動到Lua,你不能加載未編譯 Lua腳本中動態電暈。相反,我們建議以下幾種選擇:
- If the data in the table is static, you can just include it in a Lua file in your Corona project.
- For dynamic data, you can serialize a Lua table into some file format or use some alternative format like XML.
- 如果表中的數據是靜態的,你可以把它包含進來一個 Lua文件在您的電暈項目。
- 對於動態數據,您可以序列化一個 Lua表到一些文件格式或使用一些其他格式,如XML。
Here are some more resources:
這裡有更多的資源
- Table Serialization. There's Section 12.2 of the Programming in Lua (2nd ed). Also, there'shttp://lua-users.org/wiki/TableSerialization
- XML. We're not completely satisfied with the options out there, but there are options for lua-based xml parsing: http://lua-users.org/wiki/LuaXml
