--create the "display" variables. These will be used to display values when FieldID changes
stepid_disp=memory.readbyte(0x9C540)
danger_disp=memory.readword(0x7173C)
fraction_disp=memory.readbyte(0x9C6D8)
offset_disp=memory.readword(0x9AD2C)
timer_disp=memory.readword(0x9D264)
--previous fieldId and StepID values
fieldid_old=memory.readword(0x9A05C)
stepid_old=memory.readbyte(0x9C540)
--open up text file results will be dumped to. this text file should appear in your emulator folder
myfile1 = io.open("ff7_results.txt", "w")
--write text file header (tab separated)
myfile1:write("How;")
myfile1:write("\t")
myfile1:write("Field;")
myfile1:write("\t")
myfile1:write("StepID;")
myfile1:write("\t")
myfile1:write("Danger;")
myfile1:write("\t")
myfile1:write("Frac;")
myfile1:write("\t")
myfile1:write("Offset;")
myfile1:write("\t")
myfile1:write("Timer;")
myfile1:write("\t")
myfile1:write("Total steps in field")
myfile1:write("\n") --do not forget newline!
--text coordinates for displaying values on screen
x0=10 --x coordinate
y0=40 --y coordinate
dy=16 --pixels between each line
stepid_changes=0 --counter for stepID changes
stepid_old=memory.readbyte(0x0009C540) --stepID value the previous frame
while true do --main loop, executed once per frame
--read in the values for this frame
stepid=memory.readbyte(0x9C540)
danger=memory.readword(0x7173C)
fraction=memory.readbyte(0x9C6D8)
offset=memory.readword(0x9AD2C)
fieldid=memory.readword(0x9A05C)
timer=memory.readword(0x9D264)
how="Field"
if fieldid ~= fieldid_old then --when FieldID is not equal to its value the previous frame
--update the "disp"-variables
stepid_disp=stepid
danger_disp=danger
fraction_disp=fraction
offset_disp=offset
timer_disp=timer
--also, dump to text file
myfile1:write(how..";")
myfile1:write("\t")
myfile1:write(fieldid..";")
myfile1:write("\t")
myfile1:write(stepid..";")
myfile1:write("\t")
myfile1:write(danger..";")
myfile1:write("\t")
myfile1:write(fraction..";")
myfile1:write("\t")
myfile1:write(offset..";")
myfile1:write("\t")
myfile1:write(timer..";")
myfile1:write("\t")
myfile1:write(stepid_changes)
myfile1:write("\n") --do not forget newline!
--reset stepid_changes, because we are in a new fieldID
stepid_changes=0
end
--display the disp variables
gui.text(x0,y0+0*dy,"FieldID: ".. fieldid)
gui.text(x0,y0+1*dy,"StepID: ".. stepid_disp)
gui.text(x0,y0+2*dy,"Danger: ".. danger_disp)
gui.text(x0,y0+3*dy,"Fraction: ".. fraction_disp)
gui.text(x0,y0+4*dy,"Offset: ".. offset_disp)
gui.text(x0,y0+5*dy,"Timer: ".. timer_disp)
if ((stepid ~= stepid_old) and (memory.readbyte(0x696AF)~=191)) or memory.readbyte(0x696AF)==239 then --Check if StepID had changed while X not pressed or triangle is pressed
if memory.readbyte(0x696AF)==239 then how="Menu" --If it's triangle that is pressed
else how="Walk" --If StepID has changed while x not pressed
end
--Dump to text file
myfile1:write(how..";")
myfile1:write("\t")
myfile1:write(fieldid..";")
myfile1:write("\t")
myfile1:write(stepid..";")
myfile1:write("\t")
myfile1:write(danger..";")
myfile1:write("\t")
myfile1:write(fraction..";")
myfile1:write("\t")
myfile1:write(offset..";")
myfile1:write("\t")
myfile1:write(timer..";")
myfile1:write("\t")
myfile1:write(stepid_changes)
myfile1:write("\n") --do not forget newline!
end
if stepid~=stepid_old then --if stepid has changed, increase counter by 1
stepid_changes=stepid_changes+1
end
gui.text(x0,y0+7*dy,"StepID changes: " .. stepid_changes)
--create the variables holding values for the previous frame
fieldid_old=fieldid
stepid_old=stepid
emu.frameadvance() --frame advance
end
Since joypad.get doesn't record movie's input and I'm guessing you want to run the script while playing back a movie I had to search for the memory adress recording which key is pressed.
I found 0x696AF that has 191 when X is pressed and 239 when Triangle is.
I know it works for the beginning of the game but it may be a different adress and different values for where you're at, in which case you'll have to change it into the script.
I don't know if it's possible to dump into excel right away but I've add semicolon into the text file so you can copy/paste it into Excel and use the semicolons as separator.