From 37a79426ca9fb6a610e7a48114b8ef15b12ad6cb Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sun, 10 May 2020 19:11:09 +0200 Subject: [PATCH] Added playerlist, several fixes and ajustments. --- init.lua | 2 +- nodes.lua | 2 +- playerlist.lua | 37 +++++++++++++++++++++++++++++++++++++ ranks.lua | 3 ++- 4 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 playerlist.lua diff --git a/init.lua b/init.lua index 337212b..6c26491 100755 --- a/init.lua +++ b/init.lua @@ -1,6 +1,6 @@ elidragon = {} -local modules = {"functions", "nodes", "commands", "ranks", "tags", "warps", "misc", "birthday", "skyblock"} +local modules = {"functions", "nodes", "commands", "ranks", "tags", "warps", "misc", "birthday", "skyblock", "playerlist"} local modpath = minetest.get_modpath("elidragon") diff --git a/nodes.lua b/nodes.lua index bc97e46..2bedc9e 100755 --- a/nodes.lua +++ b/nodes.lua @@ -17,7 +17,7 @@ for _, def in pairs(nodes) do minetest.register_node(name, { description = def[1] .. " Block", tiles = {def[2]}, - groups = {cracky = 3, stone = 1}, + groups = {oddly_breakable_by_hand = 1, choppy = 1}, stack_max = 1, }) if def[3] then diff --git a/playerlist.lua b/playerlist.lua new file mode 100644 index 0000000..1f45483 --- /dev/null +++ b/playerlist.lua @@ -0,0 +1,37 @@ +elidragon.playerlist = {} +controls.register_on_press(function(player, key) + if key == "sneak" then + local name = player:get_player_name() + local list = {} + local players = minetest.get_connected_players() + for i, p in pairs(players) do + local n = p:get_player_name() + list[#list + 1] = player:hud_add({ + hud_elem_type = "text", + position = {x = 1, y = 0}, + offset = {x = -50, y = 5 + (i - 1) * 18}, + text = n, + alignment = {x = -1, y = 1}, + scale = {x = 100, y = 100}, + number = tonumber(elidragon.get_rank(n).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 - minetest.get_player_information(n).avg_rtt / 2 * 4) .. ".png", + alignment = {x = -1, y = 1}, + scale = {x = 1.5, y = 1.5}, + number = 0xFFFFFF, + }) + end + elidragon.playerlist[name] = list + end +end) +controls.register_on_release(function(player, key) + if key == "sneak" then + for _, id in pairs(elidragon.playerlist[player:get_player_name()]) do + player:hud_remove(id) + end + end +end) diff --git a/ranks.lua b/ranks.lua index a56e6a4..d61e119 100755 --- a/ranks.lua +++ b/ranks.lua @@ -109,6 +109,7 @@ minetest.register_chatcommand("rank", { if not rank_ref then minetest.chat_send_player(name, "Invalid Rank: " .. rank) else + elidragon.savedata.ranks[target] = rank local privs = {} for _, r in pairs(elidragon.ranks) do for k, v in pairs(r.privs) do @@ -119,10 +120,10 @@ minetest.register_chatcommand("rank", { end end minetest.set_player_privs(target, privs) + minetest.chat_send_all(target .. " is now a " .. minetest.colorize(rank_ref.color, rank_ref.name)) if target_ref then target_ref:set_nametag_attributes({color = rank_ref.color}) end - minetest.chat_send_all(target .. " is now a " .. minetest.colorize(rank_ref.color, rank_ref.name)) end end, }) -- 2.44.0