• Storing function return value
    1 replies, posted
I've made a function that returns a string and the function is being ran continuously in a HUDPaint hook. Because the return value doesn't change too often I want to be able to store the variable instead of calculating over and over but I'm unsure how.
[CODE] local cache = {} function CalculateSomething(input) if cache[input] then return cache[input] end local calculated = input * 5 / 10 + 8 cache[input] = calculated return calculated end [/CODE] This is just an example. Modify at will.
Sorry, you need to Log In to post a reply to this thread.