Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lonewolfht/mhud
A wrapper for more easily managing Minetest HUDs
https://github.com/lonewolfht/mhud
api hud minetest minetest-mod
Last synced: about 14 hours ago
JSON representation
A wrapper for more easily managing Minetest HUDs
- Host: GitHub
- URL: https://github.com/lonewolfht/mhud
- Owner: LoneWolfHT
- License: mit
- Created: 2021-04-05T03:16:31.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-26T16:23:54.000Z (about 1 year ago)
- Last Synced: 2024-09-26T09:00:12.687Z (about 14 hours ago)
- Topics: api, hud, minetest, minetest-mod
- Language: Lua
- Homepage:
- Size: 24.4 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# [M]inetest [HUD]
A wrapper for more easily managing Minetest HUDs# API
You can add this mod as a dependency in your mod.conf, or you can copy the `mhud.lua` file into your mod and use it that wayExample usage:
```lua
local hud = mhud.init()
hud:add(player, "test_hud", {
hud_elem_type = "text",
position = {x = 1, y = 0},
offset = {x = -6, y = 6},
alignment = {x = "left", y = "down"},
text = "Hello there",
color = 0x00FF00,
})
```## Mod-Specific Functions
* `mhud.init()`
Returns a hud wrapper you can use in your mod## Hud Wrapper Functions
Hud names are per-player, so you can use the same hud name for two different players
* `wrapper:add(, [hud name], )` -> `hud id`
* *player*: ObjectRef or PlayerName
* *hud name*: Name of hud. Useful if you plan on changing the hud later
* *def*: [Hud Definition]* `wrapper:[get | exists](, )` -> `{id = hud id, def = [Hud Definition]}` or `nil` if nonexistent
* *player*: ObjectRef or PlayerName
* *name*: Name (or id!) of the hud you want to get* `wrapper:change(, , )`
* *player*: ObjectRef or PlayerName
* *name*: Name (or id!) of the hud you want to change
* *def*: [Hud Definition]* `wrapper:[remove|clear](, [name])`
* *player*: ObjectRef or PlayerName
* *name*: Name (or id!) of the hud you want to remove. Leave out to remove all player's huds* `wrapper:[remove_all | clear_all]()`
* Removes all huds registered with `wrapper`## [Hud Definition]
MHud definitions are pretty much exactly the same as Minetest's. With some added aliases:### **Element Aliases**
### text
* `color` -> `number`
* `text_scale` -> `def.size {x = def.text_scale}`
### image
* `texture` -> `text`
* `image_scale` -> `def.size {x = def.image_scale, y = def.image_scale}`
### statbar
* `texture` -> `text`
* `textures {t1, t2}` -> `text`, `text2`
* `length` -> `number`
* `lengths {l1, l2}` -> `number`, `item`
* `force_image_size` -> `size`
### inventory
* `listname` -> `text`
* `size` -> `number`
* `selected` -> `item`
### waypoint
* `waypoint_text` -> `name`
* `suffix` -> `text`
* `color` -> `number`
### image_waypoint
* `texture` -> `text`
* `image_scale` -> `def.size {x = def.image_scale}`### **Misc**
* for `alignment` and `direction` you can use up/left/right/down/center instead of the numbers used by the Minetest API