84 lines
1.1 KiB
Lua
84 lines
1.1 KiB
Lua
|
|
local contexts = {}
|
|
|
|
imhud = {
|
|
_contexts = contexts
|
|
}
|
|
|
|
local ctx
|
|
|
|
-- MARK: Helpers
|
|
|
|
local function new_id()
|
|
return "_imhud_"..minetest.get_us_time().."_"..math.random(1, 100000)
|
|
end
|
|
|
|
-- MARK: Elements
|
|
|
|
local hud_image = {
|
|
add = function()
|
|
|
|
end,
|
|
update = function()
|
|
|
|
end,
|
|
remove = function()
|
|
|
|
end
|
|
}
|
|
setmetatable(hud_image, {
|
|
__call = function(_, texture)
|
|
local e = {text = texture}
|
|
setmetatable(e, hud_image)
|
|
return e
|
|
end
|
|
})
|
|
|
|
-- MARK: Building
|
|
|
|
local HUD = {
|
|
|
|
}
|
|
HUD.__index = HUD
|
|
|
|
function imhud.begin()
|
|
local e = {}
|
|
setmetatable(e, HUD)
|
|
ctx = e
|
|
return e
|
|
end
|
|
|
|
function imhud.end_()
|
|
|
|
end
|
|
|
|
local Context = {
|
|
|
|
}
|
|
Context.__index = Context
|
|
|
|
function imhud.add(target, hud, name)
|
|
local ctx = {
|
|
target = type(target) == "string" and target or target:get_player_name(),
|
|
elems = {}
|
|
}
|
|
setmetatable(ctx, Context)
|
|
contexts[name or new_id()] = ctx
|
|
end
|
|
|
|
function imhud.remove(name)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function hud()
|
|
|
|
end
|
|
|
|
minetest.register_chatcommand("hud", {
|
|
func = function(name)
|
|
imhud.add()
|
|
end
|
|
})
|