mirror of
https://repo.or.cz/minetest_orienteering.git
synced 2024-07-15 12:19:31 +02:00
Remember 12h mode for players after leaving
This commit is contained in:
parent
733c656d7b
commit
b2d7410107
13
init.lua
13
init.lua
@ -35,11 +35,13 @@ local o_lines = 4 -- Number of lines in HUD
|
|||||||
|
|
||||||
-- Helper function to switch between 12h and 24 mode for the time
|
-- Helper function to switch between 12h and 24 mode for the time
|
||||||
function orienteering.toggle_time_mode(itemstack, user, pointed_thing)
|
function orienteering.toggle_time_mode(itemstack, user, pointed_thing)
|
||||||
local name = user:get_player_name()
|
--[[ Player attribute “orienteering:twelve”:
|
||||||
if orienteering.playerhuds[name].twelve then
|
* "true": Use 12h mode for time
|
||||||
orienteering.playerhuds[name].twelve = false
|
* "false" or unset: Use 24h mode for time ]]
|
||||||
|
if user:get_attribute("orienteering:twelve") == "true" then
|
||||||
|
user:set_attribute("orienteering:twelve", "false")
|
||||||
else
|
else
|
||||||
orienteering.playerhuds[name].twelve = true
|
user:set_attribute("orienteering:twelve", "true")
|
||||||
end
|
end
|
||||||
orienteering.update_hud_displays(user)
|
orienteering.update_hud_displays(user)
|
||||||
end
|
end
|
||||||
@ -249,7 +251,6 @@ function orienteering.init_hud(player)
|
|||||||
scale= { x = 100, y = 20 },
|
scale= { x = 100, y = 20 },
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
orienteering.playerhuds[name].twelve = false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function orienteering.update_hud_displays(player)
|
function orienteering.update_hud_displays(player)
|
||||||
@ -312,7 +313,7 @@ function orienteering.update_hud_displays(player)
|
|||||||
local minutes = totalminutes % 60
|
local minutes = totalminutes % 60
|
||||||
local hours = math.floor((totalminutes - minutes) / 60)
|
local hours = math.floor((totalminutes - minutes) / 60)
|
||||||
minutes = math.floor(minutes)
|
minutes = math.floor(minutes)
|
||||||
local twelve = orienteering.playerhuds[name].twelve
|
local twelve = player:get_attribute("orienteering:twelve") == "true"
|
||||||
if twelve then
|
if twelve then
|
||||||
if hours == 12 and minutes == 0 then
|
if hours == 12 and minutes == 0 then
|
||||||
str_time = S("Time: noon")
|
str_time = S("Time: noon")
|
||||||
|
Loading…
Reference in New Issue
Block a user