]> git.lizzy.rs Git - minetest.git/blob - games/devtest/mods/testnodes/drawtypes.lua
Fix falling image of torchlike if paramtype2="none" (#10612)
[minetest.git] / games / devtest / mods / testnodes / drawtypes.lua
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.
5
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.
14 ]]
15
16 local S = minetest.get_translator("testnodes")
17
18 -- If set to true, will show an inventory image for nodes that have no inventory image as of Minetest 5.1.0.
19 -- This is due to <https://github.com/minetest/minetest/issues/9209>.
20 -- This is only added to make the items more visible to avoid confusion, but you will no longer see
21 -- the default inventory images for these items. When you want to test the default inventory image of drawtypes,
22 -- this should be turned off.
23 -- TODO: Remove support for fallback inventory image as soon #9209 is fixed.
24 local SHOW_FALLBACK_IMAGE = minetest.settings:get_bool("testnodes_show_fallback_image", false)
25
26 local fallback_image = function(img)
27         if SHOW_FALLBACK_IMAGE then
28                 return img
29         else
30                 return nil
31         end
32 end
33
34 -- A regular cube
35 minetest.register_node("testnodes:normal", {
36         description = S("Normal Drawtype Test Node"),
37         drawtype = "normal",
38         tiles = { "testnodes_normal.png" },
39
40         groups = { dig_immediate = 3 },
41 })
42
43 -- Standard glasslike node
44 minetest.register_node("testnodes:glasslike", {
45         description = S("Glasslike Drawtype Test Node"),
46         drawtype = "glasslike",
47         paramtype = "light",
48         tiles = { "testnodes_glasslike.png" },
49
50         groups = { dig_immediate = 3 },
51 })
52
53 -- Glasslike framed with the two textures (normal and "detail")
54 minetest.register_node("testnodes:glasslike_framed", {
55         description = S("Glasslike Framed Drawtype Test Node"),
56         drawtype = "glasslike_framed",
57         paramtype = "light",
58         tiles = {
59                 "testnodes_glasslike_framed.png",
60                 "testnodes_glasslike_detail.png",
61         },
62
63
64         sunlight_propagates = true,
65         groups = { dig_immediate = 3 },
66 })
67
68 -- Like the one above, but without the "detail" texture (texture 2).
69 -- This node was added to see how the engine behaves when the "detail" texture
70 -- is missing.
71 minetest.register_node("testnodes:glasslike_framed_no_detail", {
72         description = S("Glasslike Framed without Detail Drawtype Test Node"),
73         drawtype = "glasslike_framed",
74         paramtype = "light",
75         tiles = { "testnodes_glasslike_framed2.png" },
76
77
78         sunlight_propagates = true,
79         groups = { dig_immediate = 3 },
80 })
81
82
83 minetest.register_node("testnodes:glasslike_framed_optional", {
84         description = S("Glasslike Framed Optional Drawtype Test Node"),
85         drawtype = "glasslike_framed_optional",
86         paramtype = "light",
87         tiles = {
88                 "testnodes_glasslike_framed_optional.png",
89                 "testnodes_glasslike_detail.png",
90         },
91
92
93         sunlight_propagates = true,
94         groups = { dig_immediate = 3 },
95 })
96
97
98
99 minetest.register_node("testnodes:allfaces", {
100         description = S("Allfaces Drawtype Test Node"),
101         drawtype = "allfaces",
102         paramtype = "light",
103         tiles = { "testnodes_allfaces.png" },
104
105         groups = { dig_immediate = 3 },
106 })
107
108 minetest.register_node("testnodes:allfaces_optional", {
109         description = S("Allfaces Optional Drawtype Test Node"),
110         drawtype = "allfaces_optional",
111         paramtype = "light",
112         tiles = { "testnodes_allfaces_optional.png" },
113
114         groups = { dig_immediate = 3 },
115 })
116
117 minetest.register_node("testnodes:allfaces_optional_waving", {
118         description = S("Waving Allfaces Optional Drawtype Test Node"),
119         drawtype = "allfaces_optional",
120         paramtype = "light",
121         tiles = { "testnodes_allfaces_optional.png^[brighten" },
122         waving = 2,
123
124         groups = { dig_immediate = 3 },
125 })
126
127 minetest.register_node("testnodes:firelike", {
128         description = S("Firelike Drawtype Test Node"),
129         drawtype = "firelike",
130         paramtype = "light",
131         tiles = { "testnodes_firelike.png" },
132
133
134         walkable = false,
135         groups = { dig_immediate = 3 },
136 })
137
138 minetest.register_node("testnodes:fencelike", {
139         description = S("Fencelike Drawtype Test Node"),
140         drawtype = "fencelike",
141         paramtype = "light",
142         tiles = { "testnodes_fencelike.png" },
143
144         groups = { dig_immediate = 3 },
145 })
146
147 minetest.register_node("testnodes:torchlike", {
148         description = S("Torchlike Drawtype Test Node"),
149         drawtype = "torchlike",
150         paramtype = "light",
151         tiles = {
152                 "testnodes_torchlike_floor.png",
153                 "testnodes_torchlike_ceiling.png",
154                 "testnodes_torchlike_wall.png",
155         },
156
157
158         walkable = false,
159         sunlight_propagates = true,
160         groups = { dig_immediate = 3 },
161         inventory_image = fallback_image("testnodes_torchlike_floor.png"),
162 })
163
164 minetest.register_node("testnodes:torchlike_wallmounted", {
165         description = S("Wallmounted Torchlike Drawtype Test Node"),
166         drawtype = "torchlike",
167         paramtype = "light",
168         paramtype2 = "wallmounted",
169         tiles = {
170                 "testnodes_torchlike_floor.png",
171                 "testnodes_torchlike_ceiling.png",
172                 "testnodes_torchlike_wall.png",
173         },
174
175
176         walkable = false,
177         sunlight_propagates = true,
178         groups = { dig_immediate = 3 },
179         inventory_image = fallback_image("testnodes_torchlike_floor.png"),
180 })
181
182
183
184 minetest.register_node("testnodes:signlike", {
185         description = S("Wallmounted Signlike Drawtype Test Node"),
186         drawtype = "signlike",
187         paramtype = "light",
188         paramtype2 = "wallmounted",
189         tiles = { "testnodes_signlike.png" },
190
191
192         walkable = false,
193         groups = { dig_immediate = 3 },
194         sunlight_propagates = true,
195         inventory_image = fallback_image("testnodes_signlike.png"),
196 })
197
198 minetest.register_node("testnodes:plantlike", {
199         description = S("Plantlike Drawtype Test Node"),
200         drawtype = "plantlike",
201         paramtype = "light",
202         tiles = { "testnodes_plantlike.png" },
203
204
205         walkable = false,
206         sunlight_propagates = true,
207         groups = { dig_immediate = 3 },
208 })
209
210 minetest.register_node("testnodes:plantlike_waving", {
211         description = S("Waving Plantlike Drawtype Test Node"),
212         drawtype = "plantlike",
213         paramtype = "light",
214         tiles = { "testnodes_plantlike_waving.png" },
215         waving = 1,
216
217
218         walkable = false,
219         sunlight_propagates = true,
220         groups = { dig_immediate = 3 },
221 })
222
223
224
225 -- param2 will rotate
226 minetest.register_node("testnodes:plantlike_degrotate", {
227         description = S("Degrotate Plantlike Drawtype Test Node"),
228         drawtype = "plantlike",
229         paramtype = "light",
230         paramtype2 = "degrotate",
231         tiles = { "testnodes_plantlike_degrotate.png" },
232
233
234         walkable = false,
235         sunlight_propagates = true,
236         groups = { dig_immediate = 3 },
237 })
238
239 -- param2 will change height
240 minetest.register_node("testnodes:plantlike_leveled", {
241         description = S("Leveled Plantlike Drawtype Test Node"),
242         drawtype = "plantlike",
243         paramtype = "light",
244         paramtype2 = "leveled",
245         tiles = {
246                 { name = "testnodes_plantlike_leveled.png", tileable_vertical = true },
247         },
248
249
250         -- We set a default param2 here only for convenience, to make the "plant" visible after placement
251         place_param2 = 8,
252         walkable = false,
253         sunlight_propagates = true,
254         groups = { dig_immediate = 3 },
255 })
256
257 -- param2 changes shape
258 minetest.register_node("testnodes:plantlike_meshoptions", {
259         description = S("Meshoptions Plantlike Drawtype Test Node"),
260         drawtype = "plantlike",
261         paramtype = "light",
262         paramtype2 = "meshoptions",
263         tiles = { "testnodes_plantlike_meshoptions.png" },
264
265
266         walkable = false,
267         groups = { dig_immediate = 3 },
268 })
269
270 minetest.register_node("testnodes:plantlike_rooted", {
271         description = S("Rooted Plantlike Drawtype Test Node"),
272         drawtype = "plantlike_rooted",
273         paramtype = "light",
274         tiles = { "testnodes_plantlike_rooted_base.png" },
275         special_tiles = { "testnodes_plantlike_rooted.png" },
276
277         groups = { dig_immediate = 3 },
278 })
279
280 minetest.register_node("testnodes:plantlike_rooted_waving", {
281         description = S("Waving Rooted Plantlike Drawtype Test Node"),
282         drawtype = "plantlike_rooted",
283         paramtype = "light",
284         tiles = {
285                 "testnodes_plantlike_rooted_base.png",
286                 "testnodes_plantlike_rooted_base.png",
287                 "testnodes_plantlike_rooted_base_side_waving.png",
288         },
289         special_tiles = { "testnodes_plantlike_rooted_waving.png" },
290         waving = 1,
291
292         groups = { dig_immediate = 3 },
293 })
294
295 -- param2 changes height
296 minetest.register_node("testnodes:plantlike_rooted_leveled", {
297         description = S("Leveled Rooted Plantlike Drawtype Test Node"),
298         drawtype = "plantlike_rooted",
299         paramtype = "light",
300         paramtype2 = "leveled",
301         tiles = {
302                 "testnodes_plantlike_rooted_base.png",
303                 "testnodes_plantlike_rooted_base.png",
304                 "testnodes_plantlike_rooted_base_side_leveled.png",
305         },
306         special_tiles = {
307                 { name = "testnodes_plantlike_rooted_leveled.png", tileable_vertical = true },
308         },
309
310
311         -- We set a default param2 here only for convenience, to make the "plant" visible after placement
312         place_param2 = 8,
313         groups = { dig_immediate = 3 },
314 })
315
316 -- param2 changes shape
317 minetest.register_node("testnodes:plantlike_rooted_meshoptions", {
318         description = S("Meshoptions Rooted Plantlike Drawtype Test Node"),
319         drawtype = "plantlike_rooted",
320         paramtype = "light",
321         paramtype2 = "meshoptions",
322         tiles = {
323                 "testnodes_plantlike_rooted_base.png",
324                 "testnodes_plantlike_rooted_base.png",
325                 "testnodes_plantlike_rooted_base_side_meshoptions.png",
326         },
327         special_tiles = {
328                 "testnodes_plantlike_rooted_meshoptions.png",
329         },
330
331         groups = { dig_immediate = 3 },
332 })
333
334 -- param2 changes rotation
335 minetest.register_node("testnodes:plantlike_rooted_degrotate", {
336         description = S("Degrotate Rooted Plantlike Drawtype Test Node"),
337         drawtype = "plantlike_rooted",
338         paramtype = "light",
339         paramtype2 = "degrotate",
340         tiles = {
341                 "testnodes_plantlike_rooted_base.png",
342                 "testnodes_plantlike_rooted_base.png",
343                 "testnodes_plantlike_rooted_base_side_degrotate.png",
344         },
345         special_tiles = {
346                 "testnodes_plantlike_rooted_degrotate.png",
347         },
348
349         groups = { dig_immediate = 3 },
350 })
351
352 -- Demonstrative liquid nodes, source and flowing form.
353 minetest.register_node("testnodes:liquid", {
354         description = S("Source Liquid Drawtype Test Node"),
355         drawtype = "liquid",
356         paramtype = "light",
357         tiles = {
358                 "testnodes_liquidsource.png",
359         },
360         special_tiles = {
361                 {name="testnodes_liquidsource.png", backface_culling=false},
362                 {name="testnodes_liquidsource.png", backface_culling=true},
363         },
364         use_texture_alpha = true,
365
366
367         walkable = false,
368         liquidtype = "source",
369         liquid_range = 1,
370         liquid_viscosity = 0,
371         liquid_alternative_flowing = "testnodes:liquid_flowing",
372         liquid_alternative_source = "testnodes:liquid",
373         groups = { dig_immediate = 3 },
374 })
375 minetest.register_node("testnodes:liquid_flowing", {
376         description = S("Flowing Liquid Drawtype Test Node"),
377         drawtype = "flowingliquid",
378         paramtype = "light",
379         paramtype2 = "flowingliquid",
380         tiles = {
381                 "testnodes_liquidflowing.png",
382         },
383         special_tiles = {
384                 {name="testnodes_liquidflowing.png", backface_culling=false},
385                 {name="testnodes_liquidflowing.png", backface_culling=false},
386         },
387         use_texture_alpha = true,
388
389
390         walkable = false,
391         liquidtype = "flowing",
392         liquid_range = 1,
393         liquid_viscosity = 0,
394         liquid_alternative_flowing = "testnodes:liquid_flowing",
395         liquid_alternative_source = "testnodes:liquid",
396         groups = { dig_immediate = 3 },
397 })
398 minetest.register_node("testnodes:liquid_waving", {
399         description = S("Waving Source Liquid Drawtype Test Node"),
400         drawtype = "liquid",
401         paramtype = "light",
402         tiles = {
403                 "testnodes_liquidsource.png^[brighten",
404         },
405         special_tiles = {
406                 {name="testnodes_liquidsource.png^[brighten", backface_culling=false},
407                 {name="testnodes_liquidsource.png^[brighten", backface_culling=true},
408         },
409         use_texture_alpha = true,
410         waving = 3,
411
412
413         walkable = false,
414         liquidtype = "source",
415         liquid_range = 1,
416         liquid_viscosity = 0,
417         liquid_alternative_flowing = "testnodes:liquid_flowing_waving",
418         liquid_alternative_source = "testnodes:liquid_waving",
419         groups = { dig_immediate = 3 },
420 })
421 minetest.register_node("testnodes:liquid_flowing_waving", {
422         description = S("Waving Flowing Liquid Drawtype Test Node"),
423         drawtype = "flowingliquid",
424         paramtype = "light",
425         paramtype2 = "flowingliquid",
426         tiles = {
427                 "testnodes_liquidflowing.png^[brighten",
428         },
429         special_tiles = {
430                 {name="testnodes_liquidflowing.png^[brighten", backface_culling=false},
431                 {name="testnodes_liquidflowing.png^[brighten", backface_culling=false},
432         },
433         use_texture_alpha = true,
434         waving = 3,
435
436
437         walkable = false,
438         liquidtype = "flowing",
439         liquid_range = 1,
440         liquid_viscosity = 0,
441         liquid_alternative_flowing = "testnodes:liquid_flowing_waving",
442         liquid_alternative_source = "testnodes:liquid_waving",
443         groups = { dig_immediate = 3 },
444 })
445
446
447
448 -- Invisible node
449 minetest.register_node("testnodes:airlike", {
450         description = S("Airlike Drawtype Test Node"),
451         drawtype = "airlike",
452         paramtype = "light",
453
454
455         walkable = false,
456         groups = { dig_immediate = 3 },
457         sunlight_propagates = true,
458         inventory_image = fallback_image("testnodes_airlike.png"),
459 })
460
461 -- param2 changes liquid height
462 minetest.register_node("testnodes:glassliquid", {
463         description = S("Glasslike Liquid Level Drawtype Test Node"),
464         drawtype = "glasslike_framed",
465         paramtype = "light",
466         paramtype2 = "glasslikeliquidlevel",
467         tiles = {
468                 "testnodes_glasslikeliquid.png",
469         },
470         special_tiles = {
471                 "testnodes_liquid.png",
472         },
473
474         groups = { dig_immediate = 3 },
475 })
476
477 -- Adding many raillike examples, primarily to demonstrate the behavior of
478 -- "raillike groups". Nodes of the same type (rail, groupless, line, street)
479 -- should connect to nodes of the same "rail type" (=same shape, different
480 -- color) only.
481 local rails = {
482         { "rail", {"testnodes_rail_straight.png", "testnodes_rail_curved.png", "testnodes_rail_t_junction.png", "testnodes_rail_crossing.png"} },
483         { "line", {"testnodes_line_straight.png", "testnodes_line_curved.png", "testnodes_line_t_junction.png", "testnodes_line_crossing.png"}, },
484         { "street", {"testnodes_street_straight.png", "testnodes_street_curved.png", "testnodes_street_t_junction.png", "testnodes_street_crossing.png"}, },
485         -- the "groupless" nodes are nodes in which the "connect_to_raillike" group is not set
486         { "groupless", {"testnodes_rail2_straight.png", "testnodes_rail2_curved.png", "testnodes_rail2_t_junction.png", "testnodes_rail2_crossing.png"} },
487 }
488 local colors = { "", "cyan", "red" }
489
490 for r=1, #rails do
491         local id = rails[r][1]
492         local tiles = rails[r][2]
493         local raillike_group
494         if id ~= "groupless" then
495                 raillike_group = minetest.raillike_group(id)
496         end
497         for c=1, #colors do
498                 local color
499                 if colors[c] ~= "" then
500                         color = colors[c]
501                 end
502                 minetest.register_node("testnodes:raillike_"..id..c, {
503                         description = S("Raillike Drawtype Test Node: @1 @2", id, c),
504                         drawtype = "raillike",
505                         paramtype = "light",
506                         tiles = tiles,
507                         groups = { connect_to_raillike = raillike_group, dig_immediate = 3 },
508
509
510                         color = color,
511                         selection_box = {
512                                 type = "fixed",
513                                 fixed = {{-0.5,  -0.5,  -0.5, 0.5, -0.4, 0.5}},
514                         },
515                         sunlight_propagates = true,
516                         walkable = false,
517                 })
518         end
519 end
520
521
522
523 -- Add visual_scale variants of previous nodes for half and double size
524 local scale = function(subname, desc_double, desc_half)
525         local original = "testnodes:"..subname
526         local def = table.copy(minetest.registered_items[original])
527         def.visual_scale = 2.0
528         def.description = desc_double
529         minetest.register_node("testnodes:"..subname.."_double", def)
530         def = table.copy(minetest.registered_items[original])
531         def.visual_scale = 0.5
532         def.description = desc_half
533         minetest.register_node("testnodes:"..subname.."_half", def)
534 end
535
536 scale("allfaces",
537         S("Double-sized Allfaces Drawtype Test Node"),
538         S("Half-sized Allfaces Drawtype Test Node"))
539 scale("allfaces_optional",
540         S("Double-sized Allfaces Optional Drawtype Test Node"),
541         S("Half-sized Allfaces Optional Drawtype Test Node"))
542 scale("allfaces_optional_waving",
543         S("Double-sized Waving Allfaces Optional Drawtype Test Node"),
544         S("Half-sized Waving Allfaces Optional Drawtype Test Node"))
545 scale("plantlike",
546         S("Double-sized Plantlike Drawtype Test Node"),
547         S("Half-sized Plantlike Drawtype Test Node"))
548 scale("torchlike_wallmounted",
549         S("Double-sized Wallmounted Torchlike Drawtype Test Node"),
550         S("Half-sized Wallmounted Torchlike Drawtype Test Node"))
551 scale("signlike",
552         S("Double-sized Wallmounted Signlike Drawtype Test Node"),
553         S("Half-sized Wallmounted Signlike Drawtype Test Node"))
554 scale("firelike",
555         S("Double-sized Firelike Drawtype Test Node"),
556         S("Half-sized Firelike Drawtype Test Node"))