Add mods: technic, moreores, paintings, Nyancat (Pbj_pup). Small fix: sandwiches
This commit is contained in:
parent
15e8e696a2
commit
fb09deddc1
1404 changed files with 156555 additions and 211 deletions
26
mods/technic_plus_beta/technic/util/throttle.lua
Normal file
26
mods/technic_plus_beta/technic/util/throttle.lua
Normal file
|
@ -0,0 +1,26 @@
|
|||
|
||||
local function throttle(callspersecond, fn)
|
||||
local time = 0
|
||||
local count = 0
|
||||
|
||||
return function(...)
|
||||
local now = minetest.get_us_time()
|
||||
if (now - time) > 1000000 then
|
||||
-- reset time
|
||||
time = now
|
||||
count = 0
|
||||
else
|
||||
-- check max calls
|
||||
count = count + 1
|
||||
if count > callspersecond then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
return pcall(fn, ...)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
return throttle
|
Loading…
Add table
Add a link
Reference in a new issue