Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- total_events_previous_second = 0
- total_events_this_second = 0
- seconds = floor(time_in_milliseconds())
- function interpolate(x1, x2, d)
- local difference = x2 - x1
- return x1 + difference * d
- end
- function update()
- local events = get_events()
- total_events_this_second = total_events_this_second + #events
- local time = time_in_milliseconds()
- local current_seconds = floor(time)
- if seconds ~= current_seconds then
- local time_since_previous_second = math.frac(time_in_milliseconds)
- set_events_per_second(interpolate(total_events_previous_second, total_events_this_second, time_since_previous_second))
- seconds = current_seconds
- total_events_previous_second = total_events_this_second
- total_events_this_second = 0
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement