I’m trying to compare the animated id-properties of two frames in order to determine if there has been a change in value from one frame to another. As a beginner scripter/programmer I’m surprised I’ve gotten this far. I feel like I’m close to what I want but the script fails at: “p_frame_val = frame_compare[-2][-1][-1]” I get ’ TypeError: ‘int’ object is not subscriptable’. I find this strange because I am able to get this value at the bottom where I am just writing it. I’m not married to doing it this way so any suggestions on how to compare id_values over time would be appreciate. Of course any help on my problem is appreciated!
def sprite_properties(context, filepath, use_some_setting):
frame_compare = [0]
print("running write_some_data...")
f = open(filepath, 'w', encoding='utf-8')
for obj in objects:
f.write(str(obj.name) + '
')
for frames in range(scn.frame_start, scn.frame_end):
scn.frame_set(frames)
# adding the value of properties to a list
frame_compare.append(obj.items())
# get the property value for the last frame
p_frame_val = frame_compare[-2][-1][-1]
# get the property value for the current frame
c_frame_val = frame_compare[-1][-1][-1]
# check to see if the property values have changed
if p_frame_val != c_frame_val:
# if changed print the values out for each frame
p_frame = int(scn.frame_current) - 1, frame_compare[-2]
c_frame = scn.frame_current, frame_compare[-1]
f.write("Previous Frame")
f.write(str(p_frame) + '
')
f.write("Current Frame")
f.write(str(c_frame) + '
')
else:
pass
f.write(str(frame_compare[-1][-1][-1]) + '
')
f.write(str(frame_compare[-2][-1][-1]) + '
')
f.write("Hello World %s" % use_some_setting)
f.close()
return {'FINISHED'}