aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2018-11-28 23:07:43 +0100
committerorwell96 <orwell@bleipb.de>2018-11-28 23:07:43 +0100
commit976a79b2079d97671fedbb0882c4f42eec6213c0 (patch)
tree68707cab7928957ba026b5272fdafa3ab13bd362
parent8a99407736dfc4b1eb835c972dbf876d6416839d (diff)
downloadposhud-976a79b2079d97671fedbb0882c4f42eec6213c0.zip
poshud-976a79b2079d97671fedbb0882c4f42eec6213c0.tar.gz
poshud-976a79b2079d97671fedbb0882c4f42eec6213c0.tar.bz2
Add small rotating "star" indicator showing whether server responds
-rw-r--r--init.lua15
1 files changed, 14 insertions, 1 deletions
diff --git a/init.lua b/init.lua
index b22e16a..50a6bf5 100644
--- a/init.lua
+++ b/init.lua
@@ -12,6 +12,7 @@
--settings
colour = 0xFFFFFF --text colour in hex format default is white
+enable_star = true
--------------------------------------------------------------------------------
@@ -72,6 +73,9 @@ local function get_time()
return ("%02d:%02d"):format(h, m);
end
+-- rotating star
+local star={"\\", "|", "/", "-"}
+
-- Lag counters
-- adaption weights for averages
@@ -84,6 +88,8 @@ local h_text = "Initializing..."
local h_int = 2
local h_tmr = 0
+local starc = 0
+
minetest.register_globalstep(function (dtime)
-- make a lag sample
l_avg1 = w_avg1*dtime + ow_avg1*l_avg1
@@ -95,7 +101,14 @@ minetest.register_globalstep(function (dtime)
-- Update hud text that is the same for all players
local s_lag = string.format("Lag: avg: %.2f (%.2f) max: %.2f", l_avg1, l_avg2, l_max)
local s_time = "Time: "..get_time()
- h_text = s_time .. "\n" .. s_lag
+
+ local s_star = ""
+ if enable_star then
+ s_star = star[starc+1]
+ starc = (starc + 1) % 4
+ end
+
+ h_text = s_time .. " " .. s_star .. "\n" .. s_lag
h_tmr = h_int
else