lualua-tablelove2d

I want treat `variable..'['..i..']'` as a indexing attempt


here my code blows up: love.graphics.print(jugador..'['..i..']', i * 100, 10) I tried 'jugador'..'['..i..']' so i want help to get this jugador[1], jugador[2], jugador[n] treated a an indexing attempt not a text or something else...


Solution

  • love.graphics.print(jugador[i], i * 100, 10)
    

    is what you want, or based on your description in the comments

    local color = jugador[i].color
    local str = color[1] .. ", " .. color[2] .. ", " .. color[3]
    love.graphics.print(str, i * 100, 10)
    

    You will also need to understand loops loops.