local S = minetest.get_translator("testnodes")
--- If set to true, will show an inventory image for nodes that have no inventory image as of Minetest 5.1.0.
--- This is due to <https://github.com/minetest/minetest/issues/9209>.
--- This is only added to make the items more visible to avoid confusion, but you will no longer see
--- the default inventory images for these items. When you want to test the default inventory image of drawtypes,
--- this should be turned off.
--- TODO: Remove support for fallback inventory image as soon #9209 is fixed.
-local SHOW_FALLBACK_IMAGE = minetest.settings:get_bool("testnodes_show_fallback_image", false)
-
-local fallback_image = function(img)
- if SHOW_FALLBACK_IMAGE then
- return img
- else
- return nil
- end
-end
-
-- A regular cube
minetest.register_node("testnodes:normal", {
- description = S("Normal Drawtype Test Node"),
+ description = S("\"normal\" Drawtype Test Node").."\n"..
+ S("Opaque texture"),
drawtype = "normal",
tiles = { "testnodes_normal.png" },
-- Standard glasslike node
minetest.register_node("testnodes:glasslike", {
- description = S("Glasslike Drawtype Test Node"),
+ description = S("\"glasslike\" Drawtype Test Node").."\n"..
+ S("Transparent node with hidden backfaces"),
drawtype = "glasslike",
paramtype = "light",
tiles = { "testnodes_glasslike.png" },
-- Glasslike framed with the two textures (normal and "detail")
minetest.register_node("testnodes:glasslike_framed", {
- description = S("Glasslike Framed Drawtype Test Node"),
+ description = S("\"glasslike_framed\" Drawtype Test Node").."\n"..
+ S("Transparent node with hidden backfaces").."\n"..
+ S("Frame connects to neighbors"),
drawtype = "glasslike_framed",
paramtype = "light",
tiles = {
-- This node was added to see how the engine behaves when the "detail" texture
-- is missing.
minetest.register_node("testnodes:glasslike_framed_no_detail", {
- description = S("Glasslike Framed without Detail Drawtype Test Node"),
+ description = S("\"glasslike_framed\" Drawtype without Detail Test Node").."\n"..
+ S("Transparent node with hidden backfaces").."\n"..
+ S("Frame connects to neighbors, but the 'detail' tile is not used"),
drawtype = "glasslike_framed",
paramtype = "light",
tiles = { "testnodes_glasslike_framed2.png" },
minetest.register_node("testnodes:glasslike_framed_optional", {
- description = S("Glasslike Framed Optional Drawtype Test Node"),
+ description = S("\"glasslike_framed_optional\" Drawtype Test Node").."\n"..
+ S("Transparent node with hidden backfaces").."\n"..
+ S("Frame connects if 'connected_glass' setting is true"),
drawtype = "glasslike_framed_optional",
paramtype = "light",
tiles = {
minetest.register_node("testnodes:allfaces", {
- description = S("Allfaces Drawtype Test Node"),
+ description = S("\"allfaces\" Drawtype Test Node").."\n"..
+ S("Transparent node with visible internal backfaces"),
drawtype = "allfaces",
paramtype = "light",
tiles = { "testnodes_allfaces.png" },
groups = { dig_immediate = 3 },
})
+local allfaces_optional_tooltip = ""..
+ S("Rendering depends on 'leaves_style' setting:").."\n"..
+ S("* 'fancy': transparent with visible internal backfaces").."\n"..
+ S("* 'simple': transparent with hidden backfaces").."\n"..
+ S("* 'opaque': opaque")
+
minetest.register_node("testnodes:allfaces_optional", {
- description = S("Allfaces Optional Drawtype Test Node"),
+ description = S("\"allfaces_optional\" Drawtype Test Node").."\n"..
+ allfaces_optional_tooltip,
drawtype = "allfaces_optional",
paramtype = "light",
tiles = { "testnodes_allfaces_optional.png" },
})
minetest.register_node("testnodes:allfaces_optional_waving", {
- description = S("Waving Allfaces Optional Drawtype Test Node"),
+ description = S("Waving \"allfaces_optional\" Drawtype Test Node").."\n"..
+ allfaces_optional_tooltip.."\n"..
+ S("Waves if waving leaves are enabled by client"),
drawtype = "allfaces_optional",
paramtype = "light",
tiles = { "testnodes_allfaces_optional.png^[brighten" },
})
minetest.register_node("testnodes:firelike", {
- description = S("Firelike Drawtype Test Node"),
+ description = S("\"firelike\" Drawtype Test Node").."\n"..
+ S("Changes shape based on neighbors"),
drawtype = "firelike",
paramtype = "light",
tiles = { "testnodes_firelike.png" },
})
minetest.register_node("testnodes:fencelike", {
- description = S("Fencelike Drawtype Test Node"),
+ description = S("\"fencelike\" Drawtype Test Node").."\n"..
+ S("Connects to neighbors"),
drawtype = "fencelike",
paramtype = "light",
tiles = { "testnodes_fencelike.png" },
})
minetest.register_node("testnodes:torchlike", {
- description = S("Torchlike Drawtype Test Node"),
+ description = S("Floor \"torchlike\" Drawtype Test Node").."\n"..
+ S("Always on floor"),
drawtype = "torchlike",
paramtype = "light",
- tiles = {
- "testnodes_torchlike_floor.png",
- "testnodes_torchlike_ceiling.png",
- "testnodes_torchlike_wall.png",
- },
+ tiles = { "testnodes_torchlike_floor.png^[colorize:#FF0000:64" },
walkable = false,
sunlight_propagates = true,
groups = { dig_immediate = 3 },
- inventory_image = fallback_image("testnodes_torchlike_floor.png"),
})
minetest.register_node("testnodes:torchlike_wallmounted", {
- description = S("Wallmounted Torchlike Drawtype Test Node"),
+ description = S("Wallmounted \"torchlike\" Drawtype Test Node").."\n"..
+ S("param2 = wallmounted rotation (0..5)"),
drawtype = "torchlike",
paramtype = "light",
paramtype2 = "wallmounted",
walkable = false,
sunlight_propagates = true,
groups = { dig_immediate = 3 },
- inventory_image = fallback_image("testnodes_torchlike_floor.png"),
})
+minetest.register_node("testnodes:signlike", {
+ description = S("Floor \"signlike\" Drawtype Test Node").."\n"..
+ S("Always on floor"),
+ drawtype = "signlike",
+ paramtype = "light",
+ tiles = { "testnodes_signlike.png^[colorize:#FF0000:64" },
-minetest.register_node("testnodes:signlike", {
- description = S("Wallmounted Signlike Drawtype Test Node"),
+ walkable = false,
+ groups = { dig_immediate = 3 },
+ sunlight_propagates = true,
+})
+
+
+minetest.register_node("testnodes:signlike_wallmounted", {
+ description = S("Wallmounted \"signlike\" Drawtype Test Node").."\n"..
+ S("param2 = wallmounted rotation (0..5)"),
drawtype = "signlike",
paramtype = "light",
paramtype2 = "wallmounted",
walkable = false,
groups = { dig_immediate = 3 },
sunlight_propagates = true,
- inventory_image = fallback_image("testnodes_signlike.png"),
})
minetest.register_node("testnodes:plantlike", {
- description = S("Plantlike Drawtype Test Node"),
+ description = S("\"plantlike\" Drawtype Test Node"),
drawtype = "plantlike",
paramtype = "light",
tiles = { "testnodes_plantlike.png" },
})
minetest.register_node("testnodes:plantlike_waving", {
- description = S("Waving Plantlike Drawtype Test Node"),
+ description = S("Waving \"plantlike\" Drawtype Test Node").."\n"..
+ S("Waves if waving plants are enabled by client"),
drawtype = "plantlike",
paramtype = "light",
tiles = { "testnodes_plantlike_waving.png" },
groups = { dig_immediate = 3 },
})
+minetest.register_node("testnodes:plantlike_wallmounted", {
+ description = S("Wallmounted \"plantlike\" Drawtype Test Node").."\n"..
+ S("param2 = wallmounted rotation (0..5)"),
+ drawtype = "plantlike",
+ paramtype = "light",
+ paramtype2 = "wallmounted",
+ tiles = { "testnodes_plantlike_wallmounted.png" },
+ leveled = 1,
+
+
+ walkable = false,
+ sunlight_propagates = true,
+ groups = { dig_immediate = 3 },
+})
-- 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"),
+ description = S("Degrotate \"plantlike\" Drawtype Test Node").."\n"..
+ S("param2 = horizontal rotation (0..239)"),
drawtype = "plantlike",
paramtype = "light",
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").."\n"..
+ S("param2 = horizontal rotation (0..239)"),
+ drawtype = "mesh",
+ paramtype = "light",
+ paramtype2 = "degrotate",
+ mesh = "testnodes_ocorner.obj",
+ tiles = { "testnodes_mesh_stripes2.png" },
+
+ on_rightclick = rotate_on_rightclick,
+ place_param2 = 10, -- 15°
+ sunlight_propagates = true,
+ groups = { dig_immediate = 3 },
+})
+
+minetest.register_node("testnodes:mesh_colordegrotate", {
+ description = S("Colordegrotate \"mesh\" Drawtype Test Node").."\n"..
+ S("param2 = color + horizontal rotation (0..23, 32..55, ...)"),
+ drawtype = "mesh",
+ paramtype = "light",
+ paramtype2 = "colordegrotate",
+ palette = "testnodes_palette_facedir.png",
+ mesh = "testnodes_ocorner.obj",
+ tiles = { "testnodes_mesh_stripes3.png" },
+
+ on_rightclick = rotate_on_rightclick,
+ -- color index 1, 1 step (=15°) rotated
+ place_param2 = 1 * 2^5 + 1,
+ sunlight_propagates = true,
+ groups = { dig_immediate = 3 },
+})
+
-- param2 will change height
minetest.register_node("testnodes:plantlike_leveled", {
- description = S("Leveled Plantlike Drawtype Test Node"),
+ description = S("Leveled \"plantlike\" Drawtype Test Node").."\n"..
+ S("param2 = height (0..255)"),
drawtype = "plantlike",
paramtype = "light",
paramtype2 = "leveled",
-- param2 changes shape
minetest.register_node("testnodes:plantlike_meshoptions", {
- description = S("Meshoptions Plantlike Drawtype Test Node"),
+ description = S("Meshoptions \"plantlike\" Drawtype Test Node").."\n"..
+ S("param2 = plant shape"),
drawtype = "plantlike",
paramtype = "light",
paramtype2 = "meshoptions",
})
minetest.register_node("testnodes:plantlike_rooted", {
- description = S("Rooted Plantlike Drawtype Test Node"),
+ description = S("\"rooted_plantlike\" Drawtype Test Node"),
drawtype = "plantlike_rooted",
paramtype = "light",
tiles = { "testnodes_plantlike_rooted_base.png" },
groups = { dig_immediate = 3 },
})
+minetest.register_node("testnodes:plantlike_rooted_wallmounted", {
+ description = S("Wallmounted \"rooted_plantlike\" Drawtype Test Node").."\n"..
+ S("param2 = wallmounted rotation (0..5)"),
+ drawtype = "plantlike_rooted",
+ paramtype = "light",
+ paramtype2 = "wallmounted",
+ tiles = {
+ "testnodes_plantlike_rooted_base.png",
+ "testnodes_plantlike_rooted_base.png",
+ "testnodes_plantlike_rooted_base_side_wallmounted.png" },
+ special_tiles = { "testnodes_plantlike_rooted_wallmounted.png" },
+
+ groups = { dig_immediate = 3 },
+})
+
minetest.register_node("testnodes:plantlike_rooted_waving", {
- description = S("Waving Rooted Plantlike Drawtype Test Node"),
+ description = S("Waving \"rooted_plantlike\" Drawtype Test Node").."\n"..
+ S("Waves if waving plants are enabled by client"),
drawtype = "plantlike_rooted",
paramtype = "light",
tiles = {
-- param2 changes height
minetest.register_node("testnodes:plantlike_rooted_leveled", {
- description = S("Leveled Rooted Plantlike Drawtype Test Node"),
+ description = S("Leveled \"rooted_plantlike\" Drawtype Test Node").."\n"..
+ S("param2 = height (0..255)"),
drawtype = "plantlike_rooted",
paramtype = "light",
paramtype2 = "leveled",
-- param2 changes shape
minetest.register_node("testnodes:plantlike_rooted_meshoptions", {
- description = S("Meshoptions Rooted Plantlike Drawtype Test Node"),
+ description = S("Meshoptions \"rooted_plantlike\" Drawtype Test Node").."\n"..
+ S("param2 = plant shape"),
drawtype = "plantlike_rooted",
paramtype = "light",
paramtype2 = "meshoptions",
-- param2 changes rotation
minetest.register_node("testnodes:plantlike_rooted_degrotate", {
- description = S("Degrotate Rooted Plantlike Drawtype Test Node"),
+ description = S("Degrotate \"rooted_plantlike\" Drawtype Test Node").."\n"..
+ S("param2 = horizontal rotation (0..239)"),
drawtype = "plantlike_rooted",
paramtype = "light",
paramtype2 = "degrotate",
-- 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),
+ description = S("\"liquid\" Drawtype Test Node, Range @1", r).."\n"..
+ S("Drawtype only; all liquid physics are disabled"),
drawtype = "liquid",
paramtype = "light",
tiles = {
groups = { dig_immediate = 3 },
})
minetest.register_node("testnodes:liquid_flowing_"..r, {
- description = S("Flowing Liquid Drawtype Test Node, Range @1", r),
+ description = S("\"flowingliquid\" Drawtype Test Node, Range @1", r).."\n"..
+ S("Drawtype only; all liquid physics are disabled").."\n"..
+ S("param2 = flowing liquid level"),
drawtype = "flowingliquid",
paramtype = "light",
paramtype2 = "flowingliquid",
-- Waving liquid test (drawtype only)
minetest.register_node("testnodes:liquid_waving", {
- description = S("Waving Source Liquid Drawtype Test Node"),
+ description = S("Waving \"liquid\" Drawtype Test Node").."\n"..
+ S("Drawtype only; all liquid physics are disabled").."\n"..
+ S("Waves if waving liquids are enabled by client"),
drawtype = "liquid",
paramtype = "light",
tiles = {
groups = { dig_immediate = 3 },
})
minetest.register_node("testnodes:liquid_flowing_waving", {
- description = S("Waving Flowing Liquid Drawtype Test Node"),
+ description = S("Waving \"flowingliquid\" Drawtype Test Node").."\n"..
+ S("Drawtype only; all liquid physics are disabled").."\n"..
+ S("param2 = flowing liquid level").."\n"..
+ S("Waves if waving liquids are enabled by client"),
drawtype = "flowingliquid",
paramtype = "light",
paramtype2 = "flowingliquid",
-- Invisible node
minetest.register_node("testnodes:airlike", {
- description = S("Airlike Drawtype Test Node"),
+ description = S("\"airlike\" Drawtype Test Node").."\n"..
+ S("Invisible node").."\n"..
+ S("Inventory/wield image = no_texture_airlike.png"),
drawtype = "airlike",
paramtype = "light",
+ -- inventory/wield images are left empty to make sure the 'no texture'
+ -- fallback for airlike nodes is working properly.
walkable = false,
groups = { dig_immediate = 3 },
sunlight_propagates = true,
- inventory_image = fallback_image("testnodes_airlike.png"),
})
-- param2 changes liquid height
minetest.register_node("testnodes:glassliquid", {
- description = S("Glasslike Liquid Level Drawtype Test Node"),
+ description = S("\"glasslike_framed\" Drawtype with Liquid Test Node").."\n"..
+ S("param2 = liquid level (0..63)"),
drawtype = "glasslike_framed",
paramtype = "light",
paramtype2 = "glasslikeliquidlevel",
-- should connect to nodes of the same "rail type" (=same shape, different
-- color) only.
local rails = {
- { "rail", {"testnodes_rail_straight.png", "testnodes_rail_curved.png", "testnodes_rail_t_junction.png", "testnodes_rail_crossing.png"} },
- { "line", {"testnodes_line_straight.png", "testnodes_line_curved.png", "testnodes_line_t_junction.png", "testnodes_line_crossing.png"}, },
- { "street", {"testnodes_street_straight.png", "testnodes_street_curved.png", "testnodes_street_t_junction.png", "testnodes_street_crossing.png"}, },
+ { "rail", {"testnodes_rail_straight.png", "testnodes_rail_curved.png", "testnodes_rail_t_junction.png", "testnodes_rail_crossing.png"}, S("Connects to rails")},
+ { "line", {"testnodes_line_straight.png", "testnodes_line_curved.png", "testnodes_line_t_junction.png", "testnodes_line_crossing.png"}, S("Connects to lines")},
+ { "street", {"testnodes_street_straight.png", "testnodes_street_curved.png", "testnodes_street_t_junction.png", "testnodes_street_crossing.png"}, S("Connects to streets")},
-- the "groupless" nodes are nodes in which the "connect_to_raillike" group is not set
- { "groupless", {"testnodes_rail2_straight.png", "testnodes_rail2_curved.png", "testnodes_rail2_t_junction.png", "testnodes_rail2_crossing.png"} },
+ { "groupless", {"testnodes_rail2_straight.png", "testnodes_rail2_curved.png", "testnodes_rail2_t_junction.png", "testnodes_rail2_crossing.png"}, S("Connects to 'groupless' rails") },
}
local colors = { "", "cyan", "red" }
for r=1, #rails do
local id = rails[r][1]
local tiles = rails[r][2]
+ local tt = rails[r][3]
local raillike_group
if id ~= "groupless" then
raillike_group = minetest.raillike_group(id)
color = colors[c]
end
minetest.register_node("testnodes:raillike_"..id..c, {
- description = S("Raillike Drawtype Test Node: @1 @2", id, c),
+ description = S("\"raillike\" Drawtype Test Node: @1 @2", id, c).."\n"..
+ tt,
drawtype = "raillike",
paramtype = "light",
tiles = tiles,
-- Add visual_scale variants of previous nodes for half and double size
-local scale = function(subname, desc_double, desc_half)
+local scale = function(subname, append)
local original = "testnodes:"..subname
local def = table.copy(minetest.registered_items[original])
+ local orig_desc
+ if append and type(append) == "string" then
+ orig_desc = ItemStack(original):get_short_description()
+ orig_desc = orig_desc .. "\n" .. append
+ elseif append ~= false then
+ orig_desc = ItemStack(original):get_description()
+ else
+ orig_desc = ItemStack(original):get_short_description()
+ end
def.visual_scale = 2.0
- def.description = desc_double
+ def.description = S("Double-sized @1", orig_desc)
minetest.register_node("testnodes:"..subname.."_double", def)
def = table.copy(minetest.registered_items[original])
def.visual_scale = 0.5
- def.description = desc_half
+ def.description = S("Half-sized @1", orig_desc)
minetest.register_node("testnodes:"..subname.."_half", def)
end
-scale("allfaces",
- S("Double-sized Allfaces Drawtype Test Node"),
- S("Half-sized Allfaces Drawtype Test Node"))
-scale("allfaces_optional",
- S("Double-sized Allfaces Optional Drawtype Test Node"),
- S("Half-sized Allfaces Optional Drawtype Test Node"))
-scale("allfaces_optional_waving",
- S("Double-sized Waving Allfaces Optional Drawtype Test Node"),
- S("Half-sized Waving Allfaces Optional Drawtype Test Node"))
-scale("plantlike",
- S("Double-sized Plantlike Drawtype Test Node"),
- S("Half-sized Plantlike Drawtype Test Node"))
-scale("torchlike_wallmounted",
- S("Double-sized Wallmounted Torchlike Drawtype Test Node"),
- S("Half-sized Wallmounted Torchlike Drawtype Test Node"))
-scale("signlike",
- S("Double-sized Wallmounted Signlike Drawtype Test Node"),
- S("Half-sized Wallmounted Signlike Drawtype Test Node"))
-scale("firelike",
- S("Double-sized Firelike Drawtype Test Node"),
- S("Half-sized Firelike Drawtype Test Node"))
+local allfaces_newsize_tt = ""..
+ S("Rendering depends on 'leaves_style' setting:").."\n"..
+ S("* 'fancy'/'simple': transparent").."\n"..
+ S("* 'opaque': opaque")
+
+scale("allfaces", S("Transparent node"))
+scale("allfaces_optional", allfaces_newsize_tt)
+scale("allfaces_optional_waving", allfaces_newsize_tt .. "\n" .. S("Waving if waving leaves are enabled by client"))
+scale("plantlike")
+scale("plantlike_wallmounted")
+scale("torchlike_wallmounted")
+scale("signlike_wallmounted")
+scale("firelike")