TexturePacker tips

Hi,

I use Texture Packer but I find no where away to adapt my code automatically. I write a code and I hope it can help some of you. My code also work when you use multi pack

local sheetInfo={}

local sheetArray={} local nbimage=34 --if display.imageSuffix=="@6x" then -- nbimage=8 --elseif display.imageSuffix=="@8x" then -- nbimage=2 --end for i=1,nbimage do sheetInfo[i] = require("test-"..i.."-") sheetArray[i] = sheetInfo[i]:getSheet() end function sheetdata(yo) for i=1,nbimage do local value=sheetInfo[i]:getFrameIndex(yo) if value~=nil then return value,i end end return -1,-1 end function modifyFileTP(modifyFileName) print("fileName "..modifyFileName) --local modifyFileName="chargementbis.lua" function readAll(file) local f = io.open(file, "rb") local content = f:read("\*all") f:close() return content end local fichier=readAll(modifyFileName)--the file I want to modifie function mysplit(inputstr, sep) if sep == nil then sep = "%s" end local t={} ; i=1 for str in string.gmatch(inputstr, "([^"..sep.."]+)") do t[i] = str i = i + 1 end return t end leschaines=mysplit(fichier,"\n") leschainesOri=mysplit(fichier,"\n") leschaines1={} leschainesnumero={}--recupere le numero de ligne for i1=1,#leschaines do leschaines[i1]=string.gsub(leschaines[i1]," ","") leschaines[i1]=string.gsub(leschaines[i1]," ","") leschaines[i1]=string.gsub(leschaines[i1],"%-%-.\*","") if leschaines[i1][1]=='%-' then leschaines[i1]="" end if(string.find(leschaines[i1],"graphics.newImageSheet")==nil)then leschaines[i1]="" else leschaines1[#leschaines1+1]=leschaines[i1] leschainesnumero[#leschainesnumero+1]=i1 end end for i1=1,#leschaines1 do local filename=string.match(leschaines1[i1],'"(.-)"') filename=string.gsub(filename,".png","") filename=string.gsub(filename,".jpg","") filename=string.gsub(filename,".jpeg","") if string.find(filename,"test")==nil then local widthi=string.match(leschaines1[i1],'width=(.-),') local widths=string.match(leschaines1[i1],'sheetContentWidth=(.-),') local heighti=string.match(leschaines1[i1],'height=(.-),') local heights=string.match(leschaines1[i1],'sheetContentHeight=(.-)}') print("filename "..filename) local numberimage=tostring(mathfloor((widths/widthi))\*mathfloor((heights/heighti))) local numberimg=tonumber(string.match(leschaines1[i1],'numFrames=(.-),')) local nomanim=string.match(leschaines1[i1],'(.-)=') --print("nomanim "..nomanim.." filename "..filename) if(numberimg~=numberimage) then -- print("\<sdfsqrfdrg\n\n\n\n\n") end print(filename.." "..(widths/widthi).." "..(heights/heighti).." "..numberimg.." "..numberimage) local frameindex,sheetnametemp=sheetdata(filename) sheetname="test-"..sheetnametemp.."-.png" --print("frameindex "..frameindex.." sheetnametemp "..sheetnametemp) if frameindex~=-1 then local options=sheetArray[sheetnametemp]['frames'][frameindex] --print("options.height="..options.height) -- -- if(mathfloor(heights/heighti)~=heights/heighti) then -- -- print("filename "..filename.." error prop "..(heights/heighti).." "..mathfloor(heights/heighti)) -- -- end -- -- if (mathfloor(options.height/mathfloor(heights/heighti))~=options.height/mathfloor(heights/heighti))then -- -- print("not divisible by "..filename) -- -- end -- -- if(mathfloor(widths/widthi)~=widths/widthi) then -- -- print("filename1 "..filename.." error prop") -- -- end -- -- if (mathfloor(options.width/mathfloor(widths/widthi))~=options.width/mathfloor(widths/widthi))then -- -- print("not divisible1 by "..filename) -- -- end -- options.height=mathfloor(options.height/mathfloor(heights/heighti)) -- options.width=mathfloor(options.width/mathfloor(widths/widthi)) options.height=mathfloor(options.height/(heights/heighti)) options.width=mathfloor((options.width/(widths/widthi))) options.numframes=numberimg local optionsString="" for key,value in pairs(options) do if(key=="numframes")then key="numFrames" end optionsString=optionsString..key.."="..value.."," end optionsString=string.sub(optionsString,1,-2) -- local replaceString=nomanim.."=graphics.newImageSheet(\""..sheetname.."\",{"..optionsString.."}) --"..filename local optionfs="" local optionf={} optionf.sheetContentWidth= 2048 optionf.sheetContentHeight=2048 optionfs=optionfs.."sheetContentWidth="..optionf.sheetContentWidth..",sheetContentHeight="..optionf.sheetContentHeight optionf.frames={} optionfs=optionfs..",frames={" local nbimagex=mathfloor(widths/widthi) local nbimagey=mathfloor(heights/heighti) local xfait=0 local yfait=0 local xori=options.x local yori=options.y for i=1,numberimg do local xtemp=xori+xfait\*options.width local ytemp=yori+yfait\*options.height local widthtemp=options.width local heighttemp=options.height optionfs=optionfs.."{x="..xtemp..",y="..ytemp..",width="..widthtemp..",height="..heighttemp.."}" if(i\<numberimg)then optionfs=optionfs.."," else optionfs=optionfs.."}" end xfait=xfait+1 if(xfait+1\>nbimagex) then xfait=0 yfait=yfait+1 end end local replaceString=nomanim.."=graphics.newImageSheet(\""..sheetname.."\",{"..optionfs.."}) --"..filename leschaines1[i1]=replaceString print(replaceString) else print("unvalid") local replaceString=leschaines1[i1] end else print("Deja traiter "..filename) end leschainesOri[leschainesnumero[i1]]=leschaines1[i1] end local lefichierNew="" for i=1,#leschainesOri do lefichierNew=lefichierNew.."\n"..leschainesOri[i] end local f = io.open(modifyFileName, "wb") f:write(lefichierNew) f:close() end

I am sorry for my english but this code can realy help you.