Originally Posted by Terenna
Lua Code:
local function OnUpdate(self, elapsed, x, y) self.elapsed = self.elapsed + elapsed while self.elapsed > 0.5 do --only update the coords 2/second if mapID then x, y = GetPlayerMapPosition(mapID, 'player') if x then self.text:SetFormattedText('%.1f, %.1f', x * 100, y * 100) else self.text:SetText('') end end self.elapsed = self.elapsed - 0.5 end end
|
I'd probably only update the co-ordinates once in the OnUpdate function, then wait for at least another half a second before doing it again. Currently this keeps recalculating the same thing until it gets the elapsed time under half a second. If the pc is already under enough load that more than 1 second has passed between frames, then this would just be adding to the work load.
Lua Code:
local function OnUpdate(self, elapsed, x, y)
self.elapsed = (self.elapsed or 0) + elapsed
if self.elapsed > 0.5 then --only update the coords 2/second
if mapID then
x, y = GetPlayerMapPosition(mapID, 'player')
if x then
self.text:SetFormattedText('%.1f, %.1f', x * 100, y * 100)
else
self.text:SetText('')
end
end
self.elapsed = 0
end
end