minetest_modding_book/chapters/player_physics.md

63 lines
2.1 KiB
Markdown
Raw Permalink Normal View History

2015-01-24 11:05:38 -08:00
---
title: Player Physics
layout: default
root: ../
---
2015-02-22 02:28:37 -08:00
## Introduction
2015-01-24 11:05:38 -08:00
Player physics can be modified using physics overrides. Physics overrides can set the
walking speed, jump speed and gravity constants. Physics overrides are set on a player
by player basis, and are multipliers - a value of 2 for gravity would make gravity twice
as strong.
* Basic Interface
* Your Turn
2015-02-22 02:28:37 -08:00
## Basic Interface
2015-01-24 11:05:38 -08:00
Here is an example which adds an antigravity command, which
puts the caller in low G:
{% highlight lua %}
minetest.register_chatcommand("antigravity",
func = function(name, param)
local player = minetest.get_player_by_name(name)
player:set_physics_override({
gravity = 0.1 -- set gravity to 10% of its original value
-- (0.1 * 9.81)
})
end
})
{% endhighlight %}
### Possible Overrides
player:set_physics_override() is given a table of overrides.\\
2015-01-27 01:20:08 -08:00
According to [lua_api.txt](../lua_api.html#player-only-no-op-for-other-objects),
2015-01-24 11:05:38 -08:00
these can be:
* speed: multiplier to default walking speed value (default: 1)
* jump: multiplier to default jump value (default: 1)
* gravity: multiplier to default gravity value (default: 1)
* sneak: whether player can sneak (default: true)
* sneak_glitch: whether player can use the sneak glitch (default: true)
The sneak glitch allows the player to climb an 'elevator' made out of
a certain placement of blocks by sneaking (pressing shift) and pressing
space to ascend. It was originally a bug in Minetest, but was kept as
it is used on many servers to get to higher levels.
They added the option above so you can disable it.
### Multiple mods
Please be warned that mods that override the physics of a player tend
to be incompatible with each other. When setting an override, it overwrites
and override that has been set before, by your or anyone else's mod.
2015-02-22 02:28:37 -08:00
## Your Turn
2015-01-24 11:05:38 -08:00
* **sonic**: Set the speed multiplayer to a high value (at least 6) when a player joins the game.
* **super bounce**: Increase the jump value so that the player can jump up 20 meters (1 meter is 1 block).
* **space**: Make the gravity decrease the the player gets higher and higher up.