Ok, so I was able to get it to display my FPS but my next question is how do I get it to constantly update instead of just displaying the number i grabbed at the time it was loaded?
I imagine it has to be on some sort of update function. I haven't really worked with that yet though. Would I register it as an event?
So I seemed to have figured it out but It was from copy and pasting the buffer tutorial. Maybe some help on why this works?
Code:
local BufferTable = {}
function BufferReached(key, buffer)
if key == nil then return end
if BufferTable[key] == nil then BufferTable[key] = {} end
BufferTable[key].buffer = buffer or 1
BufferTable[key].now = GetFrameTimeSeconds()
if BufferTable[key].last == nil then BufferTable[key].last = BufferTable[key].now end
BufferTable[key].diff = BufferTable[key].now - BufferTable[key].last
BufferTable[key].eval = BufferTable[key].diff >= BufferTable[key].buffer
if BufferTable[key].eval then BufferTable[key].last = BufferTable[key].now end
return BufferTable[key].eval
end
function NmSystemBar:Initialize()
local fps = GetFramerate()
if not BufferReached("fpsbuffer", 1) then return; end
NmSystemBarWindowLabel:SetText("FPS: "..zo_round(fps))
EVENT_MANAGER:UnregisterForEvent(NmSystemBar.name, EVENT_ADD_ON_LOADED)
end