]> git.lizzy.rs Git - minetest.git/blobdiff - games/devtest/mods/testnodes/drawtypes.lua
Degrotate support for mesh nodes (#7840)
[minetest.git] / games / devtest / mods / testnodes / drawtypes.lua
index b3ab2b322e6dfb89647111abe9fc7740a00e16d5..02d71b50dde05cd049e845fc13c4e18a40f86e12 100644 (file)
@@ -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"),
@@ -350,68 +404,72 @@ minetest.register_node("testnodes:plantlike_rooted_degrotate", {
 })
 
 -- Demonstrative liquid nodes, source and flowing form.
-minetest.register_node("testnodes:liquid", {
-       description = S("Source Liquid Drawtype Test Node"),
-       drawtype = "liquid",
-       paramtype = "light",
-       tiles = {
-               "testnodes_liquidsource.png",
-       },
-       special_tiles = {
-               {name="testnodes_liquidsource.png", backface_culling=false},
-               {name="testnodes_liquidsource.png", backface_culling=true},
-       },
-       use_texture_alpha = true,
-
-
-       walkable = false,
-       liquidtype = "source",
-       liquid_range = 1,
-       liquid_viscosity = 0,
-       liquid_alternative_flowing = "testnodes:liquid_flowing",
-       liquid_alternative_source = "testnodes:liquid",
-       groups = { dig_immediate = 3 },
-})
-minetest.register_node("testnodes:liquid_flowing", {
-       description = S("Flowing Liquid Drawtype Test Node"),
-       drawtype = "flowingliquid",
-       paramtype = "light",
-       paramtype2 = "flowingliquid",
-       tiles = {
-               "testnodes_liquidflowing.png",
-       },
-       special_tiles = {
-               {name="testnodes_liquidflowing.png", backface_culling=false},
-               {name="testnodes_liquidflowing.png", backface_culling=false},
-       },
-       use_texture_alpha = true,
+-- DRAWTYPE ONLY, NO LIQUID PHYSICS!
+-- Liquid ranges 0 to 8
+for r = 0, 8 do
+       minetest.register_node("testnodes:liquid_"..r, {
+               description = S("Source Liquid Drawtype Test Node, Range @1", r),
+               drawtype = "liquid",
+               paramtype = "light",
+               tiles = {
+                       "testnodes_liquidsource_r"..r..".png^[colorize:#FFFFFF:100",
+               },
+               special_tiles = {
+                       {name="testnodes_liquidsource_r"..r..".png^[colorize:#FFFFFF:100", backface_culling=false},
+                       {name="testnodes_liquidsource_r"..r..".png^[colorize:#FFFFFF:100", backface_culling=true},
+               },
+               use_texture_alpha = "blend",
+
+
+               walkable = false,
+               liquid_range = r,
+               liquid_viscosity = 0,
+               liquid_alternative_flowing = "testnodes:liquid_flowing_"..r,
+               liquid_alternative_source = "testnodes:liquid_"..r,
+               groups = { dig_immediate = 3 },
+       })
+       minetest.register_node("testnodes:liquid_flowing_"..r, {
+               description = S("Flowing Liquid Drawtype Test Node, Range @1", r),
+               drawtype = "flowingliquid",
+               paramtype = "light",
+               paramtype2 = "flowingliquid",
+               tiles = {
+                       "testnodes_liquidflowing_r"..r..".png^[colorize:#FFFFFF:100",
+               },
+               special_tiles = {
+                       {name="testnodes_liquidflowing_r"..r..".png^[colorize:#FFFFFF:100", backface_culling=false},
+                       {name="testnodes_liquidflowing_r"..r..".png^[colorize:#FFFFFF:100", backface_culling=false},
+               },
+               use_texture_alpha = "blend",
+
+
+               walkable = false,
+               liquid_range = r,
+               liquid_viscosity = 0,
+               liquid_alternative_flowing = "testnodes:liquid_flowing_"..r,
+               liquid_alternative_source = "testnodes:liquid_"..r,
+               groups = { dig_immediate = 3 },
+       })
 
+end
 
-       walkable = false,
-       liquidtype = "flowing",
-       liquid_range = 1,
-       liquid_viscosity = 0,
-       liquid_alternative_flowing = "testnodes:liquid_flowing",
-       liquid_alternative_source = "testnodes:liquid",
-       groups = { dig_immediate = 3 },
-})
+-- Waving liquid test (drawtype only)
 minetest.register_node("testnodes:liquid_waving", {
        description = S("Waving Source Liquid Drawtype Test Node"),
        drawtype = "liquid",
        paramtype = "light",
        tiles = {
-               "testnodes_liquidsource.png^[brighten",
+               "testnodes_liquidsource.png^[colorize:#0000FF:127",
        },
        special_tiles = {
-               {name="testnodes_liquidsource.png^[brighten", backface_culling=false},
-               {name="testnodes_liquidsource.png^[brighten", backface_culling=true},
+               {name="testnodes_liquidsource.png^[colorize:#0000FF:127", backface_culling=false},
+               {name="testnodes_liquidsource.png^[colorize:#0000FF:127", backface_culling=true},
        },
-       use_texture_alpha = true,
+       use_texture_alpha = "blend",
        waving = 3,
 
 
        walkable = false,
-       liquidtype = "source",
        liquid_range = 1,
        liquid_viscosity = 0,
        liquid_alternative_flowing = "testnodes:liquid_flowing_waving",
@@ -424,18 +482,17 @@ minetest.register_node("testnodes:liquid_flowing_waving", {
        paramtype = "light",
        paramtype2 = "flowingliquid",
        tiles = {
-               "testnodes_liquidflowing.png^[brighten",
+               "testnodes_liquidflowing.png^[colorize:#0000FF:127",
        },
        special_tiles = {
-               {name="testnodes_liquidflowing.png^[brighten", backface_culling=false},
-               {name="testnodes_liquidflowing.png^[brighten", backface_culling=false},
+               {name="testnodes_liquidflowing.png^[colorize:#0000FF:127", backface_culling=false},
+               {name="testnodes_liquidflowing.png^[colorize:#0000FF:127", backface_culling=false},
        },
-       use_texture_alpha = true,
+       use_texture_alpha = "blend",
        waving = 3,
 
 
        walkable = false,
-       liquidtype = "flowing",
        liquid_range = 1,
        liquid_viscosity = 0,
        liquid_alternative_flowing = "testnodes:liquid_flowing_waving",
@@ -443,8 +500,6 @@ minetest.register_node("testnodes:liquid_flowing_waving", {
        groups = { dig_immediate = 3 },
 })
 
-
-
 -- Invisible node
 minetest.register_node("testnodes:airlike", {
        description = S("Airlike Drawtype Test Node"),