aboutsummaryrefslogtreecommitdiff
path: root/games
diff options
context:
space:
mode:
authorLars Müller <34514239+appgurueu@users.noreply.github.com>2020-08-12 11:51:50 +0200
committerGitHub <noreply@github.com>2020-08-12 11:51:50 +0200
commit1c38027c3a72402d752a8150701a44753e22990e (patch)
tree90aae232237d8ee167cdd7e9ad5e103897b3269e /games
parentcd0e213a3640e980e15735f97dd874754f0dc679 (diff)
downloadminetest-1c38027c3a72402d752a8150701a44753e22990e.tar.gz
minetest-1c38027c3a72402d752a8150701a44753e22990e.tar.bz2
minetest-1c38027c3a72402d752a8150701a44753e22990e.zip
Fix precision not working in hud_change (#10186)
Diffstat (limited to 'games')
-rw-r--r--games/devtest/mods/util_commands/init.lua56
1 files changed, 56 insertions, 0 deletions
diff --git a/games/devtest/mods/util_commands/init.lua b/games/devtest/mods/util_commands/init.lua
index 3a0e91a41..f2a155fb2 100644
--- a/games/devtest/mods/util_commands/init.lua
+++ b/games/devtest/mods/util_commands/init.lua
@@ -112,6 +112,62 @@ minetest.register_chatcommand("detach", {
end,
})
+-- Use this to test waypoint capabilities
+minetest.register_chatcommand("test_waypoints", {
+ params = "[change_immediate]",
+ description = "tests waypoint capabilities",
+ func = function(name, params)
+ local player = minetest.get_player_by_name(name)
+ local regular = player:hud_add {
+ hud_elem_type = "waypoint",
+ name = "regular waypoint",
+ text = "m",
+ number = 0xFF0000,
+ world_pos = vector.add(player:get_pos(), {x = 0, y = 1.5, z = 0})
+ }
+ local reduced_precision = player:hud_add {
+ hud_elem_type = "waypoint",
+ name = "better waypoint",
+ text = "m (0.5 steps, precision = 2)",
+ precision = 10,
+ number = 0xFFFF00,
+ world_pos = vector.add(player:get_pos(), {x = 0, y = 1, z = 0})
+ }
+ local function change()
+ if regular then
+ player:hud_change(regular, "world_pos", vector.add(player:get_pos(), {x = 0, y = 3, z = 0}))
+ end
+ if reduced_precision then
+ player:hud_change(reduced_precision, "precision", 2)
+ end
+ end
+ if params ~= "" then
+ -- change immediate
+ change()
+ else
+ minetest.after(0.5, change)
+ end
+ regular = regular or "error"
+ reduced_precision = reduced_precision or "error"
+ local hidden_distance = player:hud_add {
+ hud_elem_type = "waypoint",
+ name = "waypoint with hidden distance",
+ text = "this text is hidden as well (precision = 0)",
+ precision = 0,
+ number = 0x0000FF,
+ world_pos = vector.add(player:get_pos(), {x = 0, y = 0.5, z = 0})
+ } or "error"
+ local image_waypoint = player:hud_add {
+ hud_elem_type = "image_waypoint",
+ text = "wieldhand.png",
+ world_pos = player:get_pos(),
+ scale = {x = 10, y = 10},
+ offset = {x = 0, y = -32}
+ } or "error"
+ minetest.chat_send_player(name, "Waypoint IDs: regular: " .. regular .. ", reduced precision: " .. reduced_precision ..
+ ", hidden distance: " .. hidden_distance .. ", image waypoint: " .. image_waypoint)
+ end
+})
-- Unlimited node placement
minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack)