配列っぽいテーブルに要素を追加する
local t = {} table.insert(t, 1) table.insert(t, "a")
http://lua-users.org/wiki/TablesTutorial
ファイルを読み込んで1行ずつ処理する
local path = system.pathForFile("foo.txt") local f = io.open(path, "r") for line in f:lines() do print(line) end
http://symfoware.blog68.fc2.com/blog-entry-454.html
なおsystem.pathForFile
はCorona SDKのAPIで、デフォルトでmain.luaのあるディレクトリを基点としたパスを返す。
not equal
if "スーパーマン" ~= "クラーク・ケント" then print("別人です") else print("同一人物です") end
文字列のtrim(もしくはsplit)
function trim(s) return s:gsub("^%s*([^%s]*)%s*$", "%1") end
http://lua-users.org/wiki/CommonFunctions
乱数
math.randomseed(os.time()) math.random(1,10) math.random(1,10) math.random(1,10)
seedは無くても動く。