mirror of
https://repo.or.cz/minetest_orienteering.git
synced 2024-12-12 16:53:16 +01:00
Make HUD position configurable
This commit is contained in:
parent
fd1601293d
commit
4d6d7cbe13
@ -35,7 +35,8 @@ The following tools are available:
|
||||
To toggle between 12h and 24h mode for the displayed time, wield any device
|
||||
which is capable of displaying the time and press the left mouse button.
|
||||
|
||||
## Configuration recommendations
|
||||
## Configuration
|
||||
### Recommendations
|
||||
Note that in Minetest, it is also possible to access the coordinates, angles,
|
||||
etc. through the debug menu, but this would be generally considered cheating as
|
||||
this defeats the purpose of this mod. Try to resist this urge.
|
||||
@ -45,6 +46,9 @@ following line into your `minetest.conf`:
|
||||
|
||||
keymap_toggle_debug =
|
||||
|
||||
### HUD text position
|
||||
The text position can be configured by using Minetest's settings system. See
|
||||
the advanced settings menu for more information.
|
||||
|
||||
## Crafting recipes
|
||||
Crafting recipes are only available when the default mod is used.
|
||||
|
28
init.lua
28
init.lua
@ -11,6 +11,26 @@ orienteering.playerhuds = {}
|
||||
orienteering.settings = {}
|
||||
orienteering.settings.speed_unit = S("m/s")
|
||||
orienteering.settings.length_unit = S("m")
|
||||
orienteering.settings.hud_pos = { x = 0.5, y = 0 }
|
||||
orienteering.settings.hud_offset = { x = 0, y = 15 }
|
||||
orienteering.settings.hud_alignment = { x = 0, y = 0 }
|
||||
|
||||
local set = tonumber(minetest.setting_get("orienteering_hud_pos_x"))
|
||||
if set then orienteering.settings.hud_pos.x = set end
|
||||
set = tonumber(minetest.setting_get("orienteering_hud_pos_y"))
|
||||
if set then orienteering.settings.hud_pos.y = set end
|
||||
set = tonumber(minetest.setting_get("orienteering_hud_offset_x"))
|
||||
if set then orienteering.settings.hud_offset.x = set end
|
||||
set = tonumber(minetest.setting_get("orienteering_hud_offset_y"))
|
||||
if set then orienteering.settings.hud_offset.y = set end
|
||||
set = minetest.setting_get("orienteering_hud_alignment")
|
||||
if set == "left" then
|
||||
orienteering.settings.hud_alignment.x = 1
|
||||
elseif set == "center" then
|
||||
orienteering.settings.hud_alignment.x = 0
|
||||
elseif set == "right" then
|
||||
orienteering.settings.hud_alignment.x = -1
|
||||
end
|
||||
|
||||
local o_lines = 4 -- Number of lines in HUD
|
||||
|
||||
@ -182,6 +202,8 @@ function update_automapper(player)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
function init_hud(player)
|
||||
update_automapper(player)
|
||||
local name = player:get_player_name()
|
||||
@ -190,9 +212,9 @@ function init_hud(player)
|
||||
orienteering.playerhuds[name]["o_line"..i] = player:hud_add({
|
||||
hud_elem_type = "text",
|
||||
text = "",
|
||||
position = { x = 0.5, y = 0.001 },
|
||||
offset = { x = 0, y = 0+20*i },
|
||||
alignment = { x = 0, y = 0 },
|
||||
position = orienteering.settings.hud_pos,
|
||||
offset = { x = orienteering.settings.hud_offset.x, y = orienteering.settings.hud_offset.y + 20*(i-1) },
|
||||
alignment = orienteering.settings.hud_alignment,
|
||||
number = 0xFFFFFF,
|
||||
scale= { x = 100, y = 20 },
|
||||
})
|
||||
|
14
settingtypes.txt
Normal file
14
settingtypes.txt
Normal file
@ -0,0 +1,14 @@
|
||||
# Horizontal main position (x) of the Orienteering text.
|
||||
# 0.0 is left, 1.0 is right.
|
||||
orienteering_hud_pos_x (Horizontal Orienteering text screen position) float 0.5 0.0 1.0
|
||||
# Vertical main position (y) of the Orienteering text.
|
||||
# 0.0 is top, 1.0 is bottom.
|
||||
orienteering_hud_pos_y (Vertical Orienteering text screen position) float 0.0 0.0 1.0
|
||||
|
||||
# Horizontal offset (x) of the Orienteering text from the screen position.
|
||||
orienteering_hud_offset_x (Horizontal Orienteering text offset) int 0
|
||||
# Vertical offset (y) of the Orienteering text from the screen position.
|
||||
orienteering_hud_offset_y (Vertical Orienteering text offset) int 15
|
||||
|
||||
# Alignment of the Orienteering text.
|
||||
orienteering_hud_alignment (Orienteering text alignment) enum center left,center,right
|
Loading…
Reference in New Issue
Block a user