Hi, I’m new and am fumbling my way through Lua and Corona to try and build an app. I’m using the learning by doing approach, with help from a book I bought and all the guides and tutorials I found on here.
Anyway, my problem is data arrays [that name may be incorrect though it’s how I would have thought of them when I actually used to code back in the 80s/90s].
What I’m trying to do is load (and later save) a file of character information (for a role play encounter manager). So the file would contain something like:
Fred, Human, 12, false, 4
Jane, Elf, 18, true, 3
Bert, Human, 17, 3
I’m presuming from what I’ve read that I would load this in to a table ( declared by something like charTable = {} )
and then have a row per character ( charTable[i] ) and within that the details such as charTable[i].Name, charTable[i].Race.
First off, I think that kind of thing is right, though would appreciate someone saying yes or no on that.
Now, I’ve create a text file with this stuff and I’m opening it fine, using the
for line in file:lines() do
end
approach from the documentation on here.
My problem (after all this typing) is that this reads in the whole line and I want to split it into the separate items. But I can’t see anything that helps me find out how to do that.
Can anyone help me with this (I’m cool with a simple “go read this …”) and also, am I going about this the wrong way completely?
Thanks in advance for any help
Guy