View Single Post
Old 05-25-2019, 06:27 AM   #488
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,241
Default

- Put the lazy elements on separate layers. As long as nothing on a given layer needs to be redrawn, the entire layer will just keep blitting the same image when the GUI redraws everything.

- Add some logic to the lazy elements' onupdate, or whatever you're using to update them, so that it doesn't do the work on every loop:
Code:
local updateFrequency = 10 -- 10 script cycles
lazyElement.updateCount = 0

function lazyElement:onupdate()
  self.updateCount = (self.updateCount + 1) % updateFrequency
  if self.updateCount == 0 then
    updateStuff()
  end
end
If the lazy elements are all updating at the same time, it would be more efficient to use GUI.func:
Code:
GUI.func = updateAllTheLazyStuff
GUI.freq = 0.1 -- seconds
Lokasenna is offline   Reply With Quote