let's say end pieces are 30 px wide, mid piece 10px
Call function with parameters where to start (coordinates, param 0 and 1), how many mid pieces there can be (min: param 2, max: param 3)
function "createplattform":
vwidth(localvariable) = 0
-- : create starttile at (function.param(0),function.param(1))
add 30 to vwidth
-- for 1 to floor(random(function.param(2),function.param(3)+1): create midtile at (function.param(0)+vwidth,function.param(1))
add 10 to vwidth
-- : create endtile at (function.param(0)+vwidth,function.param(1))
Just make sure that the origin point of the tile is at 0,0 of the image (not in the middle) or you get overlaps.