player_physics/README.md

33 lines
953 B
Markdown
Raw Normal View History

2019-08-23 02:56:10 +02:00
# Player Physics
2017-04-06 21:08:44 +02:00
A minetest mod to centralize the management of player's stats(sprint, jump, gravity)
2017-04-06 21:15:59 +02:00
Because many mods (sprint, 3d_armor and others) rewrite the stats in their corner and it cancel
2019-08-23 02:56:10 +02:00
## API
2017-04-06 23:11:46 +02:00
2019-08-23 02:57:43 +02:00
- `player_physics.set_stats(player, "uniq_name", table)`
2017-04-06 23:11:46 +02:00
2019-08-23 02:57:43 +02:00
- `layer_physics.remove_stats(player, "uniq_name")`
2017-04-06 21:15:59 +02:00
2019-08-23 02:56:10 +02:00
## API examples
2017-04-06 21:15:59 +02:00
2019-08-23 02:57:43 +02:00
- `player_physics.set_stats(player, "potion_speedlvl1", {speed=0.35})`
2017-04-06 21:15:59 +02:00
2019-08-23 02:57:43 +02:00
- `player_physics.set_stats(player, "sprint_mod", {speed=0.35, jump=0.1})`
2017-04-06 21:15:59 +02:00
2019-08-23 02:57:43 +02:00
- `player_physics.remove_stats(player, "potion_speedlvl1")`
2017-04-06 21:15:59 +02:00
2019-08-23 02:56:10 +02:00
## Temporary effect
2017-04-06 21:15:59 +02:00
2019-08-23 02:57:43 +02:00
- `player_physics.add_effect(player, "uniq_name", time, stats)`
- `player_physics.remove_effect(player, "uniq_name")`
2017-04-06 21:15:59 +02:00
2019-08-23 02:56:10 +02:00
## Code example
2017-04-06 21:15:59 +02:00
You make a potion that adds speed for 10 seconds.
2017-04-06 23:11:46 +02:00
on_use = function(itemstack, user, pointed_thing)
2017-04-06 21:15:59 +02:00
player_physics.add_effect(user, "potion_speedlvl1", 10, {speed=0.6})
itemstack:take_item()
return itemstack
end