3 -- Mod global namespace
8 -- Load support for MT game translation.
9 local S = minetest.get_translator("map")
12 -- Cache creative mode setting
14 local creative_mode_cache = minetest.settings:get_bool("creative_mode")
18 -- Global to allow overriding
20 function map.update_hud_flags(player)
21 local creative_enabled =
22 (creative and creative.is_enabled_for(player:get_player_name())) or
25 local minimap_enabled = creative_enabled or
26 player:get_inventory():contains_item("main", "map:mapping_kit")
27 local radar_enabled = creative_enabled
29 player:hud_set_flags({
30 minimap = minimap_enabled,
31 minimap_radar = radar_enabled
36 -- Set HUD flags 'on joinplayer'
38 minetest.register_on_joinplayer(function(player)
39 map.update_hud_flags(player)
43 -- Cyclic update of HUD flags
45 local function cyclic_update()
46 for _, player in ipairs(minetest.get_connected_players()) do
47 map.update_hud_flags(player)
49 minetest.after(5.3, cyclic_update)
52 minetest.after(5.3, cyclic_update)
57 minetest.register_craftitem("map:mapping_kit", {
58 description = S("Mapping Kit") .. "\n" .. S("Use with 'Minimap' key"),
59 inventory_image = "map_mapping_kit.png",
61 groups = {flammable = 3},
63 on_use = function(itemstack, user, pointed_thing)
64 map.update_hud_flags(user)
71 minetest.register_craft({
72 output = "map:mapping_kit",
74 {"default:glass", "default:paper", "group:stick"},
75 {"default:steel_ingot", "default:paper", "default:steel_ingot"},
76 {"group:wood", "default:paper", "dye:black"},
83 minetest.register_craft({
85 recipe = "map:mapping_kit",