mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-12-23 08:29:34 +01:00
add documentation
This commit is contained in:
parent
b5f7ae5458
commit
c31c852a6e
5 changed files with 46 additions and 4 deletions
|
@ -84,7 +84,7 @@ local function attach_object(self, obj)
|
|||
end
|
||||
end, name)
|
||||
obj:set_look_horizontal(yaw)
|
||||
mcl_title.set(obj, "actionbar", {text=S("Sneak to dismount"), color="white", stay=3})
|
||||
mcl_title.set(obj, "actionbar", {text=S("Sneak to dismount"), color="white", stay=60})
|
||||
else
|
||||
obj:get_luaentity()._old_visual_size = visual_size
|
||||
end
|
||||
|
|
|
@ -646,7 +646,7 @@ register_minecart(
|
|||
if player then
|
||||
mcl_player.player_set_animation(player, "sit" , 30)
|
||||
player:set_eye_offset({x=0, y=-5.5, z=0},{x=0, y=-4, z=0})
|
||||
mcl_title.set(clicker, "actionbar", {text=S("Sneak to dismount"), color="white", stay=3})
|
||||
mcl_title.set(clicker, "actionbar", {text=S("Sneak to dismount"), color="white", stay=60})
|
||||
end
|
||||
end, name)
|
||||
end
|
||||
|
|
42
mods/HUD/mcl_title/API.md
Normal file
42
mods/HUD/mcl_title/API.md
Normal file
|
@ -0,0 +1,42 @@
|
|||
# mcl_title
|
||||
|
||||
Allow mods to show messages in the hud of players.
|
||||
|
||||
## mcl_title.set(player, type, data)
|
||||
|
||||
Show a hud message of `type` to player `player` with `data` as params.
|
||||
|
||||
The element will stay for the per-player param `stay` or `data.stay` (in gametick which is 1/20 second).
|
||||
|
||||
Here is a usage exemple:
|
||||
|
||||
```lua
|
||||
--show a title in the HUD with minecraft color "gold"
|
||||
mcl_title.set(player, "title", {text="dummy text", color="gold"})
|
||||
|
||||
--show a subtitle in the HUD with hex color "#612D2D"
|
||||
mcl_title.set(player, "subtitle", {text="dummy subtitle", color="#612D2D"})
|
||||
|
||||
--show an actionbar in the HUD (above the hotbar) with minecraft color "red"
|
||||
mcl_title.set(player, "subtitle", {text="dummy actionbar", color="red"})
|
||||
|
||||
--show a title in the HUD with minecraft color "gold" staying for 3 seconds (override stay setting)
|
||||
mcl_title.set(player, "title", {text="dummy text", color="gold", stay=3})
|
||||
```
|
||||
|
||||
## mcl_title.remove(player, type)
|
||||
|
||||
Hide HUD element of type `type` for player `player`.
|
||||
|
||||
## mcl_title.clear(player)
|
||||
|
||||
Remove every title/subtitle/actionbar from a player.
|
||||
Basicaly run `mcl_title.remove(player, type)` for every type.
|
||||
|
||||
## mcl_title.params_set(player, params)
|
||||
|
||||
Allow mods to set `stay` and upcomming `fadeIn`/`fadeOut` params.
|
||||
|
||||
```lua
|
||||
mcl_title.params_set(player, {stay = 600}) --elements with no 'data.stay' field will stay during 30s (600/20)
|
||||
```
|
|
@ -134,7 +134,7 @@ function mcl_title.set(player, type, data)
|
|||
|
||||
player:hud_change(huds_idx[type][player], "text", data.text)
|
||||
player:hud_change(huds_idx[type][player], "number", hex_color)
|
||||
hud_hide_timeouts[type][player:get_player_name()] = data.stay or mcl_title.params_get(player).stay
|
||||
hud_hide_timeouts[type][player:get_player_name()] = gametick_to_secondes(data.stay) or mcl_title.params_get(player).stay
|
||||
return true
|
||||
end
|
||||
|
||||
|
|
|
@ -330,7 +330,7 @@ function mcl_beds.on_rightclick(pos, player, is_top)
|
|||
message = select(2, lay_down(player, ppos, other))
|
||||
end
|
||||
if message then
|
||||
mcl_title.set(player, "actionbar", {text=message, color="white", stay=3})
|
||||
mcl_title.set(player, "actionbar", {text=message, color="white", stay=60})
|
||||
end
|
||||
else
|
||||
lay_down(player, nil, nil, false)
|
||||
|
|
Loading…
Reference in a new issue