From 7bae8ab8389034209c4d272ee7f7c0d544c9d0d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20M=C3=BCller?= <34514239+appgurueu@users.noreply.github.com> Date: Wed, 10 Jan 2024 19:32:49 +0100 Subject: [PATCH] Fix HUD image (waypoint) docs --- doc/lua_api.md | 20 ++++++++++++-------- games/devtest/mods/testhud/init.lua | 3 ++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/doc/lua_api.md b/doc/lua_api.md index a85bb8152..06f48aac1 100644 --- a/doc/lua_api.md +++ b/doc/lua_api.md @@ -1678,10 +1678,12 @@ type are ignored. Displays an image on the HUD. -* `scale`: The scale of the image, with 1 being the original texture size. - Only the X coordinate scale is used (positive values). - Negative values represent that percentage of the screen it - should take; e.g. `x=-100` means 100% (width). +* `scale`: The scale of the image, with `{x = 1, y = 1}` being the original texture size. + The `x` and `y` fields apply to the respective axes. + Positive values scale the source image. + Negative values represent percentages relative to screen dimensions. + Example: `{x = -20, y = 3}` means the image will be drawn 20% of screen width wide, + and 3 times as high as the source image is. * `text`: The name of the texture that is displayed. * `alignment`: The alignment of the image. * `offset`: offset in pixels from position. @@ -1748,10 +1750,12 @@ Displays distance to selected world position. Same as `image`, but does not accept a `position`; the position is instead determined by `world_pos`, the world position of the waypoint. -* `scale`: The scale of the image, with 1 being the original texture size. - Only the X coordinate scale is used (positive values). - Negative values represent that percentage of the screen it - should take; e.g. `x=-100` means 100% (width). +* `scale`: The scale of the image, with `{x = 1, y = 1}` being the original texture size. + The `x` and `y` fields apply to the respective axes. + Positive values scale the source image. + Negative values represent percentages relative to screen dimensions. + Example: `{x = -20, y = 3}` means the image will be drawn 20% of screen width wide, + and 3 times as high as the source image is. * `text`: The name of the texture that is displayed. * `alignment`: The alignment of the image. * `world_pos`: World position of the waypoint. diff --git a/games/devtest/mods/testhud/init.lua b/games/devtest/mods/testhud/init.lua index da07f17e4..062976e14 100644 --- a/games/devtest/mods/testhud/init.lua +++ b/games/devtest/mods/testhud/init.lua @@ -152,7 +152,8 @@ minetest.register_chatcommand("hudwaypoints", { type = "image_waypoint", text = "testhud_waypoint.png", world_pos = player:get_pos(), - scale = {x = 3, y = 3}, + -- 20% of screen width, 3x image height + scale = {x = -20, y = 3}, offset = {x = 0, y = -32} } if not player_waypoints[name] then