Interactive Physics Mod v1.1
physics (by sorcerykid)
Interactive Physics is a completely Lua-driven physics simulator and API for Minetest, offering a far more immersive gameplay experience with plug-and-play integration for new and existing mods alike.
The library handles quasi-realistic physical interactions between entities vs. players and entities vs. nodes (including air and water) -- sufficient to suspend disbelief for purposes of gameplay, but also with minimal performance costs incurred. It takes advantage of several features made available by PR #9747.
Here's a demonstration video showing what is possible:
https://vimeo.com/318083845
Showcasing Interactive Physics Library in Minetest
Besides the API, a control panel interface is available to manually override the physical properties of solid and liquid nodes as well as entities directly in-game.
Repository:
https://bitbucket.org/sorcerykid/physics
Download Archive (.zip)
Download Archive (.tar.gz)
Compatibility:
Minetest 5.3-dev patched with PR #9717
Dependencies:
ActiveFormspecs Mod by sorcerykid (optional)
Configuration Panel Mod by sorcerykid
Source Code License:
GNU Lesser General Public License v3 (LGPL-3.0)
Installation:
- Unzip the archive into the physics directory of your game
- Rename the physics-master directory to "physics"
- Add "physics" as a dependency to any mods using the API.
Interactive physics supports a wide variety of basic physical properties for entities, liquid nodes, solid nodes, and air nodes. It's also possible to manually override these properties in-game by use of the Physics Wand. Simply point to the respective node or entity and left-click. A pop-up window will appear so that you can make the desired adjustments in realtime.
Of course you can always click "Reset" to revert to the default values. If you wish to permanently change the properties of liquids and solids, then you can do so by editing the physics/materials.lua file.
As you can see, the following nodes have been pre-configured for you.
Code: Select all
return {
["group:water"] = { type = "liquid", viscosity = 0.5, density = 0.5 },
["group:lava"] = { type = "liquid", viscosity = 0.7, density = 0.5 },
["default:ice"] = { type = "solid", friction = 0.0, elasticity = 0.0 },
}
To set the global defaults for all liquid and solid nodes, just edit physics/config.lua. This is also where you can fine-tune gravity and adjust the properties of air itself.
Code: Select all
world_gravity = 10
air_viscosity = 0.0
air_density = 0.2
default_liquid = { viscosity = 0.2, density = 0.5 }
default_solid = { friction = 0.5, elasticity = 0.0 }
Now that the basic setup is out of the way, you're ready to integrate Interactive Physics into your own mods! First and foremost, you will need to inherit the BasicPhysics superclass. The best place to do this is within the on_activate() callback of your entity.
Code: Select all
on_activate = function ( self, dtime, staticdata )
BasicPhysics( self )
:
end
Code: Select all
physics = {
friction = 0.4,
density = 0.7,
elasticity = 0.3,
resistance = 0.2,
},