HUD reskin
parent
3d417d5f4a
commit
0f283fb5b5
|
@ -13,6 +13,8 @@ end)
|
|||
|
||||
|
||||
arena_lib.on_start("skywars", function(arena)
|
||||
arena.match_players = arena.players_amount
|
||||
|
||||
for pl_name in pairs(arena.players) do
|
||||
local player = minetest.get_player_by_name(pl_name)
|
||||
|
||||
|
|
|
@ -4,47 +4,53 @@ function skywars.generate_HUD(arena, pl_name)
|
|||
local players_killed_
|
||||
local background_players_
|
||||
local background_kill_counter_
|
||||
|
||||
local x_pos = 0.45
|
||||
local y_pos = 0
|
||||
local scale = 3.5
|
||||
local distance_x = 45
|
||||
local background_width = 32*scale
|
||||
|
||||
background_players_counter_ = player:hud_add({
|
||||
hud_elem_type = "image",
|
||||
position = {x = 1, y = 0.45},
|
||||
offset = {x = -109, y = 80},
|
||||
position = {x = x_pos, y = y_pos},
|
||||
offset = {x = distance_x+background_width, y = 50},
|
||||
text = "sw_players_hud.png",
|
||||
alignment = { x = 1.0},
|
||||
scale = { x = 3, y = 3},
|
||||
scale = { x = scale, y = scale},
|
||||
number = 0xFFFFFF,
|
||||
})
|
||||
|
||||
|
||||
background_kill_counter_ = player:hud_add({
|
||||
hud_elem_type = "image",
|
||||
position = {x = x_pos, y = y_pos},
|
||||
offset = {x = -distance_x, y = 50},
|
||||
text = "sw_kill_counter_hud.png",
|
||||
alignment = { x = 1.0},
|
||||
scale = { x = scale, y = scale},
|
||||
number = 0xFFFFFF,
|
||||
})
|
||||
|
||||
-- The number of players in the game
|
||||
players_count_ = player:hud_add({
|
||||
hud_elem_type = "text",
|
||||
position = {x = 1, y = 0.45},
|
||||
offset = {x = -85, y = 80},
|
||||
text = arena.players_amount,
|
||||
position = {x = x_pos, y = y_pos},
|
||||
offset = {x = distance_x+background_width+39, y = 50+6},
|
||||
text = tostring(arena.players_amount) .. "/" .. tostring(arena.match_players),
|
||||
alignment = { x = 0},
|
||||
scale = { x = 100, y = 100},
|
||||
number = 0x7d7071,
|
||||
})
|
||||
|
||||
background_kill_counter_ = player:hud_add({
|
||||
hud_elem_type = "image",
|
||||
position = {x = 1, y = 0.45},
|
||||
offset = {x = -109, y = 0},
|
||||
text = "sw_kill_counter_hud.png",
|
||||
alignment = { x = 1.0},
|
||||
scale = { x = 3, y = 3},
|
||||
number = 0xFFFFFF,
|
||||
number = 0xdff6f5,
|
||||
})
|
||||
|
||||
-- The number of players killed
|
||||
players_killed_ = player:hud_add({
|
||||
hud_elem_type = "text",
|
||||
position = {x = 1, y = 0.45},
|
||||
offset = {x = -85, y = 0},
|
||||
position = {x = x_pos, y = y_pos},
|
||||
offset = {x = -distance_x+33, y = 50+5},
|
||||
text = 0,
|
||||
alignment = { x = 0},
|
||||
scale = { x = 100, y = 100},
|
||||
number = 0x7d7071,
|
||||
number = 0xdff6f5,
|
||||
})
|
||||
|
||||
-- Save the huds of each player
|
||||
|
@ -82,7 +88,10 @@ function skywars.update_players_counter(arena, players_updated)
|
|||
-- updating the player counter HUD
|
||||
for pl_name in pairs(arena.players) do
|
||||
local player = minetest.get_player_by_name(pl_name)
|
||||
|
||||
-- if the temp property doesn't exists then return
|
||||
if arena.match_players == nil then return end
|
||||
|
||||
player:hud_change(arena.HUDs[pl_name].players_count, "text", pl_amount)
|
||||
player:hud_change(arena.HUDs[pl_name].players_count, "text", tostring(arena.players_amount) .. "/" .. tostring(arena.match_players))
|
||||
end
|
||||
end
|
3
init.lua
3
init.lua
|
@ -11,7 +11,8 @@ arena_lib.register_minigame("skywars", {
|
|||
loading_time = skywars_settings.loading_time,
|
||||
queue_waiting_time = skywars_settings.queue_waiting_time,
|
||||
temp_properties = {
|
||||
HUDs = {}
|
||||
HUDs = {},
|
||||
match_players = 0
|
||||
},
|
||||
properties = {
|
||||
chests = {},
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 485 B After Width: | Height: | Size: 438 B |
Binary file not shown.
Before Width: | Height: | Size: 589 B After Width: | Height: | Size: 396 B |
Loading…
Reference in New Issue