summaryrefslogtreecommitdiff
path: root/games
diff options
context:
space:
mode:
authorVitaliy <numzer0@yandex.ru>2021-03-30 01:25:11 +0300
committerGitHub <noreply@github.com>2021-03-30 00:25:11 +0200
commit3b78a223717c69918a5af422e21561f47ec74ce1 (patch)
treeaafa2961a6faafc58a2712dfcc277e662d149382 /games
parentfde2785fe363c55e8acfd17af71375a231df41c1 (diff)
downloadminetest-3b78a223717c69918a5af422e21561f47ec74ce1.tar.gz
minetest-3b78a223717c69918a5af422e21561f47ec74ce1.tar.bz2
minetest-3b78a223717c69918a5af422e21561f47ec74ce1.zip
Degrotate support for mesh nodes (#7840)
Diffstat (limited to 'games')
-rw-r--r--games/devtest/mods/testnodes/drawtypes.lua56
1 files changed, 55 insertions, 1 deletions
diff --git a/games/devtest/mods/testnodes/drawtypes.lua b/games/devtest/mods/testnodes/drawtypes.lua
index ff970144d..02d71b50d 100644
--- a/games/devtest/mods/testnodes/drawtypes.lua
+++ b/games/devtest/mods/testnodes/drawtypes.lua
@@ -223,6 +223,30 @@ minetest.register_node("testnodes:plantlike_waving", {
-- param2 will rotate
+local function rotate_on_rightclick(pos, node, clicker)
+ local def = minetest.registered_nodes[node.name]
+ local aux1 = clicker:get_player_control().aux1
+
+ local deg, deg_max
+ local color, color_mult = 0, 0
+ if def.paramtype2 == "degrotate" then
+ deg = node.param2
+ deg_max = 240
+ elseif def.paramtype2 == "colordegrotate" then
+ -- MSB [3x color, 5x rotation] LSB
+ deg = node.param2 % 2^5
+ deg_max = 24
+ color_mult = 2^5
+ color = math.floor(node.param2 / color_mult)
+ end
+
+ deg = (deg + (aux1 and 10 or 1)) % deg_max
+ node.param2 = color * color_mult + deg
+ minetest.swap_node(pos, node)
+ minetest.chat_send_player(clicker:get_player_name(),
+ "Rotation is now " .. deg .. " / " .. deg_max)
+end
+
minetest.register_node("testnodes:plantlike_degrotate", {
description = S("Degrotate Plantlike Drawtype Test Node"),
drawtype = "plantlike",
@@ -230,12 +254,42 @@ minetest.register_node("testnodes:plantlike_degrotate", {
paramtype2 = "degrotate",
tiles = { "testnodes_plantlike_degrotate.png" },
-
+ on_rightclick = rotate_on_rightclick,
+ place_param2 = 7,
walkable = false,
sunlight_propagates = true,
groups = { dig_immediate = 3 },
})
+minetest.register_node("testnodes:mesh_degrotate", {
+ description = S("Degrotate Mesh Drawtype Test Node"),
+ drawtype = "mesh",
+ paramtype = "light",
+ paramtype2 = "degrotate",
+ mesh = "testnodes_pyramid.obj",
+ tiles = { "testnodes_mesh_stripes2.png" },
+
+ on_rightclick = rotate_on_rightclick,
+ place_param2 = 7,
+ sunlight_propagates = true,
+ groups = { dig_immediate = 3 },
+})
+
+minetest.register_node("testnodes:mesh_colordegrotate", {
+ description = S("Color Degrotate Mesh Drawtype Test Node"),
+ drawtype = "mesh",
+ paramtype2 = "colordegrotate",
+ palette = "testnodes_palette_facedir.png",
+ mesh = "testnodes_pyramid.obj",
+ tiles = { "testnodes_mesh_stripes2.png" },
+
+ on_rightclick = rotate_on_rightclick,
+ -- color index 1, 7 steps rotated
+ place_param2 = 1 * 2^5 + 7,
+ sunlight_propagates = true,
+ groups = { dig_immediate = 3 },
+})
+
-- param2 will change height
minetest.register_node("testnodes:plantlike_leveled", {
description = S("Leveled Plantlike Drawtype Test Node"),