forked from Desour/helicopter
-
Notifications
You must be signed in to change notification settings - Fork 6
/
heli_hud.lua
executable file
·80 lines (70 loc) · 2.48 KB
/
heli_hud.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
local heli_hud_list = {}
function update_heli_hud(player)
--[[
local player_name = player:get_player_name()
hour = minetest.env:get_timeofday() * 24
hour = math.ceil(hour)
-- Get the dig and place count from storage, or default to 0
local meta = player:get_meta()
local time_text = "Time of day: " .. hour .. "h "
local pos = player:get_pos()
local altitude = math.ceil(pos.y)
local altitude_text = "Altitude: " .. math.ceil(altitude)
local ids = heli_hud_list[player_name]
if ids then
player:hud_change(ids["time"], "text", time_text)
player:hud_change(ids["altitude"], "text", altitude_text)
else
local screen_pos_y = -250
local screen_pos_x = -100
ids = {}
ids["bg"] = player:hud_add({
hud_elem_type = "image",
position = {x = 1, y = 0.5},
offset = {x = -240 + screen_pos_x, y = -10 + screen_pos_y},
text = "flight_info_bg.png",
scale = { x = 1, y = 1},
alignment = { x = 1, y = 0 },
})
ids["title"] = player:hud_add({
hud_elem_type = "text",
position = {x = 1, y = 0.5},
offset = {x = -120 + screen_pos_x, y = -25 + screen_pos_y},
text = "Flight Information",
alignment = 0,
scale = { x = 100, y = 30},
number = 0xFFFFFF,
})
ids["time"] = player:hud_add({
hud_elem_type = "text",
position = {x = 1, y = 0.5},
offset = {x = -180 + screen_pos_x, y = 0 + screen_pos_y},
text = time_text,
alignment = -1,
scale = { x = 50, y = 10},
number = 0xFFFFFF,
})
ids["altitude"] = player:hud_add({
hud_elem_type = "text",
position = {x = 1, y = 0.5},
offset = {x = -70 + screen_pos_x, y = 0 + screen_pos_y},
text = altitude_text,
alignment = -1,
scale = { x = 50, y = 10},
number = 0xFFFFFF,
})
heli_hud_list[player_name] = ids
end
]]--
end
function remove_heli_hud(player)
--[[
local player_name = player:get_player_name()
local ids = heli_hud_list[player_name]
player:hud_remove(ids["altitude"])
player:hud_remove(ids["time"])
player:hud_remove(ids["title"])
player:hud_remove(ids["bg"])
heli_hud_list[player_name] = nil
]]--
end