First off, really great app guys. I’m already having a ton of fun with it.
I have a question in regards to Codea’s capabilities. I am wondering if codea can be used to grab a bunch of user input and save the file to be used in some old software I wrote in C#.
Can I save a Lua table in codea for export?
Can this be done by saving to dropbox?
Is there any way for Codea to allow use of email, as in sending the saved file?
Can I serialize a table to binary?
I’m not looking for a how to just wondering how doable it is.
Hi @Briarfox. You can save files using the Lua io.* library (tutorial http://lua-users.org/wiki/IoLibraryTutorial). This will allow you to write to the Dropbox folder, locally to the device, or you could instead use http.request in order to send your data over a network.
Here is a section on binary files: http://www.lua.org/pil/21.2.2.html
You can serialize a table, there were some recursive implementations around here and on the net. I think several Lua JSON libraries also implement recursive table serialization
for built-in types.
Thanks Simeon! I’m really loving Codea. Once again I appreciate the response!
Interesting thought… What exactly would the file path be for a dropbox file? Also, would it theoretically be possible to use Dropbox as an extended version of ‘save/read LocalData’?
The path can be found using
os.getenv("HOME"). For example:
This following is taken from @ruilov’s GitHub client (https://github.com/ruilov/GitClient-Release/blob/master/LuaSandbox.lua)
-- load Info.plist
local home = os.getenv("HOME")
local dir = home.."/Documents/"..projectName..".codea/"
local info_fname = dir.."Info.plist"
local info_file = io.open(info_fname,"r")
assert(info_file~=nil,"Could not open "..info_fname.." in "..projectName)
local contents = ""
for line in io.lines(info_fname) do
contents = contents..line.."\
The Dropbox.spritepack folder would be found in:
thanks @Simeon. I’ve got an idea brewing…