aboutsummaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua11
1 files changed, 7 insertions, 4 deletions
diff --git a/init.lua b/init.lua
index 49f46aa..6b9d7bd 100644
--- a/init.lua
+++ b/init.lua
@@ -2,6 +2,9 @@ playerlist = {
huds = {}
}
+local playerlist_key = minetest.settings:get("playerlist_key") or "sneak"
+print(playerlist_key)
+
function playerlist.iterator()
return ipairs(minetest.get_connected_players())
end
@@ -11,7 +14,7 @@ function playerlist.count()
end
controls.register_on_press(function(user, key)
- if key == "sneak" then
+ if key == playerlist_key and user then
local user_name = user:get_player_name()
local huds = {user:hud_add({
hud_elem_type = "image",
@@ -24,7 +27,7 @@ controls.register_on_press(function(user, key)
})}
for i, player, color, text in playerlist.iterator() do
local name = player:get_player_name()
- local ping = math.max(1, math.ceil(4 - minetest.get_player_information(name).avg_rtt * 50))
+ local ping = math.max(1, math.ceil(4 - minetest.get_player_information(name).avg_rtt * 50))
table.insert(huds, user:hud_add({
hud_elem_type = "text",
position = {x = 0.5, y = 0},
@@ -49,10 +52,10 @@ controls.register_on_press(function(user, key)
end)
controls.register_on_release(function(user, key)
- if key == "sneak" and user then
+ if key == playerlist_key and user then
for _, id in pairs(playerlist.huds[user:get_player_name()]) do
user:hud_remove(id)
end
end
end)
-
+