precision timer
I wondered if there is any precision timer useable in LUA.
os.time() gives only seconds
minetest.env:get_timeofday() gives always the same value within a function
Why?
I'm working on a complex algorithm but I don't want the game to lag. With a precision timer I could modify my algorithm to abort when a certain time is over, else it will increase its range. So the range of the function will be limited by the speed of the computer.
Other mods should be able to auto-adjust, too. I think about the MOB-framework (AKA animals-modpack). Depending on the elapsed time, it could decide which or how many mobs are calculated. So the warning "WARNING: you need a reasonable fast machine with enough memory for animals." could be removed.
os.time() gives only seconds
minetest.env:get_timeofday() gives always the same value within a function
Why?
I'm working on a complex algorithm but I don't want the game to lag. With a precision timer I could modify my algorithm to abort when a certain time is over, else it will increase its range. So the range of the function will be limited by the speed of the computer.
Other mods should be able to auto-adjust, too. I think about the MOB-framework (AKA animals-modpack). Depending on the elapsed time, it could decide which or how many mobs are calculated. So the warning "WARNING: you need a reasonable fast machine with enough memory for animals." could be removed.