Copyable Example Code
You can paste this into the code editor; still verify target image, region, color, text, and timing values in your own device flow.
-- OCR skor okuyucu / OCR score reader
-- Region.readAsString + Num.parseOcr ile OCR hatalarini tolere et
local scoreRegion = Region(800, 100, 280, 80)
local bestKey = "en_yuksek_skor"
Snap.screenRefresh()
-- Bolgeyi oku, OCR-tolerant sayiya cevir
local rawText = scoreRegion:readAsString()
local score = Num.parseOcr(rawText, 0)
if score <= 0 then
toast("Skor okunamadi: '" .. rawText .. "'")
return
end
-- Mevcut rekor ile karsilastir
local bestScore = KV.getNumber(bestKey, 0)
if score > bestScore then
KV.set(bestKey, score)
KV.increment("rekor_kirilma_sayisi", 1)
System.vibrate(300)
System.noti("Yeni rekor!", "Skor: " .. score .. " (onceki: " .. bestScore .. ")")
else
toast("Skor: " .. score .. " (rekor: " .. bestScore .. ")")
end
-- Son 10 skoru append ile sakla
local history = KV.get("skor_gecmisi", "")
local newEntry = score .. ","
if #history > 200 then
history = history:sub(-100)
end
KV.set("skor_gecmisi", history .. newEntry)