how to display an information like this 3,1 instead of 3,125454587887

hi,

how to display an information like this 3,1 instead of 3,125454587887

it’s seem that is possbile wtih string.fmat but i can’t do it

thanks for your response

local function testPosition (event) print("CircleonTransition.x",CircleonTransition.x) local textInfo = display.newText("", 240,105,native.systemFont,20) textInfo:setFillColor(1,1,1) textInfo.text = "("..CircleonTransition.x..")" Runtime:addEventListener("enterFrame", testPosition)

[lua]

local decimalValue = function (val, places)

      local factor = 1

      for i = 1 , places, 1 do

            factor = factor * 10

      end

      local rounded = math.round(val * factor)/factor

      return rounded

end

print (decimalValue(CircleonTransition.x, 1 )) – one decimal place

print (decimalValue(CircleonTransition.x, 2 )) – two decimal places

[/lua]

[lua]

local decimalValue = function (val, places)

      local factor = 1

      for i = 1 , places, 1 do

            factor = factor * 10

      end

      local rounded = math.round(val * factor)/factor

      return rounded

end

print (decimalValue(CircleonTransition.x, 1 )) – one decimal place

print (decimalValue(CircleonTransition.x, 2 )) – two decimal places

[/lua]