-- ************************************************** -- Provide Moho with the name of this script object -- ************************************************** ScriptName = "MS_Convert_JLS_XML" -- ************************************************** -- General information about this script -- ************************************************** MS_Convert_JLS_XML = {} function MS_Convert_JLS_XML:Name() return "Convert JLipSync XML" end function MS_Convert_JLS_XML:Version() return "1.0" end function MS_Convert_JLS_XML:Description() return "Convert XML output from David Cuny's JLipSync into Moho switch data file" end function MS_Convert_JLS_XML:Creator() return "Myles Strous" end function MS_Convert_JLS_XML:UILabel() return("Convert JLipSync XML") end -- ************************************************** -- The guts of this script -- ************************************************** function MS_Convert_JLS_XML:Run(moho) local infilename = LM.GUI.OpenFile("Select Input XML File") if (infilename == "") then return end local f = io.open(infilename, "r") if (f == nil) then return end f:close() local outfilename = LM.GUI.SaveFile("Select Output Switch Data File") if (outfilename == "") then return end local frame_count = 0 local outfile = io.open(outfilename, "w") if (outfile == nil) then return end outfile:write("MohoSwitch1\n") for line in io.lines(infilename) do if string.find(line, "") then frame_count = frame_count + 1 if string.find(line, "") then start_place, end_place, frame_number = string.find(line, "([^<]+)") outfile:write(frame_count .. " " .. frame_number.."\n") end end end outfile:close() end