mirror of
https://repo.or.cz/minetest_orienteering.git
synced 2025-01-10 06:37:30 +01:00
Disable MTG's map mod messing with hud flags
This commit is contained in:
parent
e04a9e8b3e
commit
0f205060ee
22
init.lua
22
init.lua
@ -1,5 +1,5 @@
|
|||||||
local S = minetest.get_translator("orienteering")
|
local S = minetest.get_translator("orienteering")
|
||||||
local mod_map = minetest.get_modpath("map")
|
local mod_map = minetest.get_modpath("map") -- map mod from Minetest Game
|
||||||
|
|
||||||
local orienteering = {}
|
local orienteering = {}
|
||||||
orienteering.playerhuds = {}
|
orienteering.playerhuds = {}
|
||||||
@ -243,27 +243,23 @@ if minetest.get_modpath("default") ~= nil then
|
|||||||
end
|
end
|
||||||
|
|
||||||
function orienteering.update_automapper(player)
|
function orienteering.update_automapper(player)
|
||||||
if mod_map then
|
|
||||||
if orienteering.tool_active(player, "orienteering:automapper") or orienteering.tool_active(player, "orienteering:quadcorder") or minetest.settings:get_bool("creative_mode") then
|
|
||||||
player:hud_set_flags({minimap_radar = true})
|
|
||||||
else
|
|
||||||
player:hud_set_flags({minimap_radar = false})
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if orienteering.tool_active(player, "orienteering:automapper") or orienteering.tool_active(player, "orienteering:quadcorder") or minetest.settings:get_bool("creative_mode") then
|
if orienteering.tool_active(player, "orienteering:automapper") or orienteering.tool_active(player, "orienteering:quadcorder") or minetest.settings:get_bool("creative_mode") then
|
||||||
player:hud_set_flags({minimap = true, minimap_radar = true})
|
player:hud_set_flags({minimap = true, minimap_radar = true})
|
||||||
elseif orienteering.tool_active(player, "orienteering:map") then
|
elseif ((not mod_map) and orienteering.tool_active(player, "orienteering:map")) or ((mod_map) and orienteering.tool_active(player, "map:mapping_kit")) then
|
||||||
player:hud_set_flags({minimap = true, minimap_radar = false})
|
player:hud_set_flags({minimap = true, minimap_radar = false})
|
||||||
else
|
else
|
||||||
player:hud_set_flags({minimap = false, minimap_radar = false})
|
player:hud_set_flags({minimap = false, minimap_radar = false})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
-- Checks whether a certain orienteering tool is “active” and ready for use
|
-- Checks whether a certain orienteering tool is “active” and ready for use
|
||||||
function orienteering.tool_active(player, item)
|
function orienteering.tool_active(player, item)
|
||||||
-- Requirement: player carries the tool in the hotbar
|
-- Requirement: player carries the tool in the hotbar
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
|
-- Exception: MTG's Mapping Kit can be anywhere
|
||||||
|
if item == "map:mapping_kit" then
|
||||||
|
return inv:contains_item("main", item)
|
||||||
|
end
|
||||||
local hotbar = player:hud_get_hotbar_itemcount()
|
local hotbar = player:hud_get_hotbar_itemcount()
|
||||||
for i=1, hotbar do
|
for i=1, hotbar do
|
||||||
if inv:get_stack("main", i):get_name() == item then
|
if inv:get_stack("main", i):get_name() == item then
|
||||||
@ -408,6 +404,12 @@ function orienteering.update_hud_displays(player)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if mod_map then
|
||||||
|
-- Disable all HUD flag handling in map mod because we already handle it
|
||||||
|
-- ourselves.
|
||||||
|
map.update_hud_flags = function() end
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_on_newplayer(orienteering.init_hud)
|
minetest.register_on_newplayer(orienteering.init_hud)
|
||||||
minetest.register_on_joinplayer(orienteering.init_hud)
|
minetest.register_on_joinplayer(orienteering.init_hud)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user