Paramtype2: Add missing type CPT2_GLASSLIKE_LIQUID_LEVEL
authorparamat <mat.gregory@virginmedia.com>
Wed, 29 Mar 2017 02:40:30 +0000 (03:40 +0100)
committerparamat <mat.gregory@virginmedia.com>
Thu, 30 Mar 2017 03:52:54 +0000 (04:52 +0100)
Add the missing paramtype2 for param2 controlling the liquid level
inside the glasslike_framed drawtype.
Add missing documentation of the feature to lua_api.txt.
Update and improve comments for drawtype enumerations in nodedef.h.

doc/lua_api.txt
src/content_mapblock.cpp
src/nodedef.h
src/script/cpp_api/s_node.cpp

index 72599cb7c1f35c8365a32bc2ad773625b7ad20a0..0ca3767f972b00ef34a601d9f518b4fe8e097b77 100644 (file)
@@ -658,6 +658,10 @@ node definition:
       The first five bits of `param2` tells which color
       is picked from the palette.
       The palette should have 32 pixels.
+    paramtype2 == "glasslikeliquidlevel"
+    ^ Only valid for "glasslike_framed" or "glasslike_framed_optional" drawtypes.
+      param2 defines 64 levels of internal liquid.
+      Liquid texture is defined using `special_tiles = {"modname_tilename.png"},`
     collision_box = {
       type = "fixed",
       fixed = {
index d0cb50db3797754bb94d7c12567e437aad5468db..d18aff879aec813d055f0cc393df9eb0d3fb18c5 100644 (file)
@@ -760,8 +760,11 @@ void MapblockMeshGenerator::drawGlasslikeFramedNode()
                drawAutoLightedCuboid(glass_faces[face]);
        }
 
-       if (param2 > 0 && f->special_tiles[0].texture) {
-               // Interior volume level is in range 0 .. 63,
+       // Optionally render internal liquid level defined by param2
+       // Liquid is textured with 1 tile defined in nodedef 'special_tiles'
+       if (param2 > 0 && f->param_type_2 == CPT2_GLASSLIKE_LIQUID_LEVEL &&
+                       f->special_tiles[0].texture) {
+               // Internal liquid level has param2 range 0 .. 63,
                // convert it to -0.5 .. 0.5
                float vlev = (param2 / 63.0) * 2.0 - 1.0;
                tile = getSpecialTile(*f, n, 0);
index 4a9908ecc0d62b2396bfff164a0ac93faa8cde33..da3345d8023ebc2307ac3c1391eae545f2d1e281 100644 (file)
@@ -74,7 +74,9 @@ enum ContentParamType2
        // 3 bits of palette index, then facedir
        CPT2_COLORED_FACEDIR,
        // 5 bits of palette index, then wallmounted
-       CPT2_COLORED_WALLMOUNTED
+       CPT2_COLORED_WALLMOUNTED,
+       // Glasslike framed drawtype internal liquid level, param2 values 0 to 63
+       CPT2_GLASSLIKE_LIQUID_LEVEL,
 };
 
 enum LiquidType
@@ -144,26 +146,46 @@ public:
 
 enum NodeDrawType
 {
-       NDT_NORMAL, // A basic solid block
-       NDT_AIRLIKE, // Nothing is drawn
-       NDT_LIQUID, // Do not draw face towards same kind of flowing/source liquid
-       NDT_FLOWINGLIQUID, // A very special kind of thing
-       NDT_GLASSLIKE, // Glass-like, don't draw faces towards other glass
-       NDT_ALLFACES, // Leaves-like, draw all faces no matter what
-       NDT_ALLFACES_OPTIONAL, // Fancy -> allfaces, fast -> normal
+       // A basic solid block
+       NDT_NORMAL,
+       // Nothing is drawn
+       NDT_AIRLIKE,
+       // Do not draw face towards same kind of flowing/source liquid
+       NDT_LIQUID,
+       // A very special kind of thing
+       NDT_FLOWINGLIQUID,
+       // Glass-like, don't draw faces towards other glass
+       NDT_GLASSLIKE,
+       // Leaves-like, draw all faces no matter what
+       NDT_ALLFACES,
+       // Enabled -> ndt_allfaces, disabled -> ndt_normal
+       NDT_ALLFACES_OPTIONAL,
+       // Single plane perpendicular to a surface
        NDT_TORCHLIKE,
+       // Single plane parallel to a surface
        NDT_SIGNLIKE,
+       // 2 vertical planes in a 'X' shape diagonal to XZ axes.
+       // paramtype2 = "meshoptions" allows various forms, sizes and
+       // vertical and horizontal random offsets.
        NDT_PLANTLIKE,
+       // Fenceposts that connect to neighbouring fenceposts with horizontal bars
        NDT_FENCELIKE,
+       // Selects appropriate junction texture to connect like rails to
+       // neighbouring raillikes.
        NDT_RAILLIKE,
+       // Custom Lua-definable structure of multiple cuboids
        NDT_NODEBOX,
-       NDT_GLASSLIKE_FRAMED, // Glass-like, draw connected frames and all all
-                             // visible faces
-                                                 // uses 2 textures, one for frames, second for faces
-       NDT_FIRELIKE, // Draw faces slightly rotated and only on connecting nodes,
-       NDT_GLASSLIKE_FRAMED_OPTIONAL,  // enabled -> connected, disabled -> Glass-like
-                                                                       // uses 2 textures, one for frames, second for faces
-       NDT_MESH, // Uses static meshes
+       // Glass-like, draw connected frames and all visible faces.
+       // param2 > 0 defines 64 levels of internal liquid
+       // Uses 3 textures, one for frames, second for faces,
+       // optional third is a 'special tile' for the liquid.
+       NDT_GLASSLIKE_FRAMED,
+       // Draw faces slightly rotated and only on neighbouring nodes
+       NDT_FIRELIKE,
+       // Enabled -> ndt_glasslike_framed, disabled -> ndt_glasslike
+       NDT_GLASSLIKE_FRAMED_OPTIONAL,
+       // Uses static meshes
+       NDT_MESH,
 };
 
 // Mesh options for NDT_PLANTLIKE with CPT2_MESHOPTIONS
index 23c8f43b97b908080a8b61076ebc4b3fa6327c0e..adad01e453389b3c5814055614ab7bb98d7752c6 100644 (file)
@@ -62,6 +62,7 @@ struct EnumString ScriptApiNode::es_ContentParamType2[] =
                {CPT2_COLOR, "color"},
                {CPT2_COLORED_FACEDIR, "colorfacedir"},
                {CPT2_COLORED_WALLMOUNTED, "colorwallmounted"},
+               {CPT2_GLASSLIKE_LIQUID_LEVEL, "glasslikeliquidlevel"},
                {0, NULL},
        };