1
0
Fork 0

add documentation

This commit is contained in:
AFCMS 2021-07-20 16:14:34 +02:00
parent b5f7ae5458
commit c31c852a6e
5 changed files with 46 additions and 4 deletions

View File

@ -84,7 +84,7 @@ local function attach_object(self, obj)
end end
end, name) end, name)
obj:set_look_horizontal(yaw) 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 else
obj:get_luaentity()._old_visual_size = visual_size obj:get_luaentity()._old_visual_size = visual_size
end end

View File

@ -646,7 +646,7 @@ register_minecart(
if player then if player then
mcl_player.player_set_animation(player, "sit" , 30) 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}) 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
end, name) end, name)
end end

42
mods/HUD/mcl_title/API.md Normal file
View 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)
```

View File

@ -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], "text", data.text)
player:hud_change(huds_idx[type][player], "number", hex_color) 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 return true
end end

View File

@ -330,7 +330,7 @@ function mcl_beds.on_rightclick(pos, player, is_top)
message = select(2, lay_down(player, ppos, other)) message = select(2, lay_down(player, ppos, other))
end end
if message then 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 end
else else
lay_down(player, nil, nil, false) lay_down(player, nil, nil, false)