User File #44524912163951723

Upload All User Files

#44524912163951723 - Generate Movie Absolute Values

generatemovieabs.lua
806 downloads
Uploaded 1/18/2018 4:11 AM by c-square (see all 10)
This lua script converts a movie file into a list of absolute values for each of the commands in that file. This is useful when using TAS Scripts to compare your desynced movie to the original to see where you've desynced.
dofile("fileio.lua");
movieFile = "dgentas.jrsr" -- Movie file you want to convert
absFile = "dgentas.abs" -- Output file for the absolute values

print("-- Loading & Parsing Movie File. --")

movieLines = readInputFile(movieFile)
outputBinary = openOutputFile(absFile)
absoluteTime = 0
lineNumber = 1

-- Skip to events
while movieLines[lineNumber] ~= nil and movieLines[lineNumber] ~= "!BEGIN events" do
	lineNumber=lineNumber+1
end
lineNumber=lineNumber+1
-- Parse Events
while movieLines[lineNumber] ~= nil and string.sub(movieLines[lineNumber],1,15) ~= "!BEGIN diskinfo" do
	--print(movieLines[lineNumber])
	parse = movieLines[lineNumber]:split(" ")
	if string.sub(parse[1],1,1) ~= "+" then
		print("ERROR: Line does not begin with '+': " .. parse[field])
	end
	timestamp = tonumber(string.sub(parse[1],2))
	
	if parse[2] ~= "OPTION" then
		absoluteTime = absoluteTime + timestamp
		outStr = absoluteTime .. ":" .. timestamp
		
		if parse[2] == "SAVESTATE" or (parse[3] == "XMOUSEMOTION" and parse[4] == "0") then
			outStr = outStr .. ":SAVESTATE #" .. parse[4]
		else
			outStr = outStr .. ":" .. parse[3] .. ":" .. parse[4]
		end
		outputBinary.write("?",outStr .. "\n")
	end
	lineNumber=lineNumber+1
end

print("-- Loading & Parsing Complete.  " .. absFile .. " created --")