From 3d73420d651ecfa7deac986dca9ce20ea7a0f353 Mon Sep 17 00:00:00 2001 From: Desour Date: Sat, 3 May 2025 16:01:14 +0200 Subject: [PATCH 1/4] Improve TileDef doc --- doc/lua_api.md | 112 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 91 insertions(+), 21 deletions(-) diff --git a/doc/lua_api.md b/doc/lua_api.md index b492f5be5..cf9eaab3a 100644 --- a/doc/lua_api.md +++ b/doc/lua_api.md @@ -9664,29 +9664,95 @@ Currently the only workaround is to use `run_at_every_load = true`. Tile definition --------------- -* `"image.png"` -* `{name="image.png", animation={Tile Animation definition}}` -* `{name="image.png", backface_culling=bool, align_style="node"/"world"/"user", scale=int}` - * backface culling enabled by default for most nodes - * align style determines whether the texture will be rotated with the node - or kept aligned with its surroundings. "user" means that client - setting will be used, similar to `glasslike_framed_optional`. - Note: supported by solid nodes and nodeboxes only. - * scale is used to make texture span several (exactly `scale`) nodes, - instead of just one, in each direction. Works for world-aligned - textures only. - Note that as the effect is applied on per-mapblock basis, `16` should - be equally divisible by `scale` or you may get wrong results. -* `{name="image.png", color=ColorSpec}` - * the texture's color will be multiplied with this color. - * the tile's color overrides the owning node's color in all cases. -* deprecated, yet still supported field names: - * `image` (name) +Short form: + +```lua +"mymod_image.png" +-- Equivalent to `{name = "mymod_image.png"}`. +``` + +Long form: + +```lua +{ + name = "mymod_image.png", + -- Texture for the tile, see [Textures]. + + image = "mymod_image.png", + -- Deprecated. Alternative to `name`. + + backface_culling = bool, + -- If `true`, faces will only be drawn from one side. + -- + -- Default: + -- * `false` for drawtypes `plantlike`, `firelike`, `mesh`, and `liquid`. + -- * `false` for `special_tiles` of drawtype `plantlike_rooted`. + -- * `true` otherwise. + + tileable_horizontal = bool, + tileable_vertical = bool, + -- Decides how textures are sampled out-of-bounds. + -- + -- If `true`, pixels are repeated, if `false`, values are clamped to edge. + -- + -- `tileable_horizontal` and `tileable_vertical` apply to texture coordinates + -- horizontal and vertical respecitively in uv space, not world space. + -- + -- Default (for both): + -- * `false` for drawtypes `plantlike`, and `firelike`. + -- * `false` for `special_tiles` of drawtype `plantlike_rooted`. + -- * `true` otherwise. + + align_style = "node", + -- Determines whether the texture will be rotated with the node or kept + -- aligned with its surroundings. + -- + -- The tile for a face of a node is still chosen by the node's rotation. This + -- option only applies to the rotation within the face's plane. + -- + -- One of: + -- * "node" (default): Rotated with node. + -- * "world": Always default rotation. + -- * "user": Client setting `world_aligned_mode` will be used, similar to + -- `glasslike_framed_optional`. + -- + -- Supported by solid (TODO: what's solid?) nodes and nodeboxes only. + -- + -- Setting a different value in `overlay_tiles` is not supported. (TODO: test) + + scale = int, + -- Make the tile span several (exactly `scale`) nodes, instead of just one, + -- in each direction. Works for world-aligned tiles only. + -- + -- `0` (default) to disable. + -- + -- Note that as the effect is applied on a per-mapblock (TODO: meshchunk?) + -- basis, `16` should be equally divisible by `scale` or you may get wrong + -- results. (TODO: easy to fix?.) + -- + -- Not supported if used with `visual_scale ~= 1`. (TODO: test) + + color = ColorSpec, + -- The texture's color will be multiplied with this color. + -- + -- Overrides the owning node's color in all cases (`color` nodedef field and + -- node palette color (? TODO)). + + animation = Tile animation definition, + -- If given, tile will be animated over time. + -- + -- See [Tile animation definition]. +} +``` Tile animation definition ------------------------- ```lua +{ + type = "none", +} + { type = "vertical_frames", @@ -9697,7 +9763,7 @@ Tile animation definition -- Height of a frame in pixels length = 3.0, - -- Full loop length + -- Full loop length in seconds } { @@ -9710,7 +9776,7 @@ Tile animation definition -- Height in number of frames frame_length = 0.5, - -- Length of a single frame + -- Length of a single frame in seconds } ``` @@ -9975,8 +10041,12 @@ Used by `core.register_node`. -- on the node. tiles = {tile definition 1, def2, def3, def4, def5, def6}, - -- Textures of node; +Y, -Y, +X, -X, +Z, -Z + -- Textures of node. + -- UV mapping depends on drawtype, see [Node drawtypes]. + -- For `normal` nodes: +Y, -Y, +X, -X, +Z, -Z -- List can be shortened to needed length. + -- 6 is maximum. + -- See [Tile definition]. overlay_tiles = {tile definition 1, def2, def3, def4, def5, def6}, -- Same as `tiles`, but these textures are drawn on top of the base From 41eb6781769bc6012aca7b170b10a3acef39689e Mon Sep 17 00:00:00 2001 From: Desour Date: Sat, 3 May 2025 16:06:17 +0200 Subject: [PATCH 2/4] update --- doc/lua_api.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/doc/lua_api.md b/doc/lua_api.md index cf9eaab3a..6115fb87a 100644 --- a/doc/lua_api.md +++ b/doc/lua_api.md @@ -1583,7 +1583,6 @@ There are a bunch of different looking node types. * Uses models for nodes. * Tiles should hold model materials textures. * Only static meshes are implemented. - * For supported model formats see Irrlicht engine documentation. * `plantlike_rooted` * Enables underwater `plantlike` without air bubbles around the nodes. * Consists of a base cube at the coordinates of the node plus a @@ -9716,9 +9715,10 @@ Long form: -- * "user": Client setting `world_aligned_mode` will be used, similar to -- `glasslike_framed_optional`. -- - -- Supported by solid (TODO: what's solid?) nodes and nodeboxes only. + -- Only supported by drawtypes made of cuboids. -- - -- Setting a different value in `overlay_tiles` is not supported. (TODO: test) + -- Setting a different value in the corresponding `overlay_tiles` tile is not + -- supported. scale = int, -- Make the tile span several (exactly `scale`) nodes, instead of just one, @@ -9726,17 +9726,17 @@ Long form: -- -- `0` (default) to disable. -- - -- Note that as the effect is applied on a per-mapblock (TODO: meshchunk?) - -- basis, `16` should be equally divisible by `scale` or you may get wrong - -- results. (TODO: easy to fix?.) + -- Note that as the effect is applied on a per-meshgen-chunk basis, + -- `16` should be equally divisible by `scale` or you may get wrong results. -- - -- Not supported if used with `visual_scale ~= 1`. (TODO: test) + -- Setting a different value in the corresponding `overlay_tiles` tile is not + -- supported. color = ColorSpec, -- The texture's color will be multiplied with this color. -- -- Overrides the owning node's color in all cases (`color` nodedef field and - -- node palette color (? TODO)). + -- node palette color). animation = Tile animation definition, -- If given, tile will be animated over time. @@ -10061,6 +10061,7 @@ Used by `core.register_node`. color = ColorSpec, -- The node's original color will be multiplied with this color. + -- Acts as a default for the `color` field of this node's TileDefs. -- If the node has a palette, then this setting only has an effect in -- the inventory and on the wield item. From 36118770a105344bfb29b2bb4a9dee6967866bc5 Mon Sep 17 00:00:00 2001 From: Desour Date: Sun, 4 May 2025 21:22:18 +0200 Subject: [PATCH 3/4] tmp --- doc/lua_api.md | 26 +++++++- games/devtest/mods/tiled/init.lua | 104 ++++++++++++++++++++++-------- games/devtest/mods/tiled/mod.conf | 2 +- 3 files changed, 101 insertions(+), 31 deletions(-) diff --git a/doc/lua_api.md b/doc/lua_api.md index 6115fb87a..03eddd3ad 100644 --- a/doc/lua_api.md +++ b/doc/lua_api.md @@ -9684,7 +9684,7 @@ Long form: -- If `true`, faces will only be drawn from one side. -- -- Default: - -- * `false` for drawtypes `plantlike`, `firelike`, `mesh`, and `liquid`. + -- * `false` for drawtypes `plantlike`, `firelike`, `mesh`, and `liquid`. TODO: flowingliquid? -- * `false` for `special_tiles` of drawtype `plantlike_rooted`. -- * `true` otherwise. @@ -9715,7 +9715,29 @@ Long form: -- * "user": Client setting `world_aligned_mode` will be used, similar to -- `glasslike_framed_optional`. -- - -- Only supported by drawtypes made of cuboids. + -- Only supported by the following drawtypes: + -- + -- * `normal` + -- * `liquid` (but not `flowingliquid`) + -- * `glasslike_framed`: Only frame (tile 1). With `paramtype2` + -- `glasslikeliquidlevel`, `special_tiles` also don't support this. + -- * `glasslike_framed_optional`: Same limitations as for `glasslike_framed`. + -- And if the `connected_glass` setting is disabled, it may be drawn like + -- `scale` TODO. + -- * `allfaces` TODO? + -- * `allfaces_optional` TODO? + -- * `torchlike` TODO? + -- * `signlike` TODO? + -- * `plantlike` TODO? + -- * `firelike` TODO? + -- * `fencelike` TODO? + -- * `raillike` TODO? + -- * `nodebox` TODO? + -- * `mesh` TODO? + -- * `plantlike_rooted` (only the cube part) + -- + -- If a drawtype (or part of it) is not supported, don't use this feature, + -- as support may be added in the future. -- -- Setting a different value in the corresponding `overlay_tiles` tile is not -- supported. diff --git a/games/devtest/mods/tiled/init.lua b/games/devtest/mods/tiled/init.lua index ea34ea1b1..e83c90b6a 100644 --- a/games/devtest/mods/tiled/init.lua +++ b/games/devtest/mods/tiled/init.lua @@ -1,38 +1,21 @@ local align_help = "Texture spans over a space of 8×8 nodes" local align_help_n = "Tiles looks the same for every node" -core.register_node("tiled:tiled", { - description = "Tiled Node (world-aligned)".."\n"..align_help, - tiles = {{ - name = "tiled_tiled.png", - align_style = "world", - scale = 8, - }}, - groups = {cracky=3}, -}) +local scaled_tile = { + name = "tiled_tiled.png", + align_style = "world", + scale = 8, +} -core.register_node("tiled:tiled_rooted", { - description = - "Tiled 'plantlike_rooted' Node (world-aligned)".."\n".. - "Base node texture spans over a space of 8×8 nodes".."\n".. - "A plantlike thing grows on top", - paramtype = "light", - drawtype = "plantlike_rooted", - tiles = {{ - name = "tiled_tiled.png", - align_style = "world", - scale = 8, - }}, - special_tiles = {"tiled_tiled_node.png"}, +core.register_node("tiled:tiled", { + description = "Tiled 'normal' Node (world-aligned)".."\n"..align_help, + tiles = {scaled_tile}, groups = {cracky=3}, }) core.register_node("tiled:tiled_n", { - description = "Tiled Node (node-aligned)".."\n"..align_help_n, - tiles = {{ - name = "tiled_tiled_node.png", - align_style = "node", - }}, + description = "Tiled 'normal' Node (node-aligned)".."\n"..align_help_n, + tiles = {{name="tiled_tiled_node.png", align_style="node"}}, groups = {cracky=3}, }) @@ -44,8 +27,73 @@ stairs.register_stair_and_slab("tiled_n", "tiled:tiled_n", stairs.register_stair_and_slab("tiled", "tiled:tiled", {cracky=3}, - {{name="tiled_tiled.png", align_style="world", scale=8}}, + {scaled_tile}, "Tiled Stair (world-aligned)".."\n"..align_help, "Tiled Slab (world-aligned)".."\n"..align_help) +core.register_node("tiled:tiled_liquid", { + description = + "Tiled 'liquid' Node (world-aligned)".."\n".. + align_help.."\n".. + "(waving = 3)", + paramtype = "light", + drawtype = "liquid", + tiles = {scaled_tile}, + groups = {cracky=3}, + waving = 3, + liquidtype = "none", + buildable_to = true, +}) +core.register_node("tiled:tiled_glasslike", { -- broken + description = + "Tiled 'glasslike' Node (world-aligned)".."\n".. + align_help, + paramtype = "light", + paramtype2 = "facedir", + drawtype = "glasslike", + tiles = {scaled_tile}, + groups = {cracky=3}, +}) + +core.register_node("tiled:tiled_glasslike_framed", { + description = + "Tiled 'glasslike_framed' Node (world-aligned)".."\n".. + align_help, + paramtype = "light", + drawtype = "glasslike_framed", + tiles = {scaled_tile, scaled_tile}, + groups = {cracky=3}, +}) + +core.register_node("tiled:tiled_glasslike_framed", { + description = + "Tiled 'glasslike_framed' Node (world-aligned)".."\n".. + align_help, + paramtype = "light", + drawtype = "glasslike_framed", + tiles = {scaled_tile, "testnodes_glasslike_detail.png"}, + groups = {cracky=3}, +}) + +core.register_node("tiled:tiled_glasslike_framed_optional", { + description = + "Tiled 'glasslike_framed_optional' Node (world-aligned)".."\n".. + align_help, + paramtype = "light", + drawtype = "glasslike_framed_optional", + tiles = {scaled_tile, "testnodes_glasslike_detail.png"}, + groups = {cracky=3}, +}) + +core.register_node("tiled:tiled_rooted", { + description = + "Tiled 'plantlike_rooted' Node (world-aligned)".."\n".. + "Base node texture spans over a space of 8×8 nodes".."\n".. + "A plantlike thing grows on top", + paramtype = "light", + drawtype = "plantlike_rooted", + tiles = {scaled_tile}, + special_tiles = {"tiled_tiled_node.png"}, + groups = {cracky=3}, +}) diff --git a/games/devtest/mods/tiled/mod.conf b/games/devtest/mods/tiled/mod.conf index 78b19f93b..b83f51739 100644 --- a/games/devtest/mods/tiled/mod.conf +++ b/games/devtest/mods/tiled/mod.conf @@ -1,3 +1,3 @@ name = tiled description = Add nodes with a special texture that spans multiple nodes (aka "world-aligned") -depends = stairs +depends = stairs, testnodes From 1b848cc551cac1689be5a2f00f7086a6ffa8da42 Mon Sep 17 00:00:00 2001 From: Desour Date: Sun, 4 May 2025 21:57:21 +0200 Subject: [PATCH 4/4] add doc for drawtypes and add more test nodes to `devtest/tiled` --- doc/lua_api.md | 17 +++------ games/devtest/mods/tiled/init.lua | 62 ++++++++++++++++++++++++------- 2 files changed, 54 insertions(+), 25 deletions(-) diff --git a/doc/lua_api.md b/doc/lua_api.md index 03eddd3ad..f7d6f9b5c 100644 --- a/doc/lua_api.md +++ b/doc/lua_api.md @@ -9719,21 +9719,16 @@ Long form: -- -- * `normal` -- * `liquid` (but not `flowingliquid`) + -- * `flowingliquid`: no, TODO + -- * `glasslike`: no, TODO -- * `glasslike_framed`: Only frame (tile 1). With `paramtype2` -- `glasslikeliquidlevel`, `special_tiles` also don't support this. -- * `glasslike_framed_optional`: Same limitations as for `glasslike_framed`. -- And if the `connected_glass` setting is disabled, it may be drawn like - -- `scale` TODO. - -- * `allfaces` TODO? - -- * `allfaces_optional` TODO? - -- * `torchlike` TODO? - -- * `signlike` TODO? - -- * `plantlike` TODO? - -- * `firelike` TODO? - -- * `fencelike` TODO? - -- * `raillike` TODO? - -- * `nodebox` TODO? - -- * `mesh` TODO? + -- only the `1/scale` base tile is drawn. TODO: just support glasslike + -- * `allfaces` + -- * `allfaces_optional`: no, because of leaves_style simple + -- * `nodebox` -- * `plantlike_rooted` (only the cube part) -- -- If a drawtype (or part of it) is not supported, don't use this feature, diff --git a/games/devtest/mods/tiled/init.lua b/games/devtest/mods/tiled/init.lua index e83c90b6a..9a12c77eb 100644 --- a/games/devtest/mods/tiled/init.lua +++ b/games/devtest/mods/tiled/init.lua @@ -41,14 +41,36 @@ core.register_node("tiled:tiled_liquid", { tiles = {scaled_tile}, groups = {cracky=3}, waving = 3, - liquidtype = "none", + liquidtype = "source", + liquid_alternative_flowing = "tiled:tiled_flowingliquid", + liquid_alternative_source = "tiled:tiled_liquid", + liquid_renewable = false, buildable_to = true, }) -core.register_node("tiled:tiled_glasslike", { -- broken +core.register_node("tiled:tiled_flowingliquid", { + description = + "Tiled 'flowingliquid' Node (world-aligned)".."\n".. + "Broken".."\n".. + "(waving = 3)", + paramtype = "light", + paramtype2 = "flowingliquid", + drawtype = "flowingliquid", + tiles = {scaled_tile}, + special_tiles = {scaled_tile, scaled_tile}, + groups = {cracky=3}, + waving = 3, + liquidtype = "flowing", + liquid_alternative_flowing = "tiled:tiled_flowingliquid", + liquid_alternative_source = "tiled:tiled_liquid", + liquid_renewable = false, + buildable_to = true, +}) + +core.register_node("tiled:tiled_glasslike", { description = "Tiled 'glasslike' Node (world-aligned)".."\n".. - align_help, + "Broken", paramtype = "light", paramtype2 = "facedir", drawtype = "glasslike", @@ -66,26 +88,38 @@ core.register_node("tiled:tiled_glasslike_framed", { groups = {cracky=3}, }) -core.register_node("tiled:tiled_glasslike_framed", { - description = - "Tiled 'glasslike_framed' Node (world-aligned)".."\n".. - align_help, - paramtype = "light", - drawtype = "glasslike_framed", - tiles = {scaled_tile, "testnodes_glasslike_detail.png"}, - groups = {cracky=3}, -}) - core.register_node("tiled:tiled_glasslike_framed_optional", { description = "Tiled 'glasslike_framed_optional' Node (world-aligned)".."\n".. align_help, paramtype = "light", drawtype = "glasslike_framed_optional", - tiles = {scaled_tile, "testnodes_glasslike_detail.png"}, + tiles = {scaled_tile, "testnodes_glasslike_detail.png"}, --TODO: tiled detail png groups = {cracky=3}, }) +core.register_node("tiled:tiled_allfaces", { + description = + "Tiled 'allfaces' Node (world-aligned)".."\n".. + align_help.."\n", + paramtype = "light", + drawtype = "allfaces", + tiles = {scaled_tile}, + groups = {cracky=3}, +}) + +core.register_node("tiled:tiled_allfaces_optional", { + description = + "Tiled 'allfaces_optional' Node (world-aligned)".."\n".. + "Broken for leaves_style = simple".."\n".. + "(waving = 2)", + paramtype = "light", + drawtype = "allfaces_optional", + tiles = {scaled_tile}, + groups = {cracky=3}, + waving = 2, +}) + core.register_node("tiled:tiled_rooted", { description = "Tiled 'plantlike_rooted' Node (world-aligned)".."\n"..