mirror of
https://github.com/EliasFleckenstein03/playerlist.git
synced 2024-08-20 04:54:07 +02:00
Make key configurable
This commit is contained in:
parent
a84a62544f
commit
03ce6db43e
@ -1,3 +1,5 @@
|
|||||||
# playerlist
|
# playerlist
|
||||||
Show a list of all online players (similar to minecrafts tab-list) when a player is sneaking.
|
Show a list of all online players (similar to minecrafts tab-list) when a player is pressing the playerlist key (by default: sneak).
|
||||||
Provides an API that can be used to hide or nick players, sort them and display them with different colors. (E.g. Display admins at the top of the list and make their name red). There is also a ping bar for every player (<= 20ms -> 4, <= 40ms -> 3, <= 60ms -> 2, > 60ms -> 1).
|
Provides an API that can be used to hide or nick players, sort them and display them with different colors. (E.g. Display admins at the top of the list and make their name red). There is also a ping bar for every player (<= 20ms -> 4, <= 40ms -> 3, <= 60ms -> 2, > 60ms -> 1).
|
||||||
|
|
||||||
|
The playerlist key can be configured by changing the playerlist_key setting. Possible values are up, down, left, right, jump, aux1, sneak, dig, place or zoom.
|
||||||
|
7
init.lua
7
init.lua
@ -2,6 +2,9 @@ playerlist = {
|
|||||||
huds = {}
|
huds = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local playerlist_key = minetest.settings:get("playerlist_key") or "sneak"
|
||||||
|
print(playerlist_key)
|
||||||
|
|
||||||
function playerlist.iterator()
|
function playerlist.iterator()
|
||||||
return ipairs(minetest.get_connected_players())
|
return ipairs(minetest.get_connected_players())
|
||||||
end
|
end
|
||||||
@ -11,7 +14,7 @@ function playerlist.count()
|
|||||||
end
|
end
|
||||||
|
|
||||||
controls.register_on_press(function(user, key)
|
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 user_name = user:get_player_name()
|
||||||
local huds = {user:hud_add({
|
local huds = {user:hud_add({
|
||||||
hud_elem_type = "image",
|
hud_elem_type = "image",
|
||||||
@ -49,7 +52,7 @@ controls.register_on_press(function(user, key)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
controls.register_on_release(function(user, key)
|
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
|
for _, id in pairs(playerlist.huds[user:get_player_name()]) do
|
||||||
user:hud_remove(id)
|
user:hud_remove(id)
|
||||||
end
|
end
|
||||||
|
2
settingtypes.txt
Normal file
2
settingtypes.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# The key that players need to press to show the playerlist
|
||||||
|
playerlist_key (Playerlist key) string sneak
|
Loading…
Reference in New Issue
Block a user