1
0
Fork 0

Show chat message if using minimap incorrectly

This commit is contained in:
Wuzzy 2020-03-12 01:55:47 +01:00
parent 312b5aeb73
commit 7ee2340f5c
3 changed files with 27 additions and 14 deletions

View File

@ -28,6 +28,28 @@ minetest.register_craftitem("mcl_maps:empty_map", {
stack_max = 64, 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. -- Enables minimap if carried in hotbar.
-- If this item is NOT in the hotbar, the minimap is unavailable -- 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 -- 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 }, groups = { tool = 1 },
inventory_image = "mcl_maps_map_filled.png^(mcl_maps_map_filled_markings.png^[colorize:#000000)", inventory_image = "mcl_maps_map_filled.png^(mcl_maps_map_filled_markings.png^[colorize:#000000)",
stack_max = 1, stack_max = 1,
on_use = use_minimap,
on_secondary_use = use_minimap,
}) })
minetest.register_craft({ minetest.register_craft({
@ -64,20 +89,6 @@ local function has_item_in_hotbar(player, item)
return false return false
end 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) minetest.register_on_joinplayer(function(player)
update_minimap(player) update_minimap(player)
end) end)

View File

@ -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). 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. 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 Enables minimap=Aktiviert Übersichtskarte
Use the minimap key to show the map.=Taste „Karte an/aus“ benutzen, um die Karte zu betrachten.

View File

@ -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).= 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.= In Creative Mode, you don't need this item; the minimap is always available.=
Enables minimap= Enables minimap=
Use the minimap key to show the map.=