-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Monitor max lag from mod * Add new max lag for technic_get_active_networks command Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com>
- Loading branch information
Showing
5 changed files
with
29 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,23 @@ | ||
local function explode(sep, input) | ||
local t={} | ||
local i=0 | ||
for k in string.gmatch(input,"([^"..sep.."]+)") do | ||
t[i]=k | ||
i=i+1 | ||
end | ||
return t | ||
end | ||
|
||
local multiplier = tonumber(technic.config:get("max_lag_reduction_multiplier")) | ||
|
||
local last_step = minetest.get_us_time() | ||
|
||
local max_lag = 0 | ||
|
||
minetest.register_globalstep(function() | ||
-- Calculate own dtime as a workaround to 2 second limit | ||
local now = minetest.get_us_time() | ||
local dtime = now - last_step | ||
last_step = now | ||
|
||
max_lag = max_lag * multiplier -- Decrease slowly | ||
|
||
if dtime > max_lag then | ||
max_lag = dtime | ||
end | ||
end) | ||
|
||
function technic.get_max_lag() | ||
local arrayoutput = explode(", ",minetest.get_server_status()) | ||
local arrayoutput2 = explode("=",arrayoutput[4]) | ||
return tonumber(arrayoutput2[1]) | ||
return max_lag / 1000000 | ||
end |