]> git.lizzy.rs Git - elidragon.git/blobdiff - playerlist.lua
Re-add set_skyblock_spawn command
[elidragon.git] / playerlist.lua
index 6f5866ed9cd5310e418b193432b7b702554c8a5c..75472fe0055fdd6038bc96eb77250fc327f2f191 100644 (file)
@@ -6,32 +6,32 @@ controls.register_on_press(function(player, key)
                local players = minetest.get_connected_players()
                for i, p in pairs(players) do
                        local n = p:get_player_name()
-                       local ping = minetest.get_player_information(n).avg_rtt
+                       local ping = math.max(1, math.ceil(4 - minetest.get_player_information(n).avg_rtt * 4))
                        list[#list + 1] = player:hud_add({
                                hud_elem_type = "text",
-                               position = {x = 1, y = 0},
-                               offset = {x = -50, y = 5 + (i - 1) * 18},
+                               position = {x = 0.5, y = 0},
+                               offset = {x = 20, y = 53 + (i - 1) * 18},
                                text = n,
-                               alignment = {x = -1, y = 1},
+                               alignment = {x = 1, y = 1},
                                scale = {x = 100, y = 100},
-                               number = tonumber(elidragon.get_rank(n).color:gsub("#", ""), 16),
+                               number = tonumber(elidragon.get_rank(p).color:gsub("#", ""), 16),
                        })
                        list[#list + 1] = player:hud_add({
                                hud_elem_type = "image",
-                               position = {x = 1, y = 0},
-                               offset = {x = -5, y = (i - 1) * 18},
-                               text = "server_ping_" .. math.ceil(4 - ping / 2 * 4) .. ".png",
+                               position = {x = 0.5, y = 0},
+                               offset = {x = 0, y = 50 + (i - 1) * 18},
+                               text = "server_ping_" .. ping .. ".png",
                                alignment = {x = -1, y = 1},
                                scale = {x = 1.5, y = 1.5},
                                number = 0xFFFFFF,
                        })
-                       print(n .. ": " .. ping)
                end
                elidragon.playerlist[name] = list
        end
 end)
+
 controls.register_on_release(function(player, key)
-       if key == "sneak" then
+       if key == "sneak" and player then
                for _, id in pairs(elidragon.playerlist[player:get_player_name()]) do
                        player:hud_remove(id)
                end