1 --[[ Drawtype Test: This file tests out and provides examples for
2 all drawtypes in Minetest. It is attempted to keep the node
3 definitions as simple and minimal as possible to keep
4 side-effects to a minimum.
6 How to read the node definitions:
7 There are two parts which are separated by 2 newlines:
8 The first part contains the things that are more or less essential
9 for defining the drawtype (except description, which is
10 at the top for readability).
11 The second part (after the 2 newlines) contains stuff that are
12 unrelated to the drawtype, stuff that is mostly there to make
13 testing this node easier and more convenient.
16 local S = minetest.get_translator("testnodes")
19 minetest.register_node("testnodes:normal", {
20 description = S("Normal Drawtype Test Node"),
22 tiles = { "testnodes_normal.png" },
24 groups = { dig_immediate = 3 },
27 -- Standard glasslike node
28 minetest.register_node("testnodes:glasslike", {
29 description = S("Glasslike Drawtype Test Node"),
30 drawtype = "glasslike",
32 tiles = { "testnodes_glasslike.png" },
34 groups = { dig_immediate = 3 },
37 -- Glasslike framed with the two textures (normal and "detail")
38 minetest.register_node("testnodes:glasslike_framed", {
39 description = S("Glasslike Framed Drawtype Test Node"),
40 drawtype = "glasslike_framed",
43 "testnodes_glasslike_framed.png",
44 "testnodes_glasslike_detail.png",
48 sunlight_propagates = true,
49 groups = { dig_immediate = 3 },
52 -- Like the one above, but without the "detail" texture (texture 2).
53 -- This node was added to see how the engine behaves when the "detail" texture
55 minetest.register_node("testnodes:glasslike_framed_no_detail", {
56 description = S("Glasslike Framed without Detail Drawtype Test Node"),
57 drawtype = "glasslike_framed",
59 tiles = { "testnodes_glasslike_framed2.png" },
62 sunlight_propagates = true,
63 groups = { dig_immediate = 3 },
67 minetest.register_node("testnodes:glasslike_framed_optional", {
68 description = S("Glasslike Framed Optional Drawtype Test Node"),
69 drawtype = "glasslike_framed_optional",
72 "testnodes_glasslike_framed_optional.png",
73 "testnodes_glasslike_detail.png",
77 sunlight_propagates = true,
78 groups = { dig_immediate = 3 },
83 minetest.register_node("testnodes:allfaces", {
84 description = S("Allfaces Drawtype Test Node"),
85 drawtype = "allfaces",
87 tiles = { "testnodes_allfaces.png" },
89 groups = { dig_immediate = 3 },
92 minetest.register_node("testnodes:allfaces_optional", {
93 description = S("Allfaces Optional Drawtype Test Node"),
94 drawtype = "allfaces_optional",
96 tiles = { "testnodes_allfaces_optional.png" },
98 groups = { dig_immediate = 3 },
101 minetest.register_node("testnodes:allfaces_optional_waving", {
102 description = S("Waving Allfaces Optional Drawtype Test Node"),
103 drawtype = "allfaces_optional",
105 tiles = { "testnodes_allfaces_optional.png^[brighten" },
108 groups = { dig_immediate = 3 },
111 minetest.register_node("testnodes:firelike", {
112 description = S("Firelike Drawtype Test Node"),
113 drawtype = "firelike",
115 tiles = { "testnodes_firelike.png" },
119 groups = { dig_immediate = 3 },
122 minetest.register_node("testnodes:fencelike", {
123 description = S("Fencelike Drawtype Test Node"),
124 drawtype = "fencelike",
126 tiles = { "testnodes_fencelike.png" },
128 groups = { dig_immediate = 3 },
131 minetest.register_node("testnodes:torchlike", {
132 description = S("Floor Torchlike Drawtype Test Node"),
133 drawtype = "torchlike",
135 tiles = { "testnodes_torchlike_floor.png^[colorize:#FF0000:64" },
139 sunlight_propagates = true,
140 groups = { dig_immediate = 3 },
143 minetest.register_node("testnodes:torchlike_wallmounted", {
144 description = S("Wallmounted Torchlike Drawtype Test Node"),
145 drawtype = "torchlike",
147 paramtype2 = "wallmounted",
149 "testnodes_torchlike_floor.png",
150 "testnodes_torchlike_ceiling.png",
151 "testnodes_torchlike_wall.png",
156 sunlight_propagates = true,
157 groups = { dig_immediate = 3 },
160 minetest.register_node("testnodes:signlike", {
161 description = S("Floor Signlike Drawtype Test Node"),
162 drawtype = "signlike",
164 tiles = { "testnodes_signlike.png^[colorize:#FF0000:64" },
168 groups = { dig_immediate = 3 },
169 sunlight_propagates = true,
173 minetest.register_node("testnodes:signlike_wallmounted", {
174 description = S("Wallmounted Signlike Drawtype Test Node"),
175 drawtype = "signlike",
177 paramtype2 = "wallmounted",
178 tiles = { "testnodes_signlike.png" },
182 groups = { dig_immediate = 3 },
183 sunlight_propagates = true,
186 minetest.register_node("testnodes:plantlike", {
187 description = S("Plantlike Drawtype Test Node"),
188 drawtype = "plantlike",
190 tiles = { "testnodes_plantlike.png" },
194 sunlight_propagates = true,
195 groups = { dig_immediate = 3 },
198 minetest.register_node("testnodes:plantlike_waving", {
199 description = S("Waving Plantlike Drawtype Test Node"),
200 drawtype = "plantlike",
202 tiles = { "testnodes_plantlike_waving.png" },
207 sunlight_propagates = true,
208 groups = { dig_immediate = 3 },
213 -- param2 will rotate
214 local function rotate_on_rightclick(pos, node, clicker)
215 local def = minetest.registered_nodes[node.name]
216 local aux1 = clicker:get_player_control().aux1
219 local color, color_mult = 0, 0
220 if def.paramtype2 == "degrotate" then
223 elseif def.paramtype2 == "colordegrotate" then
224 -- MSB [3x color, 5x rotation] LSB
225 deg = node.param2 % 2^5
228 color = math.floor(node.param2 / color_mult)
231 deg = (deg + (aux1 and 10 or 1)) % deg_max
232 node.param2 = color * color_mult + deg
233 minetest.swap_node(pos, node)
234 minetest.chat_send_player(clicker:get_player_name(),
235 "Rotation is now " .. deg .. " / " .. deg_max)
238 minetest.register_node("testnodes:plantlike_degrotate", {
239 description = S("Degrotate Plantlike Drawtype Test Node"),
240 drawtype = "plantlike",
242 paramtype2 = "degrotate",
243 tiles = { "testnodes_plantlike_degrotate.png" },
245 on_rightclick = rotate_on_rightclick,
248 sunlight_propagates = true,
249 groups = { dig_immediate = 3 },
252 minetest.register_node("testnodes:mesh_degrotate", {
253 description = S("Degrotate Mesh Drawtype Test Node"),
256 paramtype2 = "degrotate",
257 mesh = "testnodes_pyramid.obj",
258 tiles = { "testnodes_mesh_stripes2.png" },
260 on_rightclick = rotate_on_rightclick,
262 sunlight_propagates = true,
263 groups = { dig_immediate = 3 },
266 minetest.register_node("testnodes:mesh_colordegrotate", {
267 description = S("Color Degrotate Mesh Drawtype Test Node"),
269 paramtype2 = "colordegrotate",
270 palette = "testnodes_palette_facedir.png",
271 mesh = "testnodes_pyramid.obj",
272 tiles = { "testnodes_mesh_stripes2.png" },
274 on_rightclick = rotate_on_rightclick,
275 -- color index 1, 7 steps rotated
276 place_param2 = 1 * 2^5 + 7,
277 sunlight_propagates = true,
278 groups = { dig_immediate = 3 },
281 -- param2 will change height
282 minetest.register_node("testnodes:plantlike_leveled", {
283 description = S("Leveled Plantlike Drawtype Test Node"),
284 drawtype = "plantlike",
286 paramtype2 = "leveled",
288 { name = "testnodes_plantlike_leveled.png", tileable_vertical = true },
292 -- We set a default param2 here only for convenience, to make the "plant" visible after placement
295 sunlight_propagates = true,
296 groups = { dig_immediate = 3 },
299 -- param2 changes shape
300 minetest.register_node("testnodes:plantlike_meshoptions", {
301 description = S("Meshoptions Plantlike Drawtype Test Node"),
302 drawtype = "plantlike",
304 paramtype2 = "meshoptions",
305 tiles = { "testnodes_plantlike_meshoptions.png" },
309 groups = { dig_immediate = 3 },
312 minetest.register_node("testnodes:plantlike_rooted", {
313 description = S("Rooted Plantlike Drawtype Test Node"),
314 drawtype = "plantlike_rooted",
316 tiles = { "testnodes_plantlike_rooted_base.png" },
317 special_tiles = { "testnodes_plantlike_rooted.png" },
319 groups = { dig_immediate = 3 },
322 minetest.register_node("testnodes:plantlike_rooted_waving", {
323 description = S("Waving Rooted Plantlike Drawtype Test Node"),
324 drawtype = "plantlike_rooted",
327 "testnodes_plantlike_rooted_base.png",
328 "testnodes_plantlike_rooted_base.png",
329 "testnodes_plantlike_rooted_base_side_waving.png",
331 special_tiles = { "testnodes_plantlike_rooted_waving.png" },
334 groups = { dig_immediate = 3 },
337 -- param2 changes height
338 minetest.register_node("testnodes:plantlike_rooted_leveled", {
339 description = S("Leveled Rooted Plantlike Drawtype Test Node"),
340 drawtype = "plantlike_rooted",
342 paramtype2 = "leveled",
344 "testnodes_plantlike_rooted_base.png",
345 "testnodes_plantlike_rooted_base.png",
346 "testnodes_plantlike_rooted_base_side_leveled.png",
349 { name = "testnodes_plantlike_rooted_leveled.png", tileable_vertical = true },
353 -- We set a default param2 here only for convenience, to make the "plant" visible after placement
355 groups = { dig_immediate = 3 },
358 -- param2 changes shape
359 minetest.register_node("testnodes:plantlike_rooted_meshoptions", {
360 description = S("Meshoptions Rooted Plantlike Drawtype Test Node"),
361 drawtype = "plantlike_rooted",
363 paramtype2 = "meshoptions",
365 "testnodes_plantlike_rooted_base.png",
366 "testnodes_plantlike_rooted_base.png",
367 "testnodes_plantlike_rooted_base_side_meshoptions.png",
370 "testnodes_plantlike_rooted_meshoptions.png",
373 groups = { dig_immediate = 3 },
376 -- param2 changes rotation
377 minetest.register_node("testnodes:plantlike_rooted_degrotate", {
378 description = S("Degrotate Rooted Plantlike Drawtype Test Node"),
379 drawtype = "plantlike_rooted",
381 paramtype2 = "degrotate",
383 "testnodes_plantlike_rooted_base.png",
384 "testnodes_plantlike_rooted_base.png",
385 "testnodes_plantlike_rooted_base_side_degrotate.png",
388 "testnodes_plantlike_rooted_degrotate.png",
391 groups = { dig_immediate = 3 },
394 -- Demonstrative liquid nodes, source and flowing form.
395 -- DRAWTYPE ONLY, NO LIQUID PHYSICS!
396 -- Liquid ranges 0 to 8
398 minetest.register_node("testnodes:liquid_"..r, {
399 description = S("Source Liquid Drawtype Test Node, Range @1", r),
403 "testnodes_liquidsource_r"..r..".png^[colorize:#FFFFFF:100",
406 {name="testnodes_liquidsource_r"..r..".png^[colorize:#FFFFFF:100", backface_culling=false},
407 {name="testnodes_liquidsource_r"..r..".png^[colorize:#FFFFFF:100", backface_culling=true},
409 use_texture_alpha = "blend",
414 liquid_viscosity = 0,
415 liquid_alternative_flowing = "testnodes:liquid_flowing_"..r,
416 liquid_alternative_source = "testnodes:liquid_"..r,
417 groups = { dig_immediate = 3 },
419 minetest.register_node("testnodes:liquid_flowing_"..r, {
420 description = S("Flowing Liquid Drawtype Test Node, Range @1", r),
421 drawtype = "flowingliquid",
423 paramtype2 = "flowingliquid",
425 "testnodes_liquidflowing_r"..r..".png^[colorize:#FFFFFF:100",
428 {name="testnodes_liquidflowing_r"..r..".png^[colorize:#FFFFFF:100", backface_culling=false},
429 {name="testnodes_liquidflowing_r"..r..".png^[colorize:#FFFFFF:100", backface_culling=false},
431 use_texture_alpha = "blend",
436 liquid_viscosity = 0,
437 liquid_alternative_flowing = "testnodes:liquid_flowing_"..r,
438 liquid_alternative_source = "testnodes:liquid_"..r,
439 groups = { dig_immediate = 3 },
444 -- Waving liquid test (drawtype only)
445 minetest.register_node("testnodes:liquid_waving", {
446 description = S("Waving Source Liquid Drawtype Test Node"),
450 "testnodes_liquidsource.png^[colorize:#0000FF:127",
453 {name="testnodes_liquidsource.png^[colorize:#0000FF:127", backface_culling=false},
454 {name="testnodes_liquidsource.png^[colorize:#0000FF:127", backface_culling=true},
456 use_texture_alpha = "blend",
462 liquid_viscosity = 0,
463 liquid_alternative_flowing = "testnodes:liquid_flowing_waving",
464 liquid_alternative_source = "testnodes:liquid_waving",
465 groups = { dig_immediate = 3 },
467 minetest.register_node("testnodes:liquid_flowing_waving", {
468 description = S("Waving Flowing Liquid Drawtype Test Node"),
469 drawtype = "flowingliquid",
471 paramtype2 = "flowingliquid",
473 "testnodes_liquidflowing.png^[colorize:#0000FF:127",
476 {name="testnodes_liquidflowing.png^[colorize:#0000FF:127", backface_culling=false},
477 {name="testnodes_liquidflowing.png^[colorize:#0000FF:127", backface_culling=false},
479 use_texture_alpha = "blend",
485 liquid_viscosity = 0,
486 liquid_alternative_flowing = "testnodes:liquid_flowing_waving",
487 liquid_alternative_source = "testnodes:liquid_waving",
488 groups = { dig_immediate = 3 },
492 minetest.register_node("testnodes:airlike", {
493 description = S("Airlike Drawtype Test Node"),
494 drawtype = "airlike",
499 groups = { dig_immediate = 3 },
500 sunlight_propagates = true,
503 -- param2 changes liquid height
504 minetest.register_node("testnodes:glassliquid", {
505 description = S("Glasslike Liquid Level Drawtype Test Node"),
506 drawtype = "glasslike_framed",
508 paramtype2 = "glasslikeliquidlevel",
510 "testnodes_glasslikeliquid.png",
513 "testnodes_liquid.png",
516 groups = { dig_immediate = 3 },
519 -- Adding many raillike examples, primarily to demonstrate the behavior of
520 -- "raillike groups". Nodes of the same type (rail, groupless, line, street)
521 -- should connect to nodes of the same "rail type" (=same shape, different
524 { "rail", {"testnodes_rail_straight.png", "testnodes_rail_curved.png", "testnodes_rail_t_junction.png", "testnodes_rail_crossing.png"} },
525 { "line", {"testnodes_line_straight.png", "testnodes_line_curved.png", "testnodes_line_t_junction.png", "testnodes_line_crossing.png"}, },
526 { "street", {"testnodes_street_straight.png", "testnodes_street_curved.png", "testnodes_street_t_junction.png", "testnodes_street_crossing.png"}, },
527 -- the "groupless" nodes are nodes in which the "connect_to_raillike" group is not set
528 { "groupless", {"testnodes_rail2_straight.png", "testnodes_rail2_curved.png", "testnodes_rail2_t_junction.png", "testnodes_rail2_crossing.png"} },
530 local colors = { "", "cyan", "red" }
533 local id = rails[r][1]
534 local tiles = rails[r][2]
536 if id ~= "groupless" then
537 raillike_group = minetest.raillike_group(id)
541 if colors[c] ~= "" then
544 minetest.register_node("testnodes:raillike_"..id..c, {
545 description = S("Raillike Drawtype Test Node: @1 @2", id, c),
546 drawtype = "raillike",
549 groups = { connect_to_raillike = raillike_group, dig_immediate = 3 },
555 fixed = {{-0.5, -0.5, -0.5, 0.5, -0.4, 0.5}},
557 sunlight_propagates = true,
565 -- Add visual_scale variants of previous nodes for half and double size
566 local scale = function(subname, desc_double, desc_half)
567 local original = "testnodes:"..subname
568 local def = table.copy(minetest.registered_items[original])
569 def.visual_scale = 2.0
570 def.description = desc_double
571 minetest.register_node("testnodes:"..subname.."_double", def)
572 def = table.copy(minetest.registered_items[original])
573 def.visual_scale = 0.5
574 def.description = desc_half
575 minetest.register_node("testnodes:"..subname.."_half", def)
579 S("Double-sized Allfaces Drawtype Test Node"),
580 S("Half-sized Allfaces Drawtype Test Node"))
581 scale("allfaces_optional",
582 S("Double-sized Allfaces Optional Drawtype Test Node"),
583 S("Half-sized Allfaces Optional Drawtype Test Node"))
584 scale("allfaces_optional_waving",
585 S("Double-sized Waving Allfaces Optional Drawtype Test Node"),
586 S("Half-sized Waving Allfaces Optional Drawtype Test Node"))
588 S("Double-sized Plantlike Drawtype Test Node"),
589 S("Half-sized Plantlike Drawtype Test Node"))
590 scale("torchlike_wallmounted",
591 S("Double-sized Wallmounted Torchlike Drawtype Test Node"),
592 S("Half-sized Wallmounted Torchlike Drawtype Test Node"))
593 scale("signlike_wallmounted",
594 S("Double-sized Wallmounted Signlike Drawtype Test Node"),
595 S("Half-sized Wallmounted Signlike Drawtype Test Node"))
597 S("Double-sized Firelike Drawtype Test Node"),
598 S("Half-sized Firelike Drawtype Test Node"))