Navigation Menu

Skip to content

Commit

Permalink
Split liquid_viscosity to liquid_viscosity and move_resistance (#10810)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wuzzy2 committed Oct 1, 2021
1 parent f504070 commit 21113ad
Show file tree
Hide file tree
Showing 15 changed files with 289 additions and 45 deletions.
7 changes: 4 additions & 3 deletions doc/client_lua_api.txt
Expand Up @@ -1030,8 +1030,8 @@ Methods:
* returns true if player is in a liquid (This oscillates so that the player jumps a bit above the surface)
* `is_in_liquid_stable()`
* returns true if player is in a stable liquid (This is more stable and defines the maximum speed of the player)
* `get_liquid_viscosity()`
* returns liquid viscosity (Gets the viscosity of liquid to calculate friction)
* `get_move_resistance()`
* returns move resistance of current node, the higher the slower the player moves
* `is_climbing()`
* returns true if player is climbing
* `swimming_vertical()`
Expand Down Expand Up @@ -1233,7 +1233,7 @@ It can be created via `Raycast(pos1, pos2, objects, liquids)` or
liquid_type = <string>, -- A string containing "none", "flowing", or "source" *May not exist*
liquid_alternative_flowing = <string>, -- Alternative node for liquid *May not exist*
liquid_alternative_source = <string>, -- Alternative node for liquid *May not exist*
liquid_viscosity = <number>, -- How fast the liquid flows *May not exist*
liquid_viscosity = <number>, -- How slow the liquid flows *May not exist*
liquid_renewable = <boolean>, -- Whether the liquid makes an infinite source *May not exist*
liquid_range = <number>, -- How far the liquid flows *May not exist*
drowning = bool, -- Whether the player will drown in the node
Expand All @@ -1248,6 +1248,7 @@ It can be created via `Raycast(pos1, pos2, objects, liquids)` or
},
legacy_facedir_simple = bool, -- Whether to use old facedir
legacy_wallmounted = bool -- Whether to use old wallmounted
move_resistance = <number>, -- How slow players can move through the node *May not exist*
}
```

Expand Down
45 changes: 35 additions & 10 deletions doc/lua_api.txt
Expand Up @@ -1804,7 +1804,7 @@ to games.
- (14) -- constant tolerance
Negative damage values are discarded as no damage.
* `falling_node`: if there is no walkable block under the node it will fall
* `float`: the node will not fall through liquids
* `float`: the node will not fall through liquids (`liquidtype ~= "none"`)
* `level`: Can be used to give an additional sense of progression in the game.
* A larger level will cause e.g. a weapon of a lower level make much less
damage, and get worn out much faster, or not be able to get drops
Expand Down Expand Up @@ -4147,7 +4147,7 @@ differences:

### Other API functions operating on a VoxelManip

If any VoxelManip contents were set to a liquid node,
If any VoxelManip contents were set to a liquid node (`liquidtype ~= "none"`),
`VoxelManip:update_liquids()` must be called for these liquid nodes to begin
flowing. It is recommended to call this function only after having written all
buffered data back to the VoxelManip object, save for special situations where
Expand Down Expand Up @@ -4958,8 +4958,8 @@ Call these functions only at load time!
* You should have joined some channels to receive events.
* If message comes from a server mod, `sender` field is an empty string.
* `minetest.register_on_liquid_transformed(function(pos_list, node_list))`
* Called after liquid nodes are modified by the engine's liquid transformation
process.
* Called after liquid nodes (`liquidtype ~= "none"`) are modified by the
engine's liquid transformation process.
* `pos_list` is an array of all modified positions.
* `node_list` is an array of the old node that was previously at the position
with the corresponding index in pos_list.
Expand Down Expand Up @@ -5301,7 +5301,8 @@ Environment access
* `pos1`: start of the ray
* `pos2`: end of the ray
* `objects`: if false, only nodes will be returned. Default is `true`.
* `liquids`: if false, liquid nodes won't be returned. Default is `false`.
* `liquids`: if false, liquid nodes (`liquidtype ~= "none"`) won't be
returned. Default is `false`.
* `minetest.find_path(pos1,pos2,searchdistance,max_jump,max_drop,algorithm)`
* returns table containing path that can be walked on
* returns a table of 3D points representing a path from `pos1` to `pos2` or
Expand All @@ -5325,7 +5326,7 @@ Environment access
* `minetest.spawn_tree (pos, {treedef})`
* spawns L-system tree at given `pos` with definition in `treedef` table
* `minetest.transforming_liquid_add(pos)`
* add node to liquid update queue
* add node to liquid flow update queue
* `minetest.get_node_max_level(pos)`
* get max available level for leveled node
* `minetest.get_node_level(pos)`
Expand Down Expand Up @@ -6978,7 +6979,8 @@ It can be created via `Raycast(pos1, pos2, objects, liquids)` or
* `pos1`: start of the ray
* `pos2`: end of the ray
* `objects`: if false, only nodes will be returned. Default is true.
* `liquids`: if false, liquid nodes won't be returned. Default is false.
* `liquids`: if false, liquid nodes (`liquidtype ~= "none"`) won't be
returned. Default is false.

### Methods

Expand Down Expand Up @@ -7462,6 +7464,8 @@ Used by `minetest.register_node`, `minetest.register_craftitem`, and
range = 4.0,

liquids_pointable = false,
-- If true, item points to all liquid nodes (`liquidtype ~= "none"`),
-- even those for which `pointable = false`

light_source = 0,
-- When used for nodes: Defines amount of light emitted by node.
Expand Down Expand Up @@ -7647,14 +7651,21 @@ Used by `minetest.register_node`.

climbable = false, -- If true, can be climbed on (ladder)

move_resistance = 0,
-- Slows down movement of players through this node (max. 7).
-- If this is nil, it will be equal to liquid_viscosity.
-- Note: If liquid movement physics apply to the node
-- (see `liquid_move_physics`), the movement speed will also be
-- affected by the `movement_liquid_*` settings.

buildable_to = false, -- If true, placed nodes can replace this node

floodable = false,
-- If true, liquids flow into and replace this node.
-- Warning: making a liquid node 'floodable' will cause problems.

liquidtype = "none", -- specifies liquid physics
-- * "none": no liquid physics
liquidtype = "none", -- specifies liquid flowing physics
-- * "none": no liquid flowing physics
-- * "source": spawns flowing liquid nodes at all 4 sides and below;
-- recommended drawtype: "liquid".
-- * "flowing": spawned from source, spawns more flowing liquid nodes
Expand All @@ -7668,12 +7679,26 @@ Used by `minetest.register_node`.

liquid_alternative_source = "", -- Source version of flowing liquid

liquid_viscosity = 0, -- Higher viscosity = slower flow (max. 7)
liquid_viscosity = 0,
-- Controls speed at which the liquid spreads/flows (max. 7).
-- 0 is fastest, 7 is slowest.
-- By default, this also slows down movement of players inside the node
-- (can be overridden using `move_resistance`)

liquid_renewable = true,
-- If true, a new liquid source can be created by placing two or more
-- sources nearby

liquid_move_physics = nil, -- specifies movement physics if inside node
-- * false: No liquid movement physics apply.
-- * true: Enables liquid movement physics. Enables things like
-- ability to "swim" up/down, sinking slowly if not moving,
-- smoother speed change when falling into, etc. The `movement_liquid_*`
-- settings apply.
-- * nil: Will be treated as true if `liquidype ~= "none"`
-- and as false otherwise.
-- Default: nil

leveled = 0,
-- Only valid for "nodebox" drawtype with 'type = "leveled"'.
-- Allows defining the nodebox height without using param2.
Expand Down
55 changes: 53 additions & 2 deletions games/devtest/mods/testnodes/liquids.lua
Expand Up @@ -40,9 +40,11 @@ for d=0, 8 do
liquid_range = d,
})

if d <= 7 then

local mod = "^[colorize:#000000:127"
minetest.register_node("testnodes:vliquid_"..d, {
description = "Test Liquid Source, Viscosity "..d,
description = "Test Liquid Source, Viscosity/Resistance "..d,
drawtype = "liquid",
tiles = {"testnodes_liquidsource_r"..d..".png"..mod},
special_tiles = {
Expand All @@ -61,7 +63,7 @@ for d=0, 8 do
})

minetest.register_node("testnodes:vliquid_flowing_"..d, {
description = "Flowing Test Liquid, Viscosity "..d,
description = "Flowing Test Liquid, Viscosity/Resistance "..d,
drawtype = "flowingliquid",
tiles = {"testnodes_liquidflowing_r"..d..".png"..mod},
special_tiles = {
Expand All @@ -80,4 +82,53 @@ for d=0, 8 do
liquid_viscosity = d,
})

mod = "^[colorize:#000000:192"
local v = 4
minetest.register_node("testnodes:vrliquid_"..d, {
description = "Test Liquid Source, Viscosity "..v..", Resistance "..d,
drawtype = "liquid",
tiles = {"testnodes_liquidsource_r"..d..".png"..mod},
special_tiles = {
{name = "testnodes_liquidsource_r"..d..".png"..mod, backface_culling = false},
{name = "testnodes_liquidsource_r"..d..".png"..mod, backface_culling = true},
},
use_texture_alpha = "blend",
paramtype = "light",
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
is_ground_content = false,
liquidtype = "source",
liquid_alternative_flowing = "testnodes:vrliquid_flowing_"..d,
liquid_alternative_source = "testnodes:vrliquid_"..d,
liquid_viscosity = v,
move_resistance = d,
})

minetest.register_node("testnodes:vrliquid_flowing_"..d, {
description = "Flowing Test Liquid, Viscosity "..v..", Resistance "..d,
drawtype = "flowingliquid",
tiles = {"testnodes_liquidflowing_r"..d..".png"..mod},
special_tiles = {
{name = "testnodes_liquidflowing_r"..d..".png"..mod, backface_culling = false},
{name = "testnodes_liquidflowing_r"..d..".png"..mod, backface_culling = false},
},
use_texture_alpha = "blend",
paramtype = "light",
paramtype2 = "flowingliquid",
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
is_ground_content = false,
liquidtype = "flowing",
liquid_alternative_flowing = "testnodes:vrliquid_flowing_"..d,
liquid_alternative_source = "testnodes:vrliquid_"..d,
liquid_viscosity = v,
move_resistance = d,
})

end

end
108 changes: 108 additions & 0 deletions games/devtest/mods/testnodes/properties.lua
Expand Up @@ -152,6 +152,66 @@ minetest.register_node("testnodes:liquidflowing_nojump", {
post_effect_color = {a = 70, r = 255, g = 0, b = 200},
})

-- A liquid which doesn't have liquid movement physics (source variant)
minetest.register_node("testnodes:liquid_noswim", {
description = S("No-swim Liquid Source Node"),
liquidtype = "source",
liquid_range = 1,
liquid_viscosity = 0,
liquid_alternative_flowing = "testnodes:liquidflowing_noswim",
liquid_alternative_source = "testnodes:liquid_noswim",
liquid_renewable = false,
liquid_move_physics = false,
groups = {dig_immediate=3},
walkable = false,

drawtype = "liquid",
tiles = {"testnodes_liquidsource.png^[colorize:#FF00FF:127"},
special_tiles = {
{name = "testnodes_liquidsource.png^[colorize:#FF00FF:127", backface_culling = false},
{name = "testnodes_liquidsource.png^[colorize:#FF00FF:127", backface_culling = true},
},
use_texture_alpha = "blend",
paramtype = "light",
pointable = false,
liquids_pointable = true,
buildable_to = true,
is_ground_content = false,
post_effect_color = {a = 70, r = 255, g = 200, b = 200},
})

-- A liquid which doen't have liquid movement physics (flowing variant)
minetest.register_node("testnodes:liquidflowing_noswim", {
description = S("No-swim Flowing Liquid Node"),
liquidtype = "flowing",
liquid_range = 1,
liquid_viscosity = 0,
liquid_alternative_flowing = "testnodes:liquidflowing_noswim",
liquid_alternative_source = "testnodes:liquid_noswim",
liquid_renewable = false,
liquid_move_physics = false,
groups = {dig_immediate=3},
walkable = false,


drawtype = "flowingliquid",
tiles = {"testnodes_liquidflowing.png^[colorize:#FF00FF:127"},
special_tiles = {
{name = "testnodes_liquidflowing.png^[colorize:#FF00FF:127", backface_culling = false},
{name = "testnodes_liquidflowing.png^[colorize:#FF00FF:127", backface_culling = false},
},
use_texture_alpha = "blend",
paramtype = "light",
paramtype2 = "flowingliquid",
pointable = false,
liquids_pointable = true,
buildable_to = true,
is_ground_content = false,
post_effect_color = {a = 70, r = 255, g = 200, b = 200},
})



-- Nodes that modify fall damage (various damage modifiers)
for i=-100, 100, 25 do
if i ~= 0 then
Expand Down Expand Up @@ -216,6 +276,54 @@ for i=1, 5 do
})
end

-- Move resistance nodes (various resistance levels)
for r=0, 7 do
if r > 0 then
minetest.register_node("testnodes:move_resistance"..r, {
description = S("Move-resistant Node (@1)", r),
walkable = false,
move_resistance = r,

drawtype = "glasslike",
paramtype = "light",
sunlight_propagates = true,
tiles = { "testnodes_move_resistance.png" },
is_ground_content = false,
groups = { dig_immediate = 3 },
color = { b = 0, g = 255, r = math.floor((r/7)*255), a = 255 },
})
end

minetest.register_node("testnodes:move_resistance_liquidlike"..r, {
description = S("Move-resistant Node, liquidlike (@1)", r),
walkable = false,
move_resistance = r,
liquid_move_physics = true,

drawtype = "glasslike",
paramtype = "light",
sunlight_propagates = true,
tiles = { "testnodes_move_resistance.png" },
is_ground_content = false,
groups = { dig_immediate = 3 },
color = { b = 255, g = 0, r = math.floor((r/7)*255), a = 255 },
})
end

minetest.register_node("testnodes:climbable_move_resistance_4", {
description = S("Climbable Move-resistant Node (4)"),
walkable = false,
climbable = true,
move_resistance = 4,

drawtype = "glasslike",
paramtype = "light",
sunlight_propagates = true,
tiles = {"testnodes_climbable_resistance_side.png"},
is_ground_content = false,
groups = { dig_immediate = 3 },
})

-- By placing something on the node, the node itself will be replaced
minetest.register_node("testnodes:buildable_to", {
description = S("Replacable Node"),
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 21113ad

Please sign in to comment.