Page 1 of 1

sort of a DoEvents() hack for overwhelming ABM hits

PostPosted: Sat Sep 14, 2013 16:52
by leetelate
Overwhelmed by ABM hits dragging the server down?

try this around your abm code

local time1 = 0
local time2 = 0

minetest.register_abm({
nodenames = {"default:sand"},
neighbors = {"default:water_source","default:sand"},
interval = 800,
chance = 88,
action = function(pos, node)

time1 = os.time()
if time1-time2 < 1 then return end
time2 = os.time()

--makes the time between each abm hit down to >1 second between each - fractions of a second are also possible - basically gives the server time to "catch up" especially if you have a lot of stuff going on in your abm

interval and chance are fine, but when there are huge numbers of blocks, sometimes you can get 400-500 abm hits in one second - slowing it down by returning without doing anything gives the server a chance to breathe

source: lua-users wiki and much testing