Read mavlink rangefinder distance using lua scripts

hi everyone, i am new to lua scripts and this question may be very simple. i have an optical flow sensor MTF-02p. this sensor integrated a rangefinder. the type of rangefinder is mavlink and it is facing downward. i need to read its distance data using lua scripts. first i considered filtering mavlink distance_sensor messages. this method worked but had ‘exceed time limit‘ problem. so i am wondering if there is another method than can get the distance more directly. so i tried the codes below:

rt=Parameter(‘RNGFND1_TYPE’):get()
ro=Parameter(‘RNGFND1_ORIENT’):get()

these two lines get right, 10 and 25

but the code below does not work:

ns=rangefinder:num_sensors()
	local rngfnd_backend
	local uu
	for uu=0,ns-1 do
		rngfnd_backend = rangefinder:get_backend(uu)
		
		if rngfnd_backend~=nil then
			gcs:send_text(6,string.format("Searching! %d",uu))
			gcs:send_text(6,string.format("dist=%d",rngfnd_backend:distance()))
		end
	end

and i get the error below:

Lua: /APM/scripts/mvlt02.lua:52: bad argument #2 to ‘format’ (number has no integer representation)

so can you help me to tell where is wrong, thanks a lot.