[Mod] Player Physics API [1.0.0] [playerphysics]

User avatar
Wuzzy
Member
 
Posts: 3545
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

[Mod] Player Physics API [1.0.0] [playerphysics]

by Wuzzy » Thu Feb 21, 2019 20:37

Player Physics API

This mod makes it possible for multiple mods to modify player physics (speed, jumping strength, gravity) without conflict.

This mod is an API mod for modders. Players only might need it as dependency.

DOWNLOAD

Git repository and README

The problem
Mods and games in Minetest can set physical attributes of players, such as speed and jump strength (set_physics_override. But this method only can set the raw physical values, overwriting any previous value. So as soon more than 1 mod messes with the same player physics attribute (e.g. speed), all hell breaks loose and hilarity ensues, because each mod now competes for the “correct” physics attribute. In the worst case, speed, jump strength or gravity will go all over the place.

Player Physics API
The Player Physics API resolves this conflict by providing a “common ground” for mods to work together in this regard. It's a very lightweight mod and only has 2 functions.

It introduces the concept of “modifiers”. Any mod can add and remove factors for e.g. speed at any time and the product of all factors will be the final speed. This is a much more convenient and safer solution than to setting the raw speed.

This is basically a mod implementation of https://github.com/minetest/minetest/pull/7269.

Read about how to use this mod in the README!

Showcase
This mod is being used successfully in MineClone 2 for many months without any bugs. It is used to coordinate the speed changes triggered by soul sand, sprinting, slowdown while firing an arrow and sleeping in bed. This would be impossible would every mod call set_physics_override directly.

IMORTANT WARNING
If you want to adopt this mod, you must be sure that ALL mods that mess with player physics do so by using this mod and not by calling set_physics_override directly. Any mod that calls set_physics_override direclty to change a physical attribute will destroy all benefits of the Player Physics API.

However, I consider that overwriting the raw player physics is never good development practice anyway, the problem is just that the Lua API does not provide any better tools than that.

Spead the word!
I would like to have physics modifiers as used in this mod to become a part of the official Minetest Lua API. Sadly, the discussion of this topic has been long and tiresome with no solution in sight. So in the meantime, we are stuck with a mod-based solution, i.e. the Player Physics API.

Please make modders aware that calling set_physics_override is dangerous and point them to this thread.

I also post this mod as evidence that a modifier-based solution is possible, practical, lightweight, logical, simple to use and something that modders would desperately need. Ideally, I like modders to move away from using set_physics_override and use a safer alternative instead.

Other infos
License of everything: MIT License
Dependencies: None!
My creations. I gladly accept bitcoins: 17fsUywHxeMHKG41UFfu34F1rAxZcrVoqH
 

User avatar
runs
Member
 
Posts: 721
Joined: Sat Oct 27, 2018 08:32
GitHub: runsy

Re: [Mod] Player Physics API [1.0.0] [playerphysics]

by runs » Thu Feb 21, 2019 22:26

Yes, this it would be in the official API. I wonder why not yet.
 

User avatar
TenPlus1
Member
 
Posts: 2588
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: [Mod] Player Physics API [1.0.0] [playerphysics]

by TenPlus1 » Fri Feb 22, 2019 06:44

So basically like my POVA mod but using multiplication instead of addition?
 

User avatar
texmex
Member
 
Posts: 1527
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: texmex
 

User avatar
Wuzzy
Member
 
Posts: 3545
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: [Mod] Player Physics API [1.0.0] [playerphysics]

by Wuzzy » Fri Feb 22, 2019 13:45

Oh, I'm very sorry for posting a seemingly redundant mod.

Do note that this mod is NOT for generic effects, it only bothers about player physics you can set with set_player_physics.
LATE and player_monoids are for status effects. LATE is still in alpha.
I can not find the POVA mod. I don't know why you would use addition. It does not make sense. You DO know the modifiers in set_physics_override are factors, right? And yes, my mod uses factors.

The mods physcish and player_physics look like direct competitors.
physicsh is cluttered with useless items that should be removed. Also, in the README, it says “This API may change any time”. This automatically disqualifies the mod.
player_physics is very very similar, but it also supports temporary effects. Sadly, it has no forum thread (WHY???).

Basically, the mod search is terrible. :-)

How commonly used is player_physics at the moment? If it is too commonly used, I consider removing my mod.
My creations. I gladly accept bitcoins: 17fsUywHxeMHKG41UFfu34F1rAxZcrVoqH
 

User avatar
texmex
Member
 
Posts: 1527
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: texmex

Re: [Mod] Player Physics API [1.0.0] [playerphysics]

by texmex » Fri Feb 22, 2019 18:34

Sorry if I came off as a bit salty, I didn’t mean it like that at all. I honestly wanted to know the differences of each mod. Your mods are always of a high quality which immediately made me think of supporting it in my several player physics altering mods.

While I fully understand that LATE is also a larger project it internally handles the same problem as your mod, hence the mention. I don’t understand the statement about player_monoids however, as I’m using it for exactly player physics. But I can’t blame you for not having glanced the code of all those mods. :D

MinetestForFun sometimes write great mods but they usually make little effort to spread them in the community.
 

User avatar
jas
Member
 
Posts: 410
Joined: Mon Jul 24, 2017 18:15
GitHub: jastevenson303
IRC: jas_
In-game: jas

Re: [Mod] Player Physics API [1.0.0] [playerphysics]

by jas » Fri Feb 22, 2019 20:50

Oh, I'm very sorry for posting a seemingly redundant mod.

