From 7ee2340f5cb778b690b29561906a0db452bfaa99 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 12 Mar 2020 01:55:47 +0100 Subject: [PATCH] Show chat message if using minimap incorrectly --- mods/ITEMS/mcl_maps/init.lua | 39 +++++++++++++++-------- mods/ITEMS/mcl_maps/locale/mcl_maps.de.tr | 1 + mods/ITEMS/mcl_maps/locale/template.txt | 1 + 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/mods/ITEMS/mcl_maps/init.lua b/mods/ITEMS/mcl_maps/init.lua index 4e6eefc4d..b15b27d32 100644 --- a/mods/ITEMS/mcl_maps/init.lua +++ b/mods/ITEMS/mcl_maps/init.lua @@ -28,6 +28,28 @@ minetest.register_craftitem("mcl_maps:empty_map", { stack_max = 64, }) +-- Checks if player is still allowed to display the minimap +local function update_minimap(player) + local creative = minetest.settings:get_bool("creative_mode") + if creative then + player:hud_set_flags({minimap=true, minimap_radar = true}) + else + if has_item_in_hotbar(player, "mcl_maps:filled_map") then + player:hud_set_flags({minimap = true, minimap_radar = false}) + else + player:hud_set_flags({minimap = false, minimap_radar = false}) + end + end +end + +-- Remind player how to use the minimap correctly +local function use_minimap(itemstack, player, pointed_thing) + if player and player:is_player() then + update_minimap(player) + minetest.chat_send_player(player:get_player_name(), S("Use the minimap key to show the map.")) + end +end + -- Enables minimap if carried in hotbar. -- If this item is NOT in the hotbar, the minimap is unavailable -- Note: This is not at all like Minecraft right now. Minetest's minimap is pretty overpowered, it @@ -41,6 +63,9 @@ minetest.register_craftitem("mcl_maps:filled_map", { groups = { tool = 1 }, inventory_image = "mcl_maps_map_filled.png^(mcl_maps_map_filled_markings.png^[colorize:#000000)", stack_max = 1, + + on_use = use_minimap, + on_secondary_use = use_minimap, }) minetest.register_craft({ @@ -64,20 +89,6 @@ local function has_item_in_hotbar(player, item) return false end --- Checks if player is still allowed to display the minimap -local function update_minimap(player) - local creative = minetest.settings:get_bool("creative_mode") - if creative then - player:hud_set_flags({minimap=true, minimap_radar = true}) - else - if has_item_in_hotbar(player, "mcl_maps:filled_map") then - player:hud_set_flags({minimap = true, minimap_radar = false}) - else - player:hud_set_flags({minimap = false, minimap_radar = false}) - end - end -end - minetest.register_on_joinplayer(function(player) update_minimap(player) end) diff --git a/mods/ITEMS/mcl_maps/locale/mcl_maps.de.tr b/mods/ITEMS/mcl_maps/locale/mcl_maps.de.tr index c85363720..6d1836b48 100644 --- a/mods/ITEMS/mcl_maps/locale/mcl_maps.de.tr +++ b/mods/ITEMS/mcl_maps/locale/mcl_maps.de.tr @@ -7,3 +7,4 @@ Maps show your surroundings as you explore the world.=Karten zeigen Ihre Umgebun Hold the map in any of the hotbar slots. This allows you to access the minimap by pressing the minimap key (see controls settings).=Halten Sie die Karte in einen beliebigen Platz in der Schnellleiste. Damit können Sie jetzt die Übersichtskarte aktivieren, indem Sie die Taste zum Umschalten der Karte drücken (siehe Tastenbelegung). In Creative Mode, you don't need this item; the minimap is always available.=Im Kreativmodus brauchen Sie diesen Gegenstand nicht; die Übersichtskarte ist immer verfügbar. Enables minimap=Aktiviert Übersichtskarte +Use the minimap key to show the map.=Taste „Karte an/aus“ benutzen, um die Karte zu betrachten. diff --git a/mods/ITEMS/mcl_maps/locale/template.txt b/mods/ITEMS/mcl_maps/locale/template.txt index b7f850a95..061ed45e0 100644 --- a/mods/ITEMS/mcl_maps/locale/template.txt +++ b/mods/ITEMS/mcl_maps/locale/template.txt @@ -7,3 +7,4 @@ Maps show your surroundings as you explore the world.= Hold the map in any of the hotbar slots. This allows you to access the minimap by pressing the minimap key (see controls settings).= In Creative Mode, you don't need this item; the minimap is always available.= Enables minimap= +Use the minimap key to show the map.=