Aligne texte un Arry with string.format ----> do colons

i don’t know why the texte is not aligne correctly

    txt=string.format("%5d\\t%15.15s\\t%15.15s",num,ligne[1],ligne[2])  
function setup()
    displayMode(FULLSCREEN)
    clearLocalData()
    liste=listLocalData()
    -- creer une liste vide
    if #liste==0 then   
        for i=1,10 do
            str=string.format("%2d",i)
            str="name "..str
            saveLocalData(str,math.random(1,300))
        end
        liste=listLocalData()
    end
    -- create table with scores and ligne#
    scores={}
    for num,ligne in pairs(liste) do
        table.insert(scores,{readLocalData(ligne),ligne})
    end
end


function draw()
    background(39, 40, 50, 255)
    fill(255, 0, 169, 255)
    fontSize(40)
    textMode(CORNER)
    text("Place        Score         Name",300,550)
    for num,ligne in ipairs(scores) do  
        txt=string.format("%5d\\t%15.15s\\t%15.15s",num,ligne[1],ligne[2])  
        text(txt,290,550-45*num)       
    end
end

function touched(touch)
    if CurrentTouch.state==BEGAN then
        table.sort(scores,function(a,b) return(a[1]>b[1]) end)
    end
end

@franck You have to use the font Courier. I’m not sure if there are other ones that will align.

@franck fontsize and textMode can be moved into setup since they only need to be executed once since you’re not changing their values. Plus you’ll have to change your string.format values.

Menlo is another fixed-width font on the iPad

Isn’t there also a font called Monospace?

Monospace isn’t on my iPad. The font picker in Codea doesn’t show all the system fonts that are on your iPad (which varies with iOS version), and it also adds a few (which presumably are bundled with Codea). Just noticed the Codea font picker also has Inconsolata and something called Source, which looks like it could be fixed width.