GUI.func is just a top-level thing. Components don't have any built-in frequency settings for
onupdate, but you could keep them from all updating at the same time with something like:
Code:
-- When creating them, assign a random number from 0 to 99
myElement.updateIndex = Math.floor(Math.random() * 100)
function myElement:onupdate()
if elementUpdateCounter == self.updateIndex then
-- update stuff
end
end
-- Increment a global counter
GUI.func = function()
elementUpdateCounter = (elementUpdateCounter + 1) % 100
end
You might also look into Lua's "coroutines" - they're functions that you can effectively pause and come back to, which makes them great for saying "here's a giant pile of work, do a bit of it and then wait for the next script update to do a bit more". If your elements were named consistently but with increasing numbers, you could have a coroutine looping over all of them but only doing ten at a time, etc.