overrides.lua 952 B

123456789101112131415161718192021222324252627282930313233
  1. -- execute()
  2. local old_execute = mesecon.queue.execute
  3. mesecon.queue.execute = function(self, action)
  4. if mesecons_debug.enabled then
  5. local t0 = minetest.get_us_time()
  6. old_execute(self, action)
  7. local t1 = minetest.get_us_time()
  8. local micros = t1 - t0
  9. local ctx = mesecons_debug.get_context(action.pos)
  10. ctx.micros = ctx.micros + micros
  11. ctx.mtime = t0
  12. --print("execute() func=" .. action.func .. " pos=" .. minetest.pos_to_string(action.pos) .. " micros=" .. micros)
  13. end
  14. end
  15. -- add_action()
  16. local old_add_action = mesecon.queue.add_action
  17. mesecon.queue.add_action = function(self, pos, func, params, time, overwritecheck, priority)
  18. if mesecons_debug.enabled then
  19. local ctx = mesecons_debug.get_context(pos)
  20. time = time or 0
  21. time = time + ctx.penalty
  22. old_add_action(self, pos, func, params, time, overwritecheck, priority)
  23. --print("add_action() pos=" .. minetest.pos_to_string(pos))
  24. end
  25. end