Activate tools only when in hotbar

This commit is contained in:
Wuzzy 2016-10-28 16:47:27 +02:00
parent 0272f2dd24
commit 067891bb08
4 changed files with 37 additions and 27 deletions

@ -15,9 +15,9 @@ Orienteering” will be added.
## Tools
The orienteering tools are used automatically. To use them, you only need to
have them somewhere in your main player inventory. Most tools add information
at the top section of your screen. The minimap is disabled by default, in this
mod you have to acquire the proper tool first.
have them somewhere in your hotbar. Most tools add information at the top
section of your screen. The minimap is disabled by default, in this mod
you have to acquire the proper tool first.
The following tools are available:

@ -194,15 +194,25 @@ end
function orienteering.update_automapper(player)
local inv = player:get_inventory()
if inv:contains_item("main", "orienteering:automapper") or inv:contains_item("main", "orienteering:quadcorder") then
if orienteering.tool_active(player, "orienteering:automapper") or orienteering.tool_active(player, "orienteering:quadcorder") then
player:hud_set_flags({minimap = true})
else
player:hud_set_flags({minimap = false})
end
end
-- Checks whether a certain orienteering tool is “active” and ready for use
function orienteering.tool_active(player, item)
-- Requirement: player carries the tool in the hotbar
local inv = player:get_inventory()
local hotbar = player:hud_get_hotbar_itemcount()
for i=1, hotbar do
if inv:get_stack("main", i):get_name() == item then
return true
end
end
return false
end
function orienteering.init_hud(player)
orienteering.update_automapper(player)
@ -224,31 +234,30 @@ end
function orienteering.update_hud_displays(player)
local name = player:get_player_name()
local inv = player:get_inventory()
local gps, altimeter, triangulator, compass, sextant, watch, speedometer, quadcorder
if inv:contains_item("main", "orienteering:gps") then
if orienteering.tool_active(player, "orienteering:gps") then
gps = true
end
if inv:contains_item("main", "orienteering:altimeter") then
if orienteering.tool_active(player, "orienteering:altimeter") then
altimeter = true
end
if inv:contains_item("main", "orienteering:triangulator") then
if orienteering.tool_active(player, "orienteering:triangulator") then
triangulator = true
end
if inv:contains_item("main", "orienteering:compass") then
if orienteering.tool_active(player, "orienteering:compass") then
compass = true
end
if inv:contains_item("main", "orienteering:sextant") then
if orienteering.tool_active(player, "orienteering:sextant") then
sextant = true
end
if inv:contains_item("main", "orienteering:watch") then
if orienteering.tool_active(player, "orienteering:watch") then
watch = true
end
if inv:contains_item("main", "orienteering:speedometer") then
if orienteering.tool_active(player, "orienteering:speedometer") then
speedometer = true
end
if inv:contains_item("main", "orienteering:quadcorder") then
if orienteering.tool_active(player, "orienteering:quadcorder") then
quadcorder = true
end
@ -379,10 +388,10 @@ if minetest.get_modpath("doc_items") ~= nil then
["orienteering:automapper"] = S("The automapper automatically creates a map of the area around you and enables you to view a minimap of your surroundings. It also has a built-in radar."),
})
local use = S("Put this tool anywhere in your player inventory to see the data it provides.")
local use_watch = S("Put the watch anywhere in your player inventory to see the time. Leftclick to toggle between the 24-hour and 12-hour display.")
local use_time = S("Put this tool anywhere in your player inventory to make use of its functionality. Leftclick to toggle between 24-hour and 12-hour display for the time feature.")
local use_automapper = S("If you put an automapper in your player inventory, you will be able to access the minimap. By default the minimap can be opened with [F7].")
local use = S("Put this tool in your hotbar to see the data it provides.")
local use_watch = S("Put the watch in your hotbar to see the time. Leftclick to toggle between the 24-hour and 12-hour display.")
local use_time = S("Put this tool in your hotbar to make use of its functionality. Leftclick to toggle between 24-hour and 12-hour display for the time feature.")
local use_automapper = S("If you put an automapper in your hotbar, you will be able to access the minimap. By default the minimap can be opened with [F7].")
doc.sub.items.set_items_usagehelp({
["orienteering:compass"] = use,

@ -41,7 +41,8 @@ It shows you the current time. = Es zeigt Ihnen die aktuelle Uhrzeit.
This is the ultimate orientieering tool. It shows you your coordinates (X, Y and Z), shows your yaw and pitch (horizontal and vertical viewing angles), the current time, your current speed and it enables you to access the minimap. = Dies ist das ultimative Werkzeug für die Orientierung. Es zeigt Ihnen Ihre aktuellen Koordinaten (X, Y, und Z), zeigt Ihren Gier- und Nickwinkel (horizontaler und vertikaler Blickwinkel), die aktuelle Uhrzeit, Ihre aktuelle Geschwindigkeit und es ermöglicht es Ihnen, auf die Kleinkarte zuzugreifen.
The automapper automatically creates a map of the area around you and enables you to view a minimap of your surroundings. It also has a built-in radar. = Der Autokartierer erstellt automatisch eine Karte von Ihrer näheren Umgebung und ermöglicht es Ihnen, eine Kleinkarte davon zu betrachten. Er hat außerdem einen eingebauten Radar.
Put this tool anywhere in your player inventory to see the data it provides. = Legen Sie dieses Werkzeug irgendwo in Ihrem Spielerinventar ab, um die dazugehörigen Daten zu sehen.
Put the watch anywhere in your player inventory to see the time. Leftclick to toggle between the 24-hour and 12-hour display. = Legen Sie die Uhr irgendwo in Ihrem Spielerinventar ab, um die Uhrzeit zu sehen. Mit Linksklick können Sie zwischen der 24-Stunden- und der 2-mal-12-Stunden-Anzeige wechseln.
Put this tool anywhere in your player inventory to make use of its functionality. Leftclick to toggle between 24-hour and 12-hour display for the time feature. = Legen Sie dieses Werkzeug irgendwo in Ihrem Spielerinventar ab, um davon Gebrauch zu machen. Mit Linksklick können Sie zwischen der 24-Stunden- und der 2-mal-12-Stunden-Anzeige der Uhrenfunktion wechseln.
If you put an automapper in your player inventory, you will be able to access the minimap. By default the minimap can be opened with [F7]. = Wenn Sie einen Autokartierer in Ihrem Spielerinventar ablegen, können Sie auf die Kleinkarte zugreifen. Standardmäßig kann die Kleinkarte mit [F7] geöffnet werden.
Put this tool in your hotbar to see the data it provides. = Legen Sie dieses Werkzeug in Ihrer Schnellzugriffsleiste ab, um die dazugehörigen Daten zu sehen.
Put the watch in your hotbar to see the time. Leftclick to toggle between the 24-hour and 12-hour display. = Legen Sie die Uhr in Ihrer Schnellzugriffsleiste ab, um die Uhrzeit zu sehen. Mit Linksklick können Sie zwischen der 24-Stunden- und der 2-mal-12-Stunden-Anzeige wechseln.
Put this tool in your hotbar to make use of its functionality. Leftclick to toggle between 24-hour and 12-hour display for the time feature. = Legen Sie dieses Werkzeug irgendwo in Ihrem Spielerinventar ab, um davon Gebrauch zu machen. Mit Linksklick können Sie zwischen der 24-Stunden- und der 2-mal-12-Stunden-Anzeige der Uhrenfunktion wechseln.
If you put an automapper in your hotbar, you will be able to access the minimap. By default the minimap can be opened with [F7]. = Wenn Sie einen Autokartierer in Ihrer Schnellzugriffsleiste ablegen, können Sie auf die Kleinkarte zugreifen. Standardmäßig kann die Kleinkarte mit [F7] geöffnet werden.

@ -54,7 +54,7 @@ It shows you the current time.
This is the ultimate orientieering tool. It shows you your coordinates (X, Y and Z), shows your yaw and pitch (horizontal and vertical viewing angles), the current time, your current speed and it enables you to access the minimap.
The automapper automatically creates a map of the area around you and enables you to view a minimap of your surroundings. It also has a built-in radar.
Put this tool anywhere in your player inventory to see the data it provides.
Put the watch anywhere in your player inventory to see the time. Leftclick to toggle between the 24-hour and 12-hour display.
Put this tool anywhere in your player inventory to make use of its functionality. Leftclick to toggle between 24-hour and 12-hour display for the time feature.
If you put an automapper in your player inventory, you will be able to access the minimap. By default the minimap can be opened with [F7].
Put this tool in your hotbar to see the data it provides.
Put the watch in your hotbar to see the time. Leftclick to toggle between the 24-hour and 12-hour display.
Put this tool in your hotbar to make use of its functionality. Leftclick to toggle between 24-hour and 12-hour display for the time feature.
If you put an automapper in your hotbar, you will be able to access the minimap. By default the minimap can be opened with [F7].