Okay, I've been working on this for much of the day and I still can't get it to work. I keep on getting errors related to the frame counter, so I guess that I'm doing it wrong, but I can't seem to find any documentation on movie.framecount() anywhere so I'm not sure what I'm missing. Even with the frame variable removed from the string, nothing actually gets written to the document. Here's what I'm trying to work with:
local XPosVar=0x0012
local YPosVar=0x0011
local Max=100
local Cur=0
local Rest
local Frame
local ScreenVar=0x0040
local PixelVar=0x0041
local SubPixelVar=0x0042
local SpeedVar=0x0046
local SpeedSubVar=0x0047
OutputFile=io.open('data.txt', 'w')
while Cur <= Max do
Frame=int movie.framecount()
XPos=memory.readbyte(XPosVar)
YPos=memory.readbyte(YPosVar)
Screen=memory.readbyte(ScreenVar)
Pixel=memory.readbyte(PixelVar)
SubPixel=memory.readbyte(SubPixelVar)
Speed=memory.readbyte(SpeedVar)
SpeedSub=memory.readbyte(SpeedSubVar)
outs = string.format('%d %d %d %d %d %d %d %d\n',Frame,XPos,YPos,Screen,Pixel,SubPixel,Speed,SpeedSub)
OutputFile:write(outs)
Cur=Cur+1
Rest=Max-Cur
--gui.text(0,0, "Dumping Frame " .. Frame)
--gui.text(0,10, "Frames to Go: " .. Rest)
emu.frameadvance()
end
The goal here is to grab various values (screen position, position within the level, speed, etc) from the memory and write them to an external file, along with the frame number. I feel like I'm missing something very obvious, but I'm not sure what it is...