Skip to content

Commit 21113ad

Browse files
authored
Split liquid_viscosity to liquid_viscosity and move_resistance (#10810)
1 parent f504070 commit 21113ad

File tree

15 files changed

+289
-45
lines changed

15 files changed

+289
-45
lines changed

doc/client_lua_api.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,8 +1030,8 @@ Methods:
10301030
* returns true if player is in a liquid (This oscillates so that the player jumps a bit above the surface)
10311031
* `is_in_liquid_stable()`
10321032
* returns true if player is in a stable liquid (This is more stable and defines the maximum speed of the player)
1033-
* `get_liquid_viscosity()`
1034-
* returns liquid viscosity (Gets the viscosity of liquid to calculate friction)
1033+
* `get_move_resistance()`
1034+
* returns move resistance of current node, the higher the slower the player moves
10351035
* `is_climbing()`
10361036
* returns true if player is climbing
10371037
* `swimming_vertical()`
@@ -1233,7 +1233,7 @@ It can be created via `Raycast(pos1, pos2, objects, liquids)` or
12331233
liquid_type = <string>, -- A string containing "none", "flowing", or "source" *May not exist*
12341234
liquid_alternative_flowing = <string>, -- Alternative node for liquid *May not exist*
12351235
liquid_alternative_source = <string>, -- Alternative node for liquid *May not exist*
1236-
liquid_viscosity = <number>, -- How fast the liquid flows *May not exist*
1236+
liquid_viscosity = <number>, -- How slow the liquid flows *May not exist*
12371237
liquid_renewable = <boolean>, -- Whether the liquid makes an infinite source *May not exist*
12381238
liquid_range = <number>, -- How far the liquid flows *May not exist*
12391239
drowning = bool, -- Whether the player will drown in the node
@@ -1248,6 +1248,7 @@ It can be created via `Raycast(pos1, pos2, objects, liquids)` or
12481248
},
12491249
legacy_facedir_simple = bool, -- Whether to use old facedir
12501250
legacy_wallmounted = bool -- Whether to use old wallmounted
1251+
move_resistance = <number>, -- How slow players can move through the node *May not exist*
12511252
}
12521253
```
12531254

doc/lua_api.txt

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,7 +1804,7 @@ to games.
18041804
- (14) -- constant tolerance
18051805
Negative damage values are discarded as no damage.
18061806
* `falling_node`: if there is no walkable block under the node it will fall
1807-
* `float`: the node will not fall through liquids
1807+
* `float`: the node will not fall through liquids (`liquidtype ~= "none"`)
18081808
* `level`: Can be used to give an additional sense of progression in the game.
18091809
* A larger level will cause e.g. a weapon of a lower level make much less
18101810
damage, and get worn out much faster, or not be able to get drops
@@ -4147,7 +4147,7 @@ differences:
41474147

41484148
### Other API functions operating on a VoxelManip
41494149

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

69836985
### Methods
69846986

@@ -7462,6 +7464,8 @@ Used by `minetest.register_node`, `minetest.register_craftitem`, and
74627464
range = 4.0,
74637465

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

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

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

7654+
move_resistance = 0,
7655+
-- Slows down movement of players through this node (max. 7).
7656+
-- If this is nil, it will be equal to liquid_viscosity.
7657+
-- Note: If liquid movement physics apply to the node
7658+
-- (see `liquid_move_physics`), the movement speed will also be
7659+
-- affected by the `movement_liquid_*` settings.
7660+
76507661
buildable_to = false, -- If true, placed nodes can replace this node
76517662

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

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

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

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

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

7692+
liquid_move_physics = nil, -- specifies movement physics if inside node
7693+
-- * false: No liquid movement physics apply.
7694+
-- * true: Enables liquid movement physics. Enables things like
7695+
-- ability to "swim" up/down, sinking slowly if not moving,
7696+
-- smoother speed change when falling into, etc. The `movement_liquid_*`
7697+
-- settings apply.
7698+
-- * nil: Will be treated as true if `liquidype ~= "none"`
7699+
-- and as false otherwise.
7700+
-- Default: nil
7701+
76777702
leveled = 0,
76787703
-- Only valid for "nodebox" drawtype with 'type = "leveled"'.
76797704
-- Allows defining the nodebox height without using param2.

games/devtest/mods/testnodes/liquids.lua

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ for d=0, 8 do
4040
liquid_range = d,
4141
})
4242

43+
if d <= 7 then
44+
4345
local mod = "^[colorize:#000000:127"
4446
minetest.register_node("testnodes:vliquid_"..d, {
45-
description = "Test Liquid Source, Viscosity "..d,
47+
description = "Test Liquid Source, Viscosity/Resistance "..d,
4648
drawtype = "liquid",
4749
tiles = {"testnodes_liquidsource_r"..d..".png"..mod},
4850
special_tiles = {
@@ -61,7 +63,7 @@ for d=0, 8 do
6163
})
6264

6365
minetest.register_node("testnodes:vliquid_flowing_"..d, {
64-
description = "Flowing Test Liquid, Viscosity "..d,
66+
description = "Flowing Test Liquid, Viscosity/Resistance "..d,
6567
drawtype = "flowingliquid",
6668
tiles = {"testnodes_liquidflowing_r"..d..".png"..mod},
6769
special_tiles = {
@@ -80,4 +82,53 @@ for d=0, 8 do
8082
liquid_viscosity = d,
8183
})
8284

85+
mod = "^[colorize:#000000:192"
86+
local v = 4
87+
minetest.register_node("testnodes:vrliquid_"..d, {
88+
description = "Test Liquid Source, Viscosity "..v..", Resistance "..d,
89+
drawtype = "liquid",
90+
tiles = {"testnodes_liquidsource_r"..d..".png"..mod},
91+
special_tiles = {
92+
{name = "testnodes_liquidsource_r"..d..".png"..mod, backface_culling = false},
93+
{name = "testnodes_liquidsource_r"..d..".png"..mod, backface_culling = true},
94+
},
95+
use_texture_alpha = "blend",
96+
paramtype = "light",
97+
walkable = false,
98+
pointable = false,
99+
diggable = false,
100+
buildable_to = true,
101+
is_ground_content = false,
102+
liquidtype = "source",
103+
liquid_alternative_flowing = "testnodes:vrliquid_flowing_"..d,
104+
liquid_alternative_source = "testnodes:vrliquid_"..d,
105+
liquid_viscosity = v,
106+
move_resistance = d,
107+
})
108+
109+
minetest.register_node("testnodes:vrliquid_flowing_"..d, {
110+
description = "Flowing Test Liquid, Viscosity "..v..", Resistance "..d,
111+
drawtype = "flowingliquid",
112+
tiles = {"testnodes_liquidflowing_r"..d..".png"..mod},
113+
special_tiles = {
114+
{name = "testnodes_liquidflowing_r"..d..".png"..mod, backface_culling = false},
115+
{name = "testnodes_liquidflowing_r"..d..".png"..mod, backface_culling = false},
116+
},
117+
use_texture_alpha = "blend",
118+
paramtype = "light",
119+
paramtype2 = "flowingliquid",
120+
walkable = false,
121+
pointable = false,
122+
diggable = false,
123+
buildable_to = true,
124+
is_ground_content = false,
125+
liquidtype = "flowing",
126+
liquid_alternative_flowing = "testnodes:vrliquid_flowing_"..d,
127+
liquid_alternative_source = "testnodes:vrliquid_"..d,
128+
liquid_viscosity = v,
129+
move_resistance = d,
130+
})
131+
132+
end
133+
83134
end

games/devtest/mods/testnodes/properties.lua

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,66 @@ minetest.register_node("testnodes:liquidflowing_nojump", {
152152
post_effect_color = {a = 70, r = 255, g = 0, b = 200},
153153
})
154154

155+
-- A liquid which doesn't have liquid movement physics (source variant)
156+
minetest.register_node("testnodes:liquid_noswim", {
157+
description = S("No-swim Liquid Source Node"),
158+
liquidtype = "source",
159+
liquid_range = 1,
160+
liquid_viscosity = 0,
161+
liquid_alternative_flowing = "testnodes:liquidflowing_noswim",
162+
liquid_alternative_source = "testnodes:liquid_noswim",
163+
liquid_renewable = false,
164+
liquid_move_physics = false,
165+
groups = {dig_immediate=3},
166+
walkable = false,
167+
168+
drawtype = "liquid",
169+
tiles = {"testnodes_liquidsource.png^[colorize:#FF00FF:127"},
170+
special_tiles = {
171+
{name = "testnodes_liquidsource.png^[colorize:#FF00FF:127", backface_culling = false},
172+
{name = "testnodes_liquidsource.png^[colorize:#FF00FF:127", backface_culling = true},
173+
},
174+
use_texture_alpha = "blend",
175+
paramtype = "light",
176+
pointable = false,
177+
liquids_pointable = true,
178+
buildable_to = true,
179+
is_ground_content = false,
180+
post_effect_color = {a = 70, r = 255, g = 200, b = 200},
181+
})
182+
183+
-- A liquid which doen't have liquid movement physics (flowing variant)
184+
minetest.register_node("testnodes:liquidflowing_noswim", {
185+
description = S("No-swim Flowing Liquid Node"),
186+
liquidtype = "flowing",
187+
liquid_range = 1,
188+
liquid_viscosity = 0,
189+
liquid_alternative_flowing = "testnodes:liquidflowing_noswim",
190+
liquid_alternative_source = "testnodes:liquid_noswim",
191+
liquid_renewable = false,
192+
liquid_move_physics = false,
193+
groups = {dig_immediate=3},
194+
walkable = false,
195+
196+
197+
drawtype = "flowingliquid",
198+
tiles = {"testnodes_liquidflowing.png^[colorize:#FF00FF:127"},
199+
special_tiles = {
200+
{name = "testnodes_liquidflowing.png^[colorize:#FF00FF:127", backface_culling = false},
201+
{name = "testnodes_liquidflowing.png^[colorize:#FF00FF:127", backface_culling = false},
202+
},
203+
use_texture_alpha = "blend",
204+
paramtype = "light",
205+
paramtype2 = "flowingliquid",
206+
pointable = false,
207+
liquids_pointable = true,
208+
buildable_to = true,
209+
is_ground_content = false,
210+
post_effect_color = {a = 70, r = 255, g = 200, b = 200},
211+
})
212+
213+
214+
155215
-- Nodes that modify fall damage (various damage modifiers)
156216
for i=-100, 100, 25 do
157217
if i ~= 0 then
@@ -216,6 +276,54 @@ for i=1, 5 do
216276
})
217277
end
218278

279+
-- Move resistance nodes (various resistance levels)
280+
for r=0, 7 do
281+
if r > 0 then
282+
minetest.register_node("testnodes:move_resistance"..r, {
283+
description = S("Move-resistant Node (@1)", r),
284+
walkable = false,
285+
move_resistance = r,
286+
287+
drawtype = "glasslike",
288+
paramtype = "light",
289+
sunlight_propagates = true,
290+
tiles = { "testnodes_move_resistance.png" },
291+
is_ground_content = false,
292+
groups = { dig_immediate = 3 },
293+
color = { b = 0, g = 255, r = math.floor((r/7)*255), a = 255 },
294+
})
295+
end
296+
297+
minetest.register_node("testnodes:move_resistance_liquidlike"..r, {
298+
description = S("Move-resistant Node, liquidlike (@1)", r),
299+
walkable = false,
300+
move_resistance = r,
301+
liquid_move_physics = true,
302+
303+
drawtype = "glasslike",
304+
paramtype = "light",
305+
sunlight_propagates = true,
306+
tiles = { "testnodes_move_resistance.png" },
307+
is_ground_content = false,
308+
groups = { dig_immediate = 3 },
309+
color = { b = 255, g = 0, r = math.floor((r/7)*255), a = 255 },
310+
})
311+
end
312+
313+
minetest.register_node("testnodes:climbable_move_resistance_4", {
314+
description = S("Climbable Move-resistant Node (4)"),
315+
walkable = false,
316+
climbable = true,
317+
move_resistance = 4,
318+
319+
drawtype = "glasslike",
320+
paramtype = "light",
321+
sunlight_propagates = true,
322+
tiles = {"testnodes_climbable_resistance_side.png"},
323+
is_ground_content = false,
324+
groups = { dig_immediate = 3 },
325+
})
326+
219327
-- By placing something on the node, the node itself will be replaced
220328
minetest.register_node("testnodes:buildable_to", {
221329
description = S("Replacable Node"),
295 Bytes
Loading
221 Bytes
Loading

0 commit comments

Comments
 (0)