local getFile, saveFile, fileName -- Get name of file to convert repeat cprintf(cli.lightgreen,"\nPlease enter the name of the waypoint file to convert. Include path relative to this script. Eg. rom/waypoints/mywaypoint.xml\n") printf(" > ") fileName = io.stdin:read() if fileName:lower():sub(-4,-1) ~= ".xml" then fileName = fileName .. ".xml" end getFile = io.open(getExecutionPath().."/".. fileName) if getFile == nil then cprintf(cli.yellow,"waypoint file \""..getExecutionPath().."/".. fileName.."\" does not exist.\n") end until getFile ~= nil -- Get name of new file to save repeat cprintf(cli.lightgreen,"\nPlease enter the name of the new file you wish to save.\n") fileName = io.stdin:read() if fileName:lower():sub(-4,-1) ~= ".xml" then fileName = fileName .. ".xml" end saveFile = io.open(getExecutionPath().."/".. fileName,"w") if saveFile == nil then print("Could not create waypoint file \""..getExecutionPath().."/".. fileName.."\".") end until saveFile ~= nil for line in getFile:lines() do local x = string.match(line,"x%s*=%s*\"(%-*%d*)") local z = string.match(line,"z%s*=%s*\"(%-*%d*)") local y = string.match(line,"y%s*=%s*\"(%-*%d*)") local code = string.match(line,"(.*)") or string.match(line,"(.*)") if x and z then if y then saveFile:write("\tplayer:moveTo(CWaypoint("..x..", "..z..", "..y.."),true)\n") else saveFile:write("\tplayer:moveTo(CWaypoint("..x..", "..z.."),true)\n"); end if string.match(code,"[^%s]+") then saveFile:write(code.."\n") end else saveFile:write(line.."\n") end end getFile:close() saveFile:close()