-- title: Xin chào -- blurb: Ví dụ nhỏ nhất: một bộ đếm bấm được -- The smallest script app: a counter that survives restarts. Copy this folder to /apps/ on the card. local count = 0 function open() count = tonumber(data.load() or "0") or 0 end function draw() gfx.text(24, 150, "Xin chào từ Lua!", 36, true) gfx.text(24, 210, "Bấm nút để đếm. Số đếm được lưu lại.", 22) gfx.text(24, 300, tostring(count), 120, true) gfx.button(24, 520, 340, 90, "+1", 40, true) gfx.button(394, 520, 340, 90, "Về 0", 32) end function tap(x, y) if y >= 520 and y < 610 then if x < 380 then count = count + 1 else count = 0 end data.save(tostring(count)) return true -- draw again end return false end function key(k) if k == "select" then count = count + 1; return true end return false end