local file = io.open("inputs_truncated.lua", "w")
local input_index = 0
inputs = { }
local movie_length = movie.length() - 1 -- mostly to avoid end of movie issues
function mark_input_frame()
input_index = input_index + 1
local framecount = emu.framecount()
if not tastudio.islag(framecount - 1) then
inputs[input_index] = movie.getinput(framecount - 1)
elseif not tastudio.islag(framecount - 2) then
inputs[input_index] = movie.getinput(framecount - 2)
elseif not tastudio.islag(framecount - 3) then
inputs[input_index] = movie.getinput(framecount - 3)
elseif not tastudio.islag(framecount - 4) then
inputs[input_index] = movie.getinput(framecount - 4)
else
error("too much lag???") -- should be unreachable?
end
end
event.onmemoryexecute(mark_input_frame,0x02F5) -- title screen
event.onmemoryexecute(mark_input_frame,0x09E0) -- dpad input
event.onmemoryexecute(mark_input_frame,0x1DE8) -- menus
function write_table(f)
f:write("inputs = { ")
for i=1,input_index do
f:write("{ ")
if inputs[i]["A"] then
f:write("A = true, ")
else
f:write("A = false, ")
end
if inputs[i]["B"] then
f:write("B = true, ")
else
f:write("B = false, ")
end
if inputs[i]["Down"] then
f:write("Down = true, ")
else
f:write("Down = false, ")
end
if inputs[i]["Left"] then
f:write("Left = true, ")
else
f:write("Left = false, ")
end
if inputs[i]["Power"] then
f:write("Power = true, ")
else
f:write("Power = false, ")
end
if inputs[i]["Right"] then
f:write("Right = true, ")
else
f:write("Right = false, ")
end
if inputs[i]["Select"] then
f:write("Select = true, ")
else
f:write("Select = false, ")
end
if inputs[i]["Start"] then
f:write("Start = true, ")
else
f:write("Start = false, ")
end
if inputs[i]["Up"] then
f:write("Up = true")
else
f:write("Up = false")
end
if emu.framecount() ~= movie_length then
f:write(" },\n")
else
f:write(" } }")
end
end
end
while emu.framecount() <= movie_length do
emu.frameadvance()
end
write_table(file)
file:close()