forked from Mineclonia/Mineclonia
Darken handheld map in low light conditions
This commit is contained in:
parent
b10214e1e0
commit
f2e6e61c47
|
@ -425,6 +425,7 @@ minetest.register_craft_predict(on_craft)
|
||||||
|
|
||||||
local maps = {}
|
local maps = {}
|
||||||
local huds = {}
|
local huds = {}
|
||||||
|
local light = {}
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
local map_def = {
|
local map_def = {
|
||||||
|
@ -445,6 +446,7 @@ end)
|
||||||
|
|
||||||
minetest.register_on_leaveplayer(function(player)
|
minetest.register_on_leaveplayer(function(player)
|
||||||
maps[player] = nil
|
maps[player] = nil
|
||||||
|
light[player] = nil
|
||||||
huds[player] = nil
|
huds[player] = nil
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -513,8 +515,15 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if texture ~= maps[player] then
|
local light_level
|
||||||
player:hud_change(hud.map, "text", "[combine:140x140:0,0=mcl_maps_map_background.png:6,6=" .. texture)
|
local light_level_overlay = ""
|
||||||
|
if nil ~= pos then -- do not crash while joining game
|
||||||
|
light_level = minetest.get_node_light(pos) or 0 -- can be nil somehow
|
||||||
|
light_level_overlay = "^[colorize:black:" .. 255 - (light_level * 17)
|
||||||
|
end
|
||||||
|
|
||||||
|
if texture ~= maps[player] or light_level ~= light[player] then
|
||||||
|
player:hud_change(hud.map, "text", "[combine:140x140:0,0=mcl_maps_map_background.png:6,6=" .. texture .. light_level_overlay)
|
||||||
if nil == maps[player] then
|
if nil == maps[player] then
|
||||||
-- show tmp message if player
|
-- show tmp message if player
|
||||||
-- did not wield a map before
|
-- did not wield a map before
|
||||||
|
@ -523,6 +532,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
S("Right click on a banner to add a colored marker.")
|
S("Right click on a banner to add a colored marker.")
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
light[player] = light_level
|
||||||
maps[player] = texture
|
maps[player] = texture
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -578,7 +588,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
player:hud_change(hud.marker, "text", marker)
|
player:hud_change(hud.marker, "text", marker .. light_level_overlay)
|
||||||
player:hud_change(hud.marker, "offset", {x = (6 - 140 / 2 + pos.x - minp.x) * 2, y = (6 - 140 + maxp.z - pos.z) * 2})
|
player:hud_change(hud.marker, "offset", {x = (6 - 140 / 2 + pos.x - minp.x) * 2, y = (6 - 140 + maxp.z - pos.z) * 2})
|
||||||
elseif maps[player] then
|
elseif maps[player] then
|
||||||
player:hud_change(hud.map, "text", "blank.png")
|
player:hud_change(hud.map, "text", "blank.png")
|
||||||
|
|
Loading…
Reference in New Issue