From 1c38027c3a72402d752a8150701a44753e22990e Mon Sep 17 00:00:00 2001 From: Lars Müller <34514239+appgurueu@users.noreply.github.com> Date: Wed, 12 Aug 2020 11:51:50 +0200 Subject: Fix precision not working in hud_change (#10186) --- games/devtest/mods/util_commands/init.lua | 56 +++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'games/devtest/mods/util_commands') 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) -- cgit v1.2.3 From 4d9c9186ce61e11e13bc35ce1a319e568cf08662 Mon Sep 17 00:00:00 2001 From: Paramat Date: Tue, 20 Oct 2020 22:13:27 +0100 Subject: Devtest: Automatically enable zoom capability (#10493) Make minor improvements to the zoom testing chat command. Delete incorrect line about creative mode from README.md. --- games/devtest/README.md | 1 - games/devtest/mods/util_commands/init.lua | 10 ++++++---- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'games/devtest/mods/util_commands') diff --git a/games/devtest/README.md b/games/devtest/README.md index 8b71da625..77e722af7 100644 --- a/games/devtest/README.md +++ b/games/devtest/README.md @@ -23,7 +23,6 @@ Basically, just create a world and start. A few important things to note: * Use the `/infplace` command to toggle infinite node placement in-game * Use the Param2 Tool to change the param2 of nodes; it's useful to experiment with the various drawtype test nodes * Check out the game settings and server commands for additional tests and features -* Creative Mode does nothing (apart from default engine behavior) Confused by a certain node or item? Check out for inline code comments. The usages of most tools are explained in their tooltips. diff --git a/games/devtest/mods/util_commands/init.lua b/games/devtest/mods/util_commands/init.lua index f2a155fb2..ca5dca2d9 100644 --- a/games/devtest/mods/util_commands/init.lua +++ b/games/devtest/mods/util_commands/init.lua @@ -36,8 +36,12 @@ minetest.register_chatcommand("hp", { end, }) -minetest.register_chatcommand("zoom", { - params = "[]", +minetest.register_on_joinplayer(function(player) + player:set_properties({zoom_fov = 15}) +end) + +minetest.register_chatcommand("zoomfov", { + params = "[]", description = "Set or display your zoom_fov", func = function(name, param) local player = minetest.get_player_by_name(name) @@ -58,8 +62,6 @@ minetest.register_chatcommand("zoom", { end, }) - - local s_infplace = minetest.settings:get("devtest_infplace") if s_infplace == "true" then infplace = true -- cgit v1.2.3