--[[ Place this script in the /scripts/menu/ directory of your ASP application installation directory. This script prompts the user for a dat file produced from Papagayo. The dat file is parsed and the name of an action and the frame number is extracted. At this point no error checking has been added so you MUST have 10 actions for the layer selected that match the 10 phonemes used by papagayo and you must be on the layer that has these actions them. --]] -- ************************************************** -- Provide Moho with the name of this script object -- ************************************************** ScriptName = "HV_Actiondatimport" -- ************************************************** -- General information about this script -- ************************************************** HV_Actiondatimport = {} function HV_Actiondatimport:Name() return "Actiondatimport" end function HV_Actiondatimport:Version() return "1.0" end function HV_Actiondatimport:Description() return "Imports papagayo dat files using actions instead of switch layers." end function HV_Actiondatimport:Creator() return "Vern Zehr" end function HV_Actiondatimport:UILabel() return("Actiondatimport...") end -- ************************************************** -- Recurring values -- ************************************************** -- ************************************************** -- Credits dialog -- ************************************************** local HV_ActiondatimportDialog = {} HV_ActiondatimportDialog.UPDATE = MOHO.MSG_BASE function HV_ActiondatimportDialog:new(moho) local d = LM.GUI.SimpleDialog("Actiondatimport", HV_ActiondatimportDialog) local l = d:GetLayout() d.moho = moho l:AddChild(LM.GUI.StaticText("You will be prompted to select a dat file that contains your lip sync."), LM.GUI.ALIGN_LEFT) return d end function HV_ActiondatimportDialog:UpdateWidgets() end function HV_ActiondatimportDialog:OnValidate() end function HV_ActiondatimportDialog:HandleMessage(what) end function HV_ActiondatimportDialog:OnOK() end -- ************************************************** -- The guts of this script -- ************************************************** function HV_Actiondatimport:Run(moho) local dlog = HV_ActiondatimportDialog:new(moho) if (dlog:DoModal() == LM.GUI.MSG_CANCEL) then return end local path = LM.GUI.OpenFile("Select Dat File") if (path == "") then return end local f = io.open(path, "r") if (f == nil) then return end moho.document:SetDirty() moho.document:PrepUndo(NULL) layer = moho.layer local frame = moho.frame local line = f:read() line = f:read() while (line ~= nil) do local frm = tonumber(string.sub(line, string.find(line, "%S+"))) local act = string.sub(line, string.find(line, "%a+")) layer:InsertAction(act, frm, false) line = f:read() end f:close() end