summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWuzzy <almikes@aol.com>2014-07-07 10:39:21 +0200
committerWuzzy <almikes@aol.com>2014-07-07 10:39:21 +0200
commit050be27a3b1d90a7ac5f0bffafd8319f520b58e3 (patch)
tree4d2f54679c5595f45f7e0b31084e0536ef11baca
parentbbc90ad630c1de6296ada58777a7b28e9836ac3b (diff)
Add stresstest example use globalstep less often
-rw-r--r--examples.lua25
-rw-r--r--init.lua9
2 files changed, 33 insertions, 1 deletions
diff --git a/examples.lua b/examples.lua
index d7736a0..fee65b5 100644
--- a/examples.lua
+++ b/examples.lua
@@ -42,6 +42,12 @@ playereffects.register_effect_type("fly", "Fly mode available", "playereffects_e
minetest.set_player_privs(effect.playername, privs)
end
)
+playereffects.register_effect_type("stress", "Stress Test Effect", nil, {},
+ function(player)
+ end,
+ function(effect)
+ end
+)
minetest.register_chatcommand("fast", {
@@ -77,3 +83,22 @@ minetest.register_chatcommand("fly", {
playereffects.apply_effect_type("fly", 20, minetest.get_player_by_name(name))
end,
})
+minetest.register_chatcommand("stresstest", {
+ params = "[<effects>]",
+ descriptions = "Start the stress test for Player Effects with <effects> effects.",
+ privs = {server=true},
+ func = function(name, param)
+ local player = minetest.get_player_by_name(name)
+ local max = 100
+ if(type(param)=="string") then
+ if(type(tonumber(param)) == "number") then
+ max = tonumber(param)
+ if(max > 1000) then max = 1000 end
+ end
+ end
+ minetest.debug("[playereffects] Stress test started for "..name.." with "..max.." effects.")
+ for i=1,max do
+ playereffects.apply_effect_type("stress", 10, player)
+ end
+ end
+})
diff --git a/init.lua b/init.lua
index a8159c5..188fc58 100644
--- a/init.lua
+++ b/init.lua
@@ -234,7 +234,14 @@ minetest.register_on_joinplayer(function(player)
end
end)
-minetest.register_globalstep(function()
+playereffects.globalstep_timer = 0
+minetest.register_globalstep(function(dtime)
+ playereffects.globalstep_timer = playereffects.globalstep_timer + dtime
+ if(playereffects.globalstep_timer < 1) then
+ return
+ end
+ playereffects.globalstep_timer = 0
+
local players = minetest.get_connected_players()
for p=1,#players do
playereffects.hud_update(players[p])