Playtime tracking is now implemented in Lolife!

I thought I'd share a quick rundown of how it works (ignoring the need to handle multiple save slots).
Essentially I'm keeping a running total of the number of frames that have passed in game, which I update in the game script's exit event:
on exit do
stat_time_dframe = event.frame
stat_time_dframe -= stat_time_last_frame
stat_time_frames += stat_time_dframe
stat_time_last_frame = event.frame
end
In practice there's a conditional that prevents that from counting time spent on the title screen, and of course stat_time_frames has to be restored when loading a save.
When I need to display playtime, I just call a playtime event like this to convert from frames to hours, minutes and seconds:
on playtime do
t = stat_time_frames
t /= 72000
stat_time_hours = floor t
t -= stat_time_hours
t *= 60
stat_time_mins = floor t
t -= stat_time_mins
t *= 60
stat_time_secs = floor t
end
This method assumes the game has been running at a solid 20 fps, so in reality playtime is underestimated. It shouldn't be too inaccurate (thanks in part to all of my previous performance optimisation!) and in any case an underestimate is not as bad as an overestimate. I wouldn't want to falsely inflate the game's claimed runtime, that might feel dishonest!
Hopefully this'll be useful to anyone wanting to implement playtime tracking in their own pulp project ![]()