Why? It's your mod. Who else would have posted it?




:)
201902221552
 

User avatar
sorcerykid
Member
 
Posts: 1061
Joined: Fri Aug 26, 2016 15:36
Location: Illinois, USA
GitHub: sorcerykid
In-game: Nemo

Re: [Mod] Player Physics API [1.0.0] [playerphysics]

by sorcerykid » Sat Feb 23, 2019 01:09

Rather than a tossing away all your hard work why not do a pull request and incorporate this functionality into builtin? I know you said previous discussions didn't go anywhere, but I think this is project is worth salvaging.
 

User avatar
texmex
Member
 
Posts: 1527
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: texmex
 

User avatar
TenPlus1
Member
 
Posts: 2588
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: [Mod] Player Physics API [1.0.0] [playerphysics]

by TenPlus1 » Sat Feb 23, 2019 06:23

Pova works similar to your own mod (https://notabug.org/tenplus1/pova) and is already used in 3d_armor, stamina, playerplus, catcommands and a few xanadu specific mods.
 

User avatar
texmex
Member
 
Posts: 1527
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: texmex

Re: [Mod] Player Physics API [1.0.0] [playerphysics]

by texmex » Sat Feb 23, 2019 09:34

TenPlus1 wrote:Pova works similar to your own mod (https://notabug.org/tenplus1/pova) and is already used in 3d_armor, stamina, playerplus, catcommands and a few xanadu specific mods.

Does it also have a C++ based PR pending?
 

User avatar
TenPlus1
Member
 
Posts: 2588
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1
 

User avatar
Wuzzy
Member
 
Posts: 3545
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: [Mod] Player Physics API [1.0.0] [playerphysics]

by Wuzzy » Sun Feb 24, 2019 00:45

Pova works similar to your own mod (https://notabug.org/tenplus1/pova) and is already used in 3d_armor, stamina, playerplus, catcommands and a few xanadu specific mods.

I refuse to use anything for critical infrastructure that has a leading 0 in its version number, nor has been really announced on the forums so far. The risk is just too high, sorry.
My creations. I gladly accept bitcoins: 17fsUywHxeMHKG41UFfu34F1rAxZcrVoqH
 

User avatar
TenPlus1
Member
 
Posts: 2588
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: [Mod] Player Physics API [1.0.0] [playerphysics]

by TenPlus1 » Sun Feb 24, 2019 20:25

Wuzzy: That's ok :) was just pointing out the similarities between mods... Pova has been active on Xanadu for over 10 months with no issue although I forgot to add to forum, only the ContentDB:

https://content.minetest.net/packages/TenPlus1/pova/
 

User avatar
Wuzzy
Member
 
Posts: 3545
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: [Mod] Player Physics API [1.0.0] [playerphysics]

by Wuzzy » Thu Feb 28, 2019 22:39

Well, I guess the main “selling point” of my mod is that it is the most minimalist mod that gets its task done and comes with zero unneccessary cruft. There is nothing left to remove.

It has a proper release model and complete documentation that is readable.
Also, it's very stable. This should make adoption as pain-free as possible.

I don't like POVA's design to be honest, it depends on globalstep, which I think is completely unneccessary. Also, the documentation seems incomplete, it's hard to follow.

It appears that POVA also adds/subtracts instead of multiplies. This is very weird mathematically. Let me explain why. I'm not saying it's wrong, but you should now what you're doing. IMO using factors is just the more “natural” and more straight-forward thing to do. It's much easier to maintain even in a big game.

Remember that the value you put into set_physics_override is not an absolute speed, but a speed factor.
Let's suppose you start with speed 1, then add 1, your effective speed is now 2. It has doubled. Great. But what happens when you add another 1? Then your effective speed changes from 2 to 3, which is now an increase of only 50%. In other words, the effective speed increase depends on your previous speed! There are diminishing returns. No idea if this is intentional. It's at least unexpected and missing in documentation. If it is intentional, great, but then POVA needs polishing.
At least the mod seems to maintain consistency.
There's some other useless cruft included, like a debug message in singleplayer or the test axe.
My creations. I gladly accept bitcoins: 17fsUywHxeMHKG41UFfu34F1rAxZcrVoqH
 

User avatar
TenPlus1
Member
 
Posts: 2588
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: [Mod] Player Physics API [1.0.0] [playerphysics]

by TenPlus1 » Fri Mar 01, 2019 07:16

Thanks for the input wuzzy, yes the addition/subtraction is on purpose to keep values easier and works quite well for most mods, and the globalstep can be disabled if it's not needed, it's only there to recalculate just incase of rogue mods :) The axe is a test example though...
 

User avatar
Kimapr
New member
 
Posts: 7
Joined: Fri May 24, 2019 15:53
GitHub: Kimapr
IRC: Kimapr
In-game: Kimapr

Re: [Mod] Player Physics API [1.0.0] [playerphysics]

by Kimapr » Wed Sep 04, 2019 08:31

Actually you can overwrite the ObjectRef's metatable in case of rogue mods. Minetest uses one metatable for all instances of a class. If you write to metatable of one instance, that affects other too (if you create different table and setmetatable of an instance to that table that won't affect other instances). That way you can find or create a ObjectRef, save set_physics_override for your internal use, then overwrite original one to your liking. It is like an *injection* into minetest API to change behaviour of mods. Then you don't need an API at all. You can inject all of your functions into minetest API
Ek59C88tAsaQuRAw6PCPsGFDozj1FuZ4
 


Return to Mod Releases



Who is online

Users browsing this forum: No registered users and 10 guests