]> git.lizzy.rs Git - minetest.git/blob - games/devtest/mods/testnodes/drawtypes.lua
Devtest: Fix missing/incorrect liquid properties (#9955)
[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("Wallmounted Torchlike Drawtype Test Node"),
149         drawtype = "torchlike",
150         paramtype = "light",
151         paramtype2 = "wallmounted",
152         tiles = {
153                 "testnodes_torchlike_floor.png",
154                 "testnodes_torchlike_ceiling.png",
155                 "testnodes_torchlike_wall.png",
156         },
157
158
159         walkable = false,
160         sunlight_propagates = true,
161         groups = { dig_immediate = 3 },
162         inventory_image = fallback_image("testnodes_torchlike_floor.png"),
163 })
164
165 minetest.register_node("testnodes:signlike", {
166         description = S("Wallmounted Signlike Drawtype Test Node"),
167         drawtype = "signlike",
168         paramtype = "light",
169         paramtype2 = "wallmounted",
170         tiles = { "testnodes_signlike.png" },
171
172
173         walkable = false,
174         groups = { dig_immediate = 3 },
175         sunlight_propagates = true,
176         inventory_image = fallback_image("testnodes_signlike.png"),
177 })
178
179 minetest.register_node("testnodes:plantlike", {
180         description = S("Plantlike Drawtype Test Node"),
181         drawtype = "plantlike",
182         paramtype = "light",
183         tiles = { "testnodes_plantlike.png" },
184
185
186         walkable = false,
187         sunlight_propagates = true,
188         groups = { dig_immediate = 3 },
189 })
190
191 minetest.register_node("testnodes:plantlike_waving", {
192         description = S("Waving Plantlike Drawtype Test Node"),
193         drawtype = "plantlike",
194         paramtype = "light",
195         tiles = { "testnodes_plantlike_waving.png" },
196         waving = 1,
197
198
199         walkable = false,
200         sunlight_propagates = true,
201         groups = { dig_immediate = 3 },
202 })
203
204
205
206 -- param2 will rotate
207 minetest.register_node("testnodes:plantlike_degrotate", {
208         description = S("Degrotate Plantlike Drawtype Test Node"),
209         drawtype = "plantlike",
210         paramtype = "light",
211         paramtype2 = "degrotate",
212         tiles = { "testnodes_plantlike_degrotate.png" },
213
214
215         walkable = false,
216         sunlight_propagates = true,
217         groups = { dig_immediate = 3 },
218 })
219
220 -- param2 will change height
221 minetest.register_node("testnodes:plantlike_leveled", {
222         description = S("Leveled Plantlike Drawtype Test Node"),
223         drawtype = "plantlike",
224         paramtype = "light",
225         paramtype2 = "leveled",
226         tiles = {
227                 { name = "testnodes_plantlike_leveled.png", tileable_vertical = true },
228         },
229
230
231         -- We set a default param2 here only for convenience, to make the "plant" visible after placement
232         place_param2 = 8,
233         walkable = false,
234         sunlight_propagates = true,
235         groups = { dig_immediate = 3 },
236 })
237
238 -- param2 changes shape
239 minetest.register_node("testnodes:plantlike_meshoptions", {
240         description = S("Meshoptions Plantlike Drawtype Test Node"),
241         drawtype = "plantlike",
242         paramtype = "light",
243         paramtype2 = "meshoptions",
244         tiles = { "testnodes_plantlike_meshoptions.png" },
245
246
247         walkable = false,
248         groups = { dig_immediate = 3 },
249 })
250
251 minetest.register_node("testnodes:plantlike_rooted", {
252         description = S("Rooted Plantlike Drawtype Test Node"),
253         drawtype = "plantlike_rooted",
254         paramtype = "light",
255         tiles = { "testnodes_plantlike_rooted_base.png" },
256         special_tiles = { "testnodes_plantlike_rooted.png" },
257
258         groups = { dig_immediate = 3 },
259 })
260
261 minetest.register_node("testnodes:plantlike_rooted_waving", {
262         description = S("Waving Rooted Plantlike Drawtype Test Node"),
263         drawtype = "plantlike_rooted",
264         paramtype = "light",
265         tiles = {
266                 "testnodes_plantlike_rooted_base.png",
267                 "testnodes_plantlike_rooted_base.png",
268                 "testnodes_plantlike_rooted_base_side_waving.png",
269         },
270         special_tiles = { "testnodes_plantlike_rooted_waving.png" },
271         waving = 1,
272
273         groups = { dig_immediate = 3 },
274 })
275
276 -- param2 changes height
277 minetest.register_node("testnodes:plantlike_rooted_leveled", {
278         description = S("Leveled Rooted Plantlike Drawtype Test Node"),
279         drawtype = "plantlike_rooted",
280         paramtype = "light",
281         paramtype2 = "leveled",
282         tiles = {
283                 "testnodes_plantlike_rooted_base.png",
284                 "testnodes_plantlike_rooted_base.png",
285                 "testnodes_plantlike_rooted_base_side_leveled.png",
286         },
287         special_tiles = {
288                 { name = "testnodes_plantlike_rooted_leveled.png", tileable_vertical = true },
289         },
290
291
292         -- We set a default param2 here only for convenience, to make the "plant" visible after placement
293         place_param2 = 8,
294         groups = { dig_immediate = 3 },
295 })
296
297 -- param2 changes shape
298 minetest.register_node("testnodes:plantlike_rooted_meshoptions", {
299         description = S("Meshoptions Rooted Plantlike Drawtype Test Node"),
300         drawtype = "plantlike_rooted",
301         paramtype = "light",
302         paramtype2 = "meshoptions",
303         tiles = {
304                 "testnodes_plantlike_rooted_base.png",
305                 "testnodes_plantlike_rooted_base.png",
306                 "testnodes_plantlike_rooted_base_side_meshoptions.png",
307         },
308         special_tiles = {
309                 "testnodes_plantlike_rooted_meshoptions.png",
310         },
311
312         groups = { dig_immediate = 3 },
313 })
314
315 -- param2 changes rotation
316 minetest.register_node("testnodes:plantlike_rooted_degrotate", {
317         description = S("Degrotate Rooted Plantlike Drawtype Test Node"),
318         drawtype = "plantlike_rooted",
319         paramtype = "light",
320         paramtype2 = "degrotate",
321         tiles = {
322                 "testnodes_plantlike_rooted_base.png",
323                 "testnodes_plantlike_rooted_base.png",
324                 "testnodes_plantlike_rooted_base_side_degrotate.png",
325         },
326         special_tiles = {
327                 "testnodes_plantlike_rooted_degrotate.png",
328         },
329
330         groups = { dig_immediate = 3 },
331 })
332
333 -- Demonstrative liquid nodes, source and flowing form.
334 minetest.register_node("testnodes:liquid", {
335         description = S("Source Liquid Drawtype Test Node"),
336         drawtype = "liquid",
337         paramtype = "light",
338         tiles = {
339                 "testnodes_liquidsource.png",
340         },
341         special_tiles = {
342                 {name="testnodes_liquidsource.png", backface_culling=false},
343                 {name="testnodes_liquidsource.png", backface_culling=true},
344         },
345         use_texture_alpha = true,
346
347
348         walkable = false,
349         liquidtype = "source",
350         liquid_range = 1,
351         liquid_viscosity = 0,
352         liquid_alternative_flowing = "testnodes:liquid_flowing",
353         liquid_alternative_source = "testnodes:liquid",
354         groups = { dig_immediate = 3 },
355 })
356 minetest.register_node("testnodes:liquid_flowing", {
357         description = S("Flowing Liquid Drawtype Test Node"),
358         drawtype = "flowingliquid",
359         paramtype = "light",
360         paramtype2 = "flowingliquid",
361         tiles = {
362                 "testnodes_liquidflowing.png",
363         },
364         special_tiles = {
365                 {name="testnodes_liquidflowing.png", backface_culling=false},
366                 {name="testnodes_liquidflowing.png", backface_culling=false},
367         },
368         use_texture_alpha = true,
369
370
371         walkable = false,
372         liquidtype = "flowing",
373         liquid_range = 1,
374         liquid_viscosity = 0,
375         liquid_alternative_flowing = "testnodes:liquid_flowing",
376         liquid_alternative_source = "testnodes:liquid",
377         groups = { dig_immediate = 3 },
378 })
379 minetest.register_node("testnodes:liquid_waving", {
380         description = S("Waving Source Liquid Drawtype Test Node"),
381         drawtype = "liquid",
382         paramtype = "light",
383         tiles = {
384                 "testnodes_liquidsource.png^[brighten",
385         },
386         special_tiles = {
387                 {name="testnodes_liquidsource.png^[brighten", backface_culling=false},
388                 {name="testnodes_liquidsource.png^[brighten", backface_culling=true},
389         },
390         use_texture_alpha = true,
391         waving = 3,
392
393
394         walkable = false,
395         liquidtype = "source",
396         liquid_range = 1,
397         liquid_viscosity = 0,
398         liquid_alternative_flowing = "testnodes:liquid_flowing_waving",
399         liquid_alternative_source = "testnodes:liquid_waving",
400         groups = { dig_immediate = 3 },
401 })
402 minetest.register_node("testnodes:liquid_flowing_waving", {
403         description = S("Waving Flowing Liquid Drawtype Test Node"),
404         drawtype = "flowingliquid",
405         paramtype = "light",
406         paramtype2 = "flowingliquid",
407         tiles = {
408                 "testnodes_liquidflowing.png^[brighten",
409         },
410         special_tiles = {
411                 {name="testnodes_liquidflowing.png^[brighten", backface_culling=false},
412                 {name="testnodes_liquidflowing.png^[brighten", backface_culling=false},
413         },
414         use_texture_alpha = true,
415         waving = 3,
416
417
418         walkable = false,
419         liquidtype = "flowing",
420         liquid_range = 1,
421         liquid_viscosity = 0,
422         liquid_alternative_flowing = "testnodes:liquid_flowing_waving",
423         liquid_alternative_source = "testnodes:liquid_waving",
424         groups = { dig_immediate = 3 },
425 })
426
427
428
429 -- Invisible node
430 minetest.register_node("testnodes:airlike", {
431         description = S("Airlike Drawtype Test Node"),
432         drawtype = "airlike",
433         paramtype = "light",
434
435
436         walkable = false,
437         groups = { dig_immediate = 3 },
438         sunlight_propagates = true,
439         inventory_image = fallback_image("testnodes_airlike.png"),
440 })
441
442 -- param2 changes liquid height
443 minetest.register_node("testnodes:glassliquid", {
444         description = S("Glasslike Liquid Level Drawtype Test Node"),
445         drawtype = "glasslike_framed",
446         paramtype = "light",
447         paramtype2 = "glasslikeliquidlevel",
448         tiles = {
449                 "testnodes_glasslikeliquid.png",
450         },
451         special_tiles = {
452                 "testnodes_liquid.png",
453         },
454
455         groups = { dig_immediate = 3 },
456 })
457
458 -- Adding many raillike examples, primarily to demonstrate the behavior of
459 -- "raillike groups". Nodes of the same type (rail, groupless, line, street)
460 -- should connect to nodes of the same "rail type" (=same shape, different
461 -- color) only.
462 local rails = {
463         { "rail", {"testnodes_rail_straight.png", "testnodes_rail_curved.png", "testnodes_rail_t_junction.png", "testnodes_rail_crossing.png"} },
464         { "line", {"testnodes_line_straight.png", "testnodes_line_curved.png", "testnodes_line_t_junction.png", "testnodes_line_crossing.png"}, },
465         { "street", {"testnodes_street_straight.png", "testnodes_street_curved.png", "testnodes_street_t_junction.png", "testnodes_street_crossing.png"}, },
466         -- the "groupless" nodes are nodes in which the "connect_to_raillike" group is not set
467         { "groupless", {"testnodes_rail2_straight.png", "testnodes_rail2_curved.png", "testnodes_rail2_t_junction.png", "testnodes_rail2_crossing.png"} },
468 }
469 local colors = { "", "cyan", "red" }
470
471 for r=1, #rails do
472         local id = rails[r][1]
473         local tiles = rails[r][2]
474         local raillike_group
475         if id ~= "groupless" then
476                 raillike_group = minetest.raillike_group(id)
477         end
478         for c=1, #colors do
479                 local color
480                 if colors[c] ~= "" then
481                         color = colors[c]
482                 end
483                 minetest.register_node("testnodes:raillike_"..id..c, {
484                         description = S("Raillike Drawtype Test Node: @1 @2", id, c),
485                         drawtype = "raillike",
486                         paramtype = "light",
487                         tiles = tiles,
488                         groups = { connect_to_raillike = raillike_group, dig_immediate = 3 },
489
490
491                         color = color,
492                         selection_box = {
493                                 type = "fixed",
494                                 fixed = {{-0.5,  -0.5,  -0.5, 0.5, -0.4, 0.5}},
495                         },
496                         sunlight_propagates = true,
497                         walkable = false,
498                 })
499         end
500 end
501
502
503
504 -- Add visual_scale variants of previous nodes for half and double size
505 local scale = function(subname, desc_double, desc_half)
506         local original = "testnodes:"..subname
507         local def = table.copy(minetest.registered_items[original])
508         def.visual_scale = 2.0
509         def.description = desc_double
510         minetest.register_node("testnodes:"..subname.."_double", def)
511         def = table.copy(minetest.registered_items[original])
512         def.visual_scale = 0.5
513         def.description = desc_half
514         minetest.register_node("testnodes:"..subname.."_half", def)
515 end
516
517 scale("plantlike",
518         S("Double-sized Plantlike Drawtype Test Node"),
519         S("Half-sized Plantlike Drawtype Test Node"))
520 scale("torchlike",
521         S("Double-sized Wallmounted Torchlike Drawtype Test Node"),
522         S("Half-sized Wallmounted Torchlike Drawtype Test Node"))
523 scale("signlike",
524         S("Double-sized Wallmounted Signlike Drawtype Test Node"),
525         S("Half-sized Wallmounted Signlike Drawtype Test Node"))
526 scale("firelike",
527         S("Double-sized Firelike Drawtype Test Node"),
528         S("Half-sized Firelike Drawtype Test Node"))