[Resolved] Inserting numbers in to a string

Does any one know how to insert numbers in to a string or text? Here’s an example of what I was trying to do:

local correct = 59  
local total = 300  
  
local showResults = display.newText( "You got " + correct + " correct out of " + total, 0, 0, native.systemFont, 20)  

Apparently Lua doesn’t like to add strings to numbers, and it doesn’t seem to want to add strings to strings either. I also tried this:

local correct = 59  
local total = 300  
  
--convert to string values  
local correctString = string.format( correct )  
local totalString = string.format( total )  
  
local showResults = display.newText( "You got " + correctString + " correct out of " + totalString, 0, 0, native.systemFont, 20)  

That mucks up everything, the program won’t even run when I try it. I’m sure this is one of those simple things that I’m just missing. I really don’t want to use four different variables to display this correctly. Any suggestions would be greatly appreciated! [import]uid: 155792 topic_id: 27672 reply_id: 327672[/import]

LIke this:

local showResults = display.newText( "You got " .. correctString .. " correct out of " .. totalString, 0, 0, native.systemFont, 20) [import]uid: 84637 topic_id: 27672 reply_id: 112363[/import]

Thanks Danny! I knew there had to be a simple way to do this. That worked perfectly! [import]uid: 155792 topic_id: 27672 reply_id: 112369[/import]

Your welcome! [import]uid: 84637 topic_id: 27672 reply_id: 112371[/import]