33 lines
947 B
Lua

local playerHud = {}
function logistica.show_short_popup(playerName, text)
local player = minetest.get_player_by_name(playerName)
if not player then return end
if playerHud[playerName] then
player:hud_remove(playerHud[playerName].hudId)
playerHud[playerName].job:cancel()
playerHud[playerName] = nil
end
local hudId = player:hud_add({
hud_elem_type = "text",
position = {x = 0.5, y = 0.5},
offset = {x = 0, y = 40},
text = text,
scale = { x = 1, y = 1},
alignment = { x = 0.5, y = 0 },
number = 0xDFDFDF,
})
playerHud[playerName] = {}
playerHud[playerName].hudId = hudId
local job = minetest.after(3, function()
local pl = minetest.get_player_by_name(playerName)
if not pl then return end
if not playerHud[playerName] then return end
pl:hud_remove(playerHud[playerName].hudId)
playerHud[playerName] = nil
end)
playerHud[playerName].job = job
end