Skip to main content
se eliminaron 4 caracteres en el cuerpo
Origen Enlace
polu
  • 41
  • 5

Estoy intentando comparar las tablas score[1] y highscore[1] para obtener la puntuación más alta y grabarla en highscore.json pero no me funciona. ¿Alguien me puede ayudar? Gracias

local function onCollision_1(event)
if event.phase == "began" then

    local agro = event.object1
    local hit = event.object2
    if agro.type == "ball" and hit.type == "exit" then
    elseif agro.type == "exit" and hit.type == "ball" then

        initialtime.text = initialtime.text + clockText.text
        score = {}
        highscore = {}
        highscore[1] = tiempoinicialinitialtime.text
        score[1] = tiempoinicialinitialtime.text
        loadsave.saveTable(score, "score.json", system.DocumentsDirectory)          
        score = loadsave.loadTable("score.json", system.DocumentsDirectory)  
        
    if  score[1] > highscore[1] then
        loadsave.saveTable(highscore, "highscore.json", system.DocumentsDirectory)
        highscore = loadsave.loadTable("highscore.json", system.DocumentsDirectory)
    else

end
showpoints = function() storyboard.gotoScene("play", "fade", 800) end timer.performWithDelay(2000, showpoints)
end end end

Estoy intentando comparar las tablas score[1] y highscore[1] para obtener la puntuación más alta y grabarla en highscore.json pero no me funciona. ¿Alguien me puede ayudar? Gracias

local function onCollision_1(event)
if event.phase == "began" then

    local agro = event.object1
    local hit = event.object2
    if agro.type == "ball" and hit.type == "exit" then
    elseif agro.type == "exit" and hit.type == "ball" then

        initialtime.text = initialtime.text + clockText.text
        score = {}
        highscore = {}
        highscore[1] = tiempoinicial.text
        score[1] = tiempoinicial.text
        loadsave.saveTable(score, "score.json", system.DocumentsDirectory)          
        score = loadsave.loadTable("score.json", system.DocumentsDirectory)  
        
    if  score[1] > highscore[1] then
        loadsave.saveTable(highscore, "highscore.json", system.DocumentsDirectory)
        highscore = loadsave.loadTable("highscore.json", system.DocumentsDirectory)
    else

end
showpoints = function() storyboard.gotoScene("play", "fade", 800) end timer.performWithDelay(2000, showpoints)
end end end

Estoy intentando comparar las tablas score[1] y highscore[1] para obtener la puntuación más alta y grabarla en highscore.json pero no me funciona. ¿Alguien me puede ayudar? Gracias

local function onCollision_1(event)
if event.phase == "began" then

    local agro = event.object1
    local hit = event.object2
    if agro.type == "ball" and hit.type == "exit" then
    elseif agro.type == "exit" and hit.type == "ball" then

        initialtime.text = initialtime.text + clockText.text
        score = {}
        highscore = {}
        highscore[1] = initialtime.text
        score[1] = initialtime.text
        loadsave.saveTable(score, "score.json", system.DocumentsDirectory)          
        score = loadsave.loadTable("score.json", system.DocumentsDirectory)  
        
    if  score[1] > highscore[1] then
        loadsave.saveTable(highscore, "highscore.json", system.DocumentsDirectory)
        highscore = loadsave.loadTable("highscore.json", system.DocumentsDirectory)
    else

end
showpoints = function() storyboard.gotoScene("play", "fade", 800) end timer.performWithDelay(2000, showpoints)
end end end

Origen Enlace
polu
  • 41
  • 5

comparar dos tablas para grabar la puntuación más alta

Estoy intentando comparar las tablas score[1] y highscore[1] para obtener la puntuación más alta y grabarla en highscore.json pero no me funciona. ¿Alguien me puede ayudar? Gracias

local function onCollision_1(event)
if event.phase == "began" then

    local agro = event.object1
    local hit = event.object2
    if agro.type == "ball" and hit.type == "exit" then
    elseif agro.type == "exit" and hit.type == "ball" then

        initialtime.text = initialtime.text + clockText.text
        score = {}
        highscore = {}
        highscore[1] = tiempoinicial.text
        score[1] = tiempoinicial.text
        loadsave.saveTable(score, "score.json", system.DocumentsDirectory)          
        score = loadsave.loadTable("score.json", system.DocumentsDirectory)  
        
    if  score[1] > highscore[1] then
        loadsave.saveTable(highscore, "highscore.json", system.DocumentsDirectory)
        highscore = loadsave.loadTable("highscore.json", system.DocumentsDirectory)
    else

end
showpoints = function() storyboard.gotoScene("play", "fade", 800) end timer.performWithDelay(2000, showpoints)
end end end