new areas systeme
@ -3,42 +3,74 @@
|
||||
areas.hud = {}
|
||||
|
||||
local function tick()
|
||||
minetest.after(1, tick)
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
local name = player:get_player_name()
|
||||
local pos = vector.round(player:getpos())
|
||||
local areaStrings = {}
|
||||
local area_text = "no areas\n\n"
|
||||
local area_owner_name = ""
|
||||
local mod_owner = 0
|
||||
local mod_open = 0
|
||||
local mod_farming = 0
|
||||
local area_name = ""
|
||||
local nb_areas = 0
|
||||
for id, area in pairs(areas:getAreasAtPos(pos)) do
|
||||
table.insert(areaStrings, ("%s [%u] (%s%s)")
|
||||
:format(area.name, id, area.owner,
|
||||
area.open and ":open" or area.openfarming and ":open to farming" or ""))
|
||||
nb_areas = nb_areas+1
|
||||
if areas:isAreaOwner(id, name) then
|
||||
mod_owner = 1
|
||||
end
|
||||
|
||||
if area.open then
|
||||
mod_open = 1
|
||||
end
|
||||
if area.openfarming then
|
||||
mod_farming = 1
|
||||
end
|
||||
|
||||
if not area.parent then
|
||||
area_owner_name = area.owner
|
||||
area_name = area.name
|
||||
end
|
||||
end
|
||||
local areaString = "Areas:"
|
||||
if #areaStrings > 0 then
|
||||
areaString = areaString.."\n"..
|
||||
table.concat(areaStrings, "\n")
|
||||
|
||||
local icon = "areas_1_0_1.png"
|
||||
if nb_areas > 0 then
|
||||
area_text = ("nb area:%u\nowner:%s\nname:%s"):format(nb_areas, area_owner_name, area_name)
|
||||
icon = ("areas_%u_%u_%u.png"):format(mod_owner, mod_open, mod_farming)
|
||||
end
|
||||
local hud = areas.hud[name]
|
||||
if not hud then
|
||||
hud = {}
|
||||
areas.hud[name] = hud
|
||||
hud.areasId = player:hud_add({
|
||||
if not areas.hud[name] then
|
||||
areas.hud[name] = {}
|
||||
areas.hud[name].icon = player:hud_add({
|
||||
hud_elem_type = "image",
|
||||
position = {x=0,y=1},
|
||||
scale = {x=1,y=1},
|
||||
offset = {x=26,y=-60},
|
||||
text = icon,
|
||||
})
|
||||
|
||||
areas.hud[name].areas_id = player:hud_add({
|
||||
hud_elem_type = "text",
|
||||
name = "Areas",
|
||||
number = 0xFFFFFF,
|
||||
position = {x=0, y=1},
|
||||
offset = {x=8, y=-8},
|
||||
text = areaString,
|
||||
scale = {x=200, y=60},
|
||||
offset = {x=48, y=-40},
|
||||
text = area_text,
|
||||
scale = {x=1, y=1},
|
||||
alignment = {x=1, y=-1},
|
||||
})
|
||||
hud.oldAreas = areaString
|
||||
return
|
||||
elseif hud.oldAreas ~= areaString then
|
||||
player:hud_change(hud.areasId, "text", areaString)
|
||||
hud.oldAreas = areaString
|
||||
areas.hud[name].old_area_text = area_text
|
||||
areas.hud[name].old_icon = icon
|
||||
else
|
||||
if areas.hud[name].old_area_text ~= area_text then
|
||||
player:hud_change(areas.hud[name].areas_id, "text", area_text)
|
||||
areas.hud[name].old_area_text = area_text
|
||||
end
|
||||
if areas.hud[name].old_icon ~= icon then
|
||||
player:hud_change(areas.hud[name].icon, "text", icon)
|
||||
areas.hud[name].old_icon = icon
|
||||
end
|
||||
end
|
||||
end
|
||||
minetest.after(1.5, tick)
|
||||
end
|
||||
|
||||
tick()
|
||||
|
BIN
mods/areas/textures/areas_0_0_0.png
Normal file
After Width: | Height: | Size: 365 B |
BIN
mods/areas/textures/areas_0_0_1.png
Normal file
After Width: | Height: | Size: 668 B |
BIN
mods/areas/textures/areas_0_1_0.png
Normal file
After Width: | Height: | Size: 669 B |
BIN
mods/areas/textures/areas_0_1_1.png
Normal file
After Width: | Height: | Size: 669 B |
BIN
mods/areas/textures/areas_1_0_0.png
Normal file
After Width: | Height: | Size: 499 B |
BIN
mods/areas/textures/areas_1_0_1.png
Normal file
After Width: | Height: | Size: 385 B |
BIN
mods/areas/textures/areas_1_1_0.png
Normal file
After Width: | Height: | Size: 383 B |
BIN
mods/areas/textures/areas_1_1_1.png
Normal file
After Width: | Height: | Size: 792 B |