Add hud_compass mod @ Git commit 648c744...
ContentDB: https://content.minetest.net/packages/kestral/hud_compass/ Commit: https://github.com/kestral246/hud_compass/tree/648c744master
|
@ -139,6 +139,8 @@ The game includes the mods from the default [minetest_game](https://github.com/m
|
|||
* [bookmarks_gui][] ([BSD 3-Clause][lic.bookmarks_gui]) -- version: [f7ae10a Git][ver.bookmarks_gui] *2017-08-29*
|
||||
* [hbarmor][] ([MIT][lic.mit] / [CC BY-SA][lic.ccbysa3.0]) -- version: [1.0.0][ver.hbarmor] *2019-04-01*
|
||||
* [home_gui][] ([BSD 3-Clause][lic.home_gui]) -- version: [425466a Git][ver.home_gui] *2021-05-21* ([patched][home_gui.patch])
|
||||
* [hud_compass][] (MIT / [CC BY-SA ][lic.ccbysa3.0]) -- version: [648c744
|
||||
Git][ver.hud_compass] *2020-04-23*
|
||||
* [hudbars][] ([MIT][lic.mit] / [CC BY-SA][lic.ccbysa3.0]) -- version: [2.3.1][ver.hudbars] *2020-07-11*
|
||||
* [pbmarks][] ([MIT][lic.pbmarks]) -- version: [00c3549 Git][ver.pbmarks] *2021-05-28*
|
||||
* world/
|
||||
|
@ -315,6 +317,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
|
|||
[homedecor]: https://forum.minetest.net/viewtopic.php?t=2041
|
||||
[hot_air_balloons]: https://forum.minetest.net/viewtopic.php?t=22367
|
||||
[hovercraft]: https://forum.minetest.net/viewtopic.php?t=6722
|
||||
[hud_compass]: https://content.minetest.net/packages/kestral/hud_compass/
|
||||
[hudbars]: https://forum.minetest.net/viewtopic.php?t=11153
|
||||
[ilights]: https://forum.minetest.net/viewtopic.php?t=12200
|
||||
[intllib]: https://forum.minetest.net/viewtopic.php?t=4929
|
||||
|
@ -566,6 +569,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
|
|||
[ver.homedecor]: https://gitlab.com/VanessaE/homedecor_modpack/tree/f1dc68a
|
||||
[ver.hot_air_balloons]: https://notabug.org/NetherEran/hot_air_balloons/src/39a3572ad1bf7fd800525d68b128981e1b2c37d1
|
||||
[ver.hovercraft]: https://github.com/stujones11/hovercraft/tree/4d50e68
|
||||
[ver.hud_compass]: https://github.com/kestral246/hud_compass/tree/648c744
|
||||
[ver.hudbars]: http://repo.or.cz/minetest_hudbars.git/tree/0684bac
|
||||
[ver.ilights]: https://gitlab.com/VanessaE/ilights/tags/2021-02-25-01
|
||||
[ver.intllib]: https://github.com/minetest-mods/intllib/tree/6ebdc53
|
||||
|
|
|
@ -2643,6 +2643,16 @@ torches_enable_ceiling = false
|
|||
#hidename.use_alpha = false
|
||||
|
||||
|
||||
# *** hud_compass *** #
|
||||
|
||||
## Define default to place compass and whether to use clock.
|
||||
# -1 to -4 = compass only (disabled), -5 to -8 = compass + clock (disabled)
|
||||
# 1 to 4 = compass only (enabled), 5 to 8 = compass + clock (enabled)
|
||||
# type: enum
|
||||
# default: -2
|
||||
#compass_default_corner = -2
|
||||
|
||||
|
||||
# *** hudbars *** #
|
||||
|
||||
## Specifies how the value indicators (i.e. health, breath, etc.) look.
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
HUD Compass [hud_compass]
|
||||
-------------------------
|
||||
|
||||
A Minetest mod to optionally place a HUD compass and a 24-hour clock on the screen.
|
||||
|
||||
By David G (kestral246)
|
||||
|
||||
![HUD Compass Screenshot](screenshot.png "hud_compass")
|
||||
|
||||
How to enable
|
||||
-------------
|
||||
|
||||
This mod defaults to not displaying a compass or a clock. To enable, use the chat command:
|
||||
|
||||
"/compass" -> By default this places just a compass in the bottom right corner of the screen.
|
||||
|
||||
Repeated use of this command will toggle the display of the compass off and on.
|
||||
|
||||
When given with an argument, the user can select whether to display just a compass, or a compass and a clock, and which corner of the screen to place them in. This is particularly useful with Android clients, where the bottom right corner of the screen has the jump button.
|
||||
|
||||
"/compass 1" -> compass only, top right corner
|
||||
"/compass 2" -> compass only, bottom right corner
|
||||
"/compass 3" -> compass only, bottom left corner
|
||||
"/compass 4" -> compass only, top left corner
|
||||
|
||||
"/compass 5" -> compass and clock, top right corner
|
||||
"/compass 6" -> compass and clock, bottom right corner
|
||||
"/compass 7" -> compass and clock, bottom left corner
|
||||
"/compass 8" -> compass and clock, top left corner
|
||||
|
||||
In addition:
|
||||
|
||||
"/compass 0" -> forces compass and clock off.
|
||||
|
||||
**Note:** The clock is a 24-hour clock, with only one hand that displays the hours. Noon is at the top and midnight is at the bottom.
|
||||
|
||||
**New:** The default initial state can now be set in minetest.conf using "compass\_default\_corner = n", where "n" can be one of the eight corner numbers above. If it's positive, the compass (or compass and clock) will be enabled at start, while if it's negative, they will start disabled.
|
||||
|
||||
Local mod storage is used to maintain the state and position of hud_compass display between sessions, per user.
|
||||
|
||||
|
||||
Special Thanks
|
||||
--------------
|
||||
Special thanks go out to MoNTE48, for pointing out that the image files could be significantly reduced with zopflipng (much better than with optipng), in this mod's first Pull Request.
|
||||
|
||||
|
||||
Licenses
|
||||
--------
|
||||
Source code
|
||||
|
||||
> The MIT License (MIT)
|
||||
|
||||
Media (textures)
|
||||
|
||||
> Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
|
||||
> (Compass textures were copied from my realcompass mod, which were originally based on the textures created by tacotexmex for the ccompass mod. Clock textures were derived from these same textures.)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
-- hud_compass
|
||||
-- Optionally place a compass and 24-hour clock on the screen.
|
||||
-- A HUD version of my realcompass mod.
|
||||
-- By David_G (kestral246@gmail.com)
|
||||
-- 2019-12-31
|
||||
|
||||
local hud_compass = {}
|
||||
local storage = minetest.get_mod_storage()
|
||||
|
||||
-- State of hud_compass
|
||||
-- 1 = NE, 2 = SE, 3 = SW, 4 = NW (just compass)
|
||||
-- 5 = NE, 6 = SE, 7 = SW, 8 = NW (both compass and clock)
|
||||
-- positive == enabled, negative == disabled
|
||||
|
||||
-- Define default (if not overridden): SE corner, compass only, off by default
|
||||
local default_corner = tonumber(minetest.settings:get("compass_default_corner") or -2)
|
||||
|
||||
local lookup_compass = {
|
||||
{hud_elem_type="image", text="", position={x=1,y=0}, scale={x=4,y=4}, alignment={x=-1,y=1}, offset={x=-8,y=4}},
|
||||
{hud_elem_type="image", text="", position={x=1,y=1}, scale={x=4,y=4}, alignment={x=-1,y=-1}, offset={x=-8,y=-4}},
|
||||
{hud_elem_type="image", text="", position={x=0,y=1}, scale={x=4,y=4}, alignment={x=1,y=-1}, offset={x=8,y=-4}},
|
||||
{hud_elem_type="image", text="", position={x=0,y=0}, scale={x=4,y=4}, alignment={x=1,y=1}, offset={x=8,y=4}},
|
||||
{hud_elem_type="image", text="", position={x=1,y=0}, scale={x=4,y=4}, alignment={x=-1,y=1}, offset={x=-76,y=4}},
|
||||
{hud_elem_type="image", text="", position={x=1,y=1}, scale={x=4,y=4}, alignment={x=-1,y=-1}, offset={x=-76,y=-4}},
|
||||
{hud_elem_type="image", text="", position={x=0,y=1}, scale={x=4,y=4}, alignment={x=1,y=-1}, offset={x=76,y=-4}},
|
||||
{hud_elem_type="image", text="", position={x=0,y=0}, scale={x=4,y=4}, alignment={x=1,y=1}, offset={x=76,y=4}}
|
||||
}
|
||||
local lookup_clock = {
|
||||
{hud_elem_type="image", text="", position={x=1,y=0}, scale={x=4,y=4}, alignment={x=-1,y=1}, offset={x=-8,y=4}},
|
||||
{hud_elem_type="image", text="", position={x=1,y=1}, scale={x=4,y=4}, alignment={x=-1,y=-1}, offset={x=-8,y=-4}},
|
||||
{hud_elem_type="image", text="", position={x=0,y=1}, scale={x=4,y=4}, alignment={x=1,y=-1}, offset={x=8,y=-4}},
|
||||
{hud_elem_type="image", text="", position={x=0,y=0}, scale={x=4,y=4}, alignment={x=1,y=1}, offset={x=8,y=4}},
|
||||
{hud_elem_type="image", text="", position={x=1,y=0}, scale={x=4,y=4}, alignment={x=-1,y=1}, offset={x=-8,y=4}},
|
||||
{hud_elem_type="image", text="", position={x=1,y=1}, scale={x=4,y=4}, alignment={x=-1,y=-1}, offset={x=-8,y=-4}},
|
||||
{hud_elem_type="image", text="", position={x=0,y=1}, scale={x=4,y=4}, alignment={x=1,y=-1}, offset={x=8,y=-4}},
|
||||
{hud_elem_type="image", text="", position={x=0,y=0}, scale={x=4,y=4}, alignment={x=1,y=1}, offset={x=8,y=4}}
|
||||
}
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local pname = player:get_player_name()
|
||||
local corner = default_corner
|
||||
if storage:get(pname) and tonumber(storage:get(pname)) then -- validate mod storage value
|
||||
local temp = math.floor(tonumber(storage:get(pname)))
|
||||
if temp ~= nil and temp ~= 0 and temp >= -8 and temp <= 8 then
|
||||
corner = temp
|
||||
end
|
||||
end
|
||||
hud_compass[pname] = {
|
||||
id_compass = player:hud_add(lookup_compass[math.abs(corner)]),
|
||||
last_image_compass = -1,
|
||||
id_clock = player:hud_add(lookup_clock[math.abs(corner)]),
|
||||
last_image_clock = -1,
|
||||
state = corner,
|
||||
}
|
||||
end)
|
||||
|
||||
minetest.register_chatcommand("compass", {
|
||||
params = "[<corner>]",
|
||||
description = "Change display of HUD Compass.",
|
||||
privs = {},
|
||||
func = function(pname, params)
|
||||
local player = minetest.get_player_by_name(pname)
|
||||
if params and string.len(params) > 0 then -- includes corner parameter
|
||||
local corner = tonumber(string.match(params, "^%d$"))
|
||||
if corner and corner == 0 then -- disable compass and clock
|
||||
player:hud_change(hud_compass[pname].id_compass, "text", "") -- blank hud compass
|
||||
hud_compass[pname].last_image_compass = -1
|
||||
player:hud_change(hud_compass[pname].id_clock, "text", "") -- blank hud clock
|
||||
hud_compass[pname].last_image_clock = -1
|
||||
hud_compass[pname].state = -1 * math.abs(hud_compass[pname].state)
|
||||
storage:set_string(pname, hud_compass[pname].state)
|
||||
elseif corner and corner > 0 and corner <= 4 then -- enable compass only to given corner
|
||||
player:hud_remove(hud_compass[pname].id_compass) -- remove old hud compass
|
||||
hud_compass[pname].last_image_compass = -1
|
||||
player:hud_remove(hud_compass[pname].id_clock) -- remove old hud clock
|
||||
hud_compass[pname].last_image_clock = -1
|
||||
hud_compass[pname].id_compass = player:hud_add(lookup_compass[corner]) -- place new hud compass at requested corner
|
||||
hud_compass[pname].state = corner
|
||||
storage:set_string(pname, corner)
|
||||
elseif corner and corner >= 5 and corner <= 8 then -- enable compass and clock to given corner
|
||||
player:hud_remove(hud_compass[pname].id_compass) -- remove old hud compass
|
||||
hud_compass[pname].last_image_compass = -1
|
||||
player:hud_remove(hud_compass[pname].id_clock) -- remove old hud clock
|
||||
hud_compass[pname].last_image_clock = -1
|
||||
hud_compass[pname].id_compass = player:hud_add(lookup_compass[corner]) -- place new hud compass at requested corner
|
||||
hud_compass[pname].id_clock = player:hud_add(lookup_clock[corner]) -- place new hud clock at requested corner
|
||||
hud_compass[pname].state = corner
|
||||
storage:set_string(pname, corner)
|
||||
end
|
||||
else -- just toggle hud
|
||||
if hud_compass[pname].state > 0 then -- is enabled
|
||||
player:hud_change(hud_compass[pname].id_compass, "text", "") -- blank hud compass
|
||||
hud_compass[pname].last_image_compass = -1
|
||||
player:hud_change(hud_compass[pname].id_clock, "text", "") -- blank hud clock
|
||||
hud_compass[pname].last_image_clock = -1
|
||||
end
|
||||
hud_compass[pname].state = -1 * hud_compass[pname].state -- toggle state
|
||||
storage:set_string(pname, hud_compass[pname].state)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
local pname = player:get_player_name()
|
||||
if hud_compass[pname] then
|
||||
hud_compass[pname] = nil
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
local players = minetest.get_connected_players()
|
||||
for i,player in ipairs(players) do
|
||||
local pname = player:get_player_name()
|
||||
local dir = player:get_look_horizontal()
|
||||
-- Calculate image indexes for compass and clock.
|
||||
local angle_relative = math.deg(dir)
|
||||
local image_compass = math.floor((angle_relative/22.5) + 0.5)%16
|
||||
local image_clock = math.floor(24 * minetest.get_timeofday())
|
||||
|
||||
if hud_compass[pname].state > 0 and image_compass ~= hud_compass[pname].last_image_compass then
|
||||
local rc = player:hud_change(hud_compass[pname].id_compass, "text", "realcompass_"..image_compass..".png")
|
||||
-- Check return code, seems to fix occasional startup glitch.
|
||||
if rc == 1 then
|
||||
hud_compass[pname].last_image_compass = image_compass
|
||||
end
|
||||
end
|
||||
if hud_compass[pname].state >= 5 and image_clock ~= hud_compass[pname].last_image_clock then
|
||||
local rc = player:hud_change(hud_compass[pname].id_clock, "text", "hud_24hr_clock_"..image_clock..".png")
|
||||
-- Check return code, seems to fix occasional startup glitch.
|
||||
if rc == 1 then
|
||||
hud_compass[pname].last_image_clock = image_clock
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
|
@ -0,0 +1,2 @@
|
|||
name = hud_compass
|
||||
description = Optionally place a HUD compass and 24-hour clock on the screen.
|
After Width: | Height: | Size: 150 KiB |
|
@ -0,0 +1,8 @@
|
|||
# This file contains settings for wand_of_illumination that can be changed in
|
||||
# minetest.conf
|
||||
|
||||
# Define default to place compass and whether to use clock.
|
||||
# -1 to -4 = compass only (disabled), -5 to -8 = compass + clock (disabled)
|
||||
# 1 to 4 = compass only (enabled), 5 to 8 = compass + clock (enabled)
|
||||
# (default = -2)
|
||||
compass_default_corner (Default corner to place compass) enum -2 -8,-7,-6,-5,-4,-3,-2,-1,1,2,3,4,5,6,7,8
|
After Width: | Height: | Size: 397 B |
After Width: | Height: | Size: 401 B |
After Width: | Height: | Size: 395 B |
After Width: | Height: | Size: 400 B |
After Width: | Height: | Size: 395 B |
After Width: | Height: | Size: 396 B |
After Width: | Height: | Size: 396 B |
After Width: | Height: | Size: 394 B |
After Width: | Height: | Size: 395 B |
After Width: | Height: | Size: 392 B |
After Width: | Height: | Size: 388 B |
After Width: | Height: | Size: 390 B |
After Width: | Height: | Size: 396 B |
After Width: | Height: | Size: 392 B |
After Width: | Height: | Size: 391 B |
After Width: | Height: | Size: 396 B |
After Width: | Height: | Size: 402 B |
After Width: | Height: | Size: 395 B |
After Width: | Height: | Size: 392 B |
After Width: | Height: | Size: 390 B |
After Width: | Height: | Size: 388 B |
After Width: | Height: | Size: 390 B |
After Width: | Height: | Size: 395 B |
After Width: | Height: | Size: 394 B |
After Width: | Height: | Size: 484 B |
After Width: | Height: | Size: 486 B |
After Width: | Height: | Size: 493 B |
After Width: | Height: | Size: 483 B |
After Width: | Height: | Size: 480 B |
After Width: | Height: | Size: 487 B |
After Width: | Height: | Size: 491 B |
After Width: | Height: | Size: 484 B |
After Width: | Height: | Size: 493 B |
After Width: | Height: | Size: 489 B |
After Width: | Height: | Size: 480 B |
After Width: | Height: | Size: 488 B |
After Width: | Height: | Size: 491 B |
After Width: | Height: | Size: 484 B |
After Width: | Height: | Size: 484 B |
After Width: | Height: | Size: 486 B |
|
@ -630,6 +630,15 @@ sprint_breath_drain (Breath drain) float 1
|
|||
hidename.use_alpha (Use nametag alpha level) bool false
|
||||
|
||||
|
||||
[*hud_compass]
|
||||
|
||||
# Define default to place compass and whether to use clock.
|
||||
# -1 to -4 = compass only (disabled), -5 to -8 = compass + clock (disabled)
|
||||
# 1 to 4 = compass only (enabled), 5 to 8 = compass + clock (enabled)
|
||||
# (default = -2)
|
||||
compass_default_corner (Default corner to place compass) enum -2 -8,-7,-6,-5,-4,-3,-2,-1,1,2,3,4,5,6,7,8
|
||||
|
||||
|
||||
[*hudbars]
|
||||
|
||||
[**Appearance]
|
||||
|
|