mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Merge 3118efdf1c
into 2d36d32da8
This commit is contained in:
commit
cc6b91ff7b
4 changed files with 45 additions and 0 deletions
29
builtin/game/default_physics.lua
Normal file
29
builtin/game/default_physics.lua
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
-- Minetest: builtin/game/default_physics.lua
|
||||||
|
|
||||||
|
-- DEFAULT_PHYSICS variable of a player
|
||||||
|
core.DEFAULT_PHYSICS = {
|
||||||
|
speed = 1,
|
||||||
|
speed_walk = 1,
|
||||||
|
speed_climb = 1,
|
||||||
|
speed_crouch = 1,
|
||||||
|
speed_fast = 1,
|
||||||
|
|
||||||
|
jump = 1,
|
||||||
|
gravity = 1,
|
||||||
|
|
||||||
|
liquid_fluidity = 1,
|
||||||
|
liquid_fluidity_smooth = 1,
|
||||||
|
liquid_sink = 1,
|
||||||
|
|
||||||
|
acceleration_default = 1,
|
||||||
|
acceleration_air = 1,
|
||||||
|
acceleration_fast = 1,
|
||||||
|
|
||||||
|
sneak = true,
|
||||||
|
sneak_glitch = false,
|
||||||
|
new_move = true,
|
||||||
|
}
|
||||||
|
|
||||||
|
core.register_on_joinplayer(function(player)
|
||||||
|
player:set_physics_override(core.DEFAULT_PHYSICS)
|
||||||
|
end)
|
|
@ -30,6 +30,7 @@ dofile(commonpath .. "chatcommands.lua")
|
||||||
dofile(gamepath .. "chat.lua")
|
dofile(gamepath .. "chat.lua")
|
||||||
dofile(commonpath .. "information_formspecs.lua")
|
dofile(commonpath .. "information_formspecs.lua")
|
||||||
dofile(gamepath .. "static_spawn.lua")
|
dofile(gamepath .. "static_spawn.lua")
|
||||||
|
dofile(gamepath .. "default_physics.lua")
|
||||||
dofile(gamepath .. "detached_inventory.lua")
|
dofile(gamepath .. "detached_inventory.lua")
|
||||||
assert(loadfile(gamepath .. "falling.lua"))(builtin_shared)
|
assert(loadfile(gamepath .. "falling.lua"))(builtin_shared)
|
||||||
dofile(gamepath .. "features.lua")
|
dofile(gamepath .. "features.lua")
|
||||||
|
|
|
@ -8706,6 +8706,7 @@ child will follow movement and rotation of that bone.
|
||||||
* Returns `0` (no bits set) if the object is not a player.
|
* Returns `0` (no bits set) if the object is not a player.
|
||||||
* `set_physics_override(override_table)`
|
* `set_physics_override(override_table)`
|
||||||
* Overrides the physics attributes of the player
|
* Overrides the physics attributes of the player
|
||||||
|
* `core.DEFAULT_PHYSICS` contains the default values.
|
||||||
* `override_table` is a table with the following fields:
|
* `override_table` is a table with the following fields:
|
||||||
* `speed`: multiplier to *all* movement speed (`speed_*`) and
|
* `speed`: multiplier to *all* movement speed (`speed_*`) and
|
||||||
acceleration (`acceleration_*`) values (default: `1`)
|
acceleration (`acceleration_*`) values (default: `1`)
|
||||||
|
|
|
@ -204,3 +204,17 @@ local function run_player_hotbar_clamp_tests(player)
|
||||||
player:hud_set_hotbar_itemcount(old_bar_size)
|
player:hud_set_hotbar_itemcount(old_bar_size)
|
||||||
end
|
end
|
||||||
unittests.register("test_player_hotbar_clamp", run_player_hotbar_clamp_tests, {player=true})
|
unittests.register("test_player_hotbar_clamp", run_player_hotbar_clamp_tests, {player=true})
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Player defaults physics
|
||||||
|
--
|
||||||
|
core.DEFAULT_PHYSICS.speed = 2 -- Slightly change
|
||||||
|
local function run_player_default_physics_tests(player)
|
||||||
|
local player_overrides = player:get_physics_override()
|
||||||
|
assert(player_overrides.speed == 2)
|
||||||
|
-- Revert everything
|
||||||
|
core.DEFAULT_PHYSICS.speed = 1
|
||||||
|
player_overrides.speed = 1
|
||||||
|
player:set_physics_override(player_overrides)
|
||||||
|
end
|
||||||
|
unittests.register("test_player_default_physics", run_player_default_physics_tests, {player=true})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue