Page 1 of 1

[Mod] simple block physics [block_physics][WIP][2.2]

PostPosted: Sun Dec 18, 2016 18:52
by Swablu
Simple Block Physics
Info
This mod adds very very simple block physics to minetest.
Some inspiration came from this post: https://forum.minetest.net/viewtopic.php?id=3032 credits to Fiberous
The mod only affects humanmade blocks that don't use there param2.
It uses the param2 variable of the affected blocks to store the weight they can hold.

Gifs
+ Spoiler


Long explenation about the physics
The affected blocks are all cobble blocks, all brick blocks and all full blocks (like diamond_block)
These blocks have four properties: shear strenght, tensile strenght, compressive strenght and weight.
When a block is updated (by punching, placing or digging or TNT)
This block will use its values for its strenghts to calculate the amount of support it has from the surrounding blocks.
Then its param2 value will be updated to be the amount of mass that the block can still hold.
This update will spread throught the neightbouring blocks and all unsupported blocks will fall down.

Also there is the param1 value for the amount of overhang. I should really documentate this somewhere :P

+ Data


Why would i use this?
It's an extra challenge while you build a house!
The different materials have different properties, this makes for some more interesting building
Arches are stronger than 90 degree angles, thick pilars reach higher.

Why shouldn't i use this on an existing world?
This mod uses the param2 of all affected blocks.
Param2 defaults to 0 which means there is no support.
When you build your buildings with the mod enable, it will work as intended.

Build tips
  • If a node is connected from to opposite sides, it is considered stronger.
    More of these double connections make the node even stronger.
  • This means that building a bridge will propably require some kind of temporary scaffolding.
  • Different materials have different qualities.:
    You could use stone as a base and wood for higher walls and overhangs.
  • Arches are pretty good too.
  • Just experimentate!

Download
Use at an existing world at your own risk: all buildings will collapse!
The mod can be downloaded here: https://github.com/LHolten/block_physics
Depends: default? and stairs?
License: GNU GPLv3

API
+ Spoiler


Log/Done
  • fix hanging blocks
  • fixed blocks not falling in water, lava and fire
  • use something different from abm to get rid of the lag: minetest.after
  • fix diagonal falling blocks bug
  • add support for TNT back

Todo
  • fix attached node removal
  • add physics for natural nodes
  • falling node double check or something
  • add group for delay

Mmaybe somwhere in the future
  • add a more realistic destructive option

All suggestions are welkom

Re: [Mod] simple block physics [block_physics]

PostPosted: Mon Dec 19, 2016 15:19
by DS-minetest
the mod would be nice but it causes massive lags

Re: [Mod] simple block physics [block_physics]

PostPosted: Mon Dec 19, 2016 15:53
by Swablu
Thanks for the response,
I know it causes lag, but it is still fun to play with.
If someone knows a way to fix this, please send me a message.

Re: [Mod] simple block physics [block_physics]

PostPosted: Mon Dec 19, 2016 17:48
by Andrey01
Nice! It looks like really

Re: [Mod] simple block physics [block_physics][No Lag!]

PostPosted: Mon Dec 19, 2016 18:56
by Swablu
I updated the mod to only update blocks that are touched.
This should greatly reduce lag.

Re: [Mod] simple block physics [block_physics][No Lag!]

PostPosted: Mon Dec 19, 2016 19:00
by Wuzzy
Do you care to actually explain the “simple block physics”? ;-)

It it only triggered by TNT as suggested by the GIFs? What are the rules?

Re: [Mod] simple block physics [block_physics][No Lag!]

PostPosted: Mon Dec 19, 2016 20:24
by Swablu
I have tried to explain the physics as well as i can,
Hope everyone understands it.

As of the last update the physics are only trigerred by building and digging and not by TNT. :)
Support for this is on my todo list

Re: [Mod] simple block physics [block_physics][No Lag!]

PostPosted: Mon Dec 19, 2016 21:47
by mahmutelmas06
I think nodes should collapse if there is no block connected touching to ground. Otherwise we cannot build a bridge :)

Re: [Mod] simple block physics [block_physics][No Lag!]

PostPosted: Tue Dec 20, 2016 00:25
by Wuzzy
Ohhhhhh! Now I understand this mod.
Wow! I am quite impressed by the idea alone. Very innovative. It completely turns the entire building aspect of Minetest on the head. This opens totally new possibilities for interesting new subgames.
Building is completely different and more challenging than the default. I definitely need to put this mod on my watch list. :-)

I still did not understand the meaning of the 4 values (tensile, weight, etc.). I do understand now that the blocks have to be attached in a special way. I know kinda how it works, but I am not sure about the exact physics.

I think the current blocks you modified for Minetest Game are not modified rigourously enough. Because there are many blocks which don't have physics at all, meaning they can freely float in air. For example, leaves. This means, if you have leaves, you can entirely circumvent the whole challenge of this mod because the physics rule doesn't apply to them, so you can use leaves to build any building, bridge, etc. with ease.
On the other hand, maybe Minetest Game is just not “ready” for a mod like this. ;-)

I think this mod can only be used most efficiently if an entire subgame follows the new paradigm of block physics and is balanced to it, not just for a few selected blocks. But I am pretty sure subgames will will go all the way of block physics could be very interesting to play. :-)

I think this mod should be generalized and definitely not hard-depend on Minetest Game. Because this is far too fundamental a game concept to be limited to Minetest Game only. Try to make that dependency optional. This will make integration into other subgames easier.

Introducing an API would be nice. Or is it all done with groups only? In that case, please specify the exact meaning of all groups and their ratings in some readme file. So that other mods can easily build upon this mod.

Then, I have a question: Could this mod maybe be used to prevent the infamous noob-poling (getting to high places quick just by stacking blocks vertically and jumping)? That would be awesome! If yes, how could it be done?

Another question: I noticed that there is often a delay after blocks lose their stability before they fall. Is it possible that this delay varies per block? This would be interesting. If e.g. a bridge collapses, depending on the block type, you might have more or less time to “escape” the complete collapse. :-) Would an instant collapse (like for falling_node) be also possible?

I think I found a bug. I noticed that blocks sometimes seem to “slide off” other blocks. I have not fully understood the physics of that. However, there is one oddidy: It appears that it is also possible for blocks to “slide off” if they should have logically been blocked from doing so. Do you see this hole?

Image
Below the desert cobblestone there is lots of air, which is of course concealed. If you place a desert cobblestone into that hole, it will glide off into that air, which seems physically impossible. It's as if the block has gone diagonally through the blocks.

Here's how it looks below the desert cobblestone (the pointed node is the same node as in the 1st screenshot):
Image

I hope you understood the bug. It is not easy to reproduce since I still don't fully understand the physics.

Re: [Mod] simple block physics [block_physics][No Lag!]

PostPosted: Tue Dec 20, 2016 02:09
by TumeniNodes
I'm assuming steel can take the most strain from weight?
This is really nice, I had mentioned something like this once, which would cause players to have to build structures in the same way as real life. Load bearing materials/walls will be needed.... Bridges will take more thought with this ; )

I like it, it's very cool. This is also a nice mod for teachers who use Minetest to add...

By the way, for those who dislike float islands and often spend time going around blowing them up.... this will probably eliminate them naturally :P (I think...) Seems like you would only need to punch one block on one and the rest would simply drop?

Re: [Mod] simple block physics [block_physics][No Lag!]

PostPosted: Tue Dec 20, 2016 03:06
by TheReaperKing
Tumen funny you say that, I've been looking for something like this for my students for a while. Now it will make them think more when they create their buildings :) Thanks for making this Swablu!

Re: [Mod] simple block physics [block_physics][No Lag!]

PostPosted: Tue Dec 20, 2016 11:52
by DS-minetest
ok, now the lag is much less (as long as you dont dig)

there was a minecraft mod like this, i forgot the name

Re: [Mod] simple block physics [block_physics][No Lag!]

PostPosted: Tue Dec 20, 2016 14:45
by Swablu
mahmutelmas06 wrote:I think nodes should collapse if there is no block connected touching to ground. Otherwise we cannot build a bridge :)

I don't know what you mean? You are propably using a node without physics
Wuzzy wrote:Wow! I am quite impressed by the idea alone. Very innovative. It completely turns the entire building aspect of Minetest on the head. This opens totally new possibilities for interesting new subgames.
Building is completely different and more challenging than the default. I definitely need to put this mod on my watch list. :-)

I am glad you like it, i was inspired by this http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/1283267-blockphysics-mod minecraft mod and the post by fiberous linked in the main post. He explains what the three values for strenght are for.

Wuzzy wrote:I think the current blocks you modified for Minetest Game are not modified rigourously enough. Because there are many blocks which don't have physics at all, meaning they can freely float in air. For example, leaves. This means, if you have leaves, you can entirely circumvent the whole challenge of this mod because the physics rule doesn't apply to them, so you can use leaves to build any building, bridge, etc. with ease.
On the other hand, maybe Minetest Game is just not “ready” for a mod like this. ;-)

I agree that the blocks may not be modiefied rigorusly enough, but i think the natural blocks should not be affected, because then the whole world could collapse and there would not be a base for the other blocks to build on :D.
For leaves, you could dissable the piece of code that makes placed leaves not decay.
I think logs are more of a problem, because i use them a lot and they already use there param2.

Wuzzy wrote:I think this mod can only be used most efficiently if an entire subgame follows the new paradigm of block physics and is balanced to it, not just for a few selected blocks. But I am pretty sure subgames will will go all the way of block physics could be very interesting to play. :-)

I think this mod should be generalized and definitely not hard-depend on Minetest Game. Because this is far too fundamental a game concept to be limited to Minetest Game only. Try to make that dependency optional. This will make integration into other subgames easier.

Agreed!

Wuzzy wrote:Introducing an API would be nice. Or is it all done with groups only? In that case, please specify the exact meaning of all groups and their ratings in some readme file. So that other mods can easily build upon this mod.

At the moment it is all done with groups, but i may need to at some api functions for the TNT to work correctly.

Wuzzy wrote:Then, I have a question: Could this mod maybe be used to prevent the infamous noob-poling (getting to high places quick just by stacking blocks vertically and jumping)? That would be awesome! If yes, how could it be done?

probably :-) idk

Another question: I noticed that there is often a delay after blocks lose their stability before they fall. Is it possible that this delay varies per block? This would be interesting. If e.g. a bridge collapses, depending on the block type, you might have more or less time to “escape” the complete collapse. :-) Would an instant collapse (like for falling_node) be also possible?

yes this delay can be varied, it would require an aditional group, but hey why not?

I think I found a bug

You did, i know why this happens just need to fix it :-P

I'm assuming steel can take the most strain from weight?
This is really nice, I had mentioned something like this once, which would cause players to have to build structures in the same way as real life. Load bearing materials/walls will be needed.... Bridges will take more thought with this ; )

Thats the idea!

Tumen funny you say that, I've been looking for something like this for my students for a while. Now it will make them think more when they create their buildings :) Thanks for making this Swablu!

Keep in mined that this mod is still WIP.
It is a learning experience for me to!

ok, now the lag is much less (as long as you dont dig)
there was a minecraft mod like this, i forgot the name

i can't get rid of the lag when you dig, but the mod you are refering to is http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/1283267-blockphysics-mod

Re: [Mod] simple block physics [block_physics][No Lag!]

PostPosted: Tue Dec 20, 2016 18:50
by Wuzzy
Wuzzy wrote:Introducing an API would be nice. Or is it all done with groups only? In that case, please specify the exact meaning of all groups and their ratings in some readme file. So that other mods can easily build upon this mod.

At the moment it is all done with groups, but i may need to at some api functions for the TNT to work correctly.
[/quote]
Hint: For explosions we have that semi-official on_blast function (see lua_api.txt).

Version 2.0

PostPosted: Sat Dec 31, 2016 16:11
by Swablu
Hi people,
I have made a new version (2.0)!

Changelog:
  • TNT affects blocks again
  • Moved all processing to a coroutine
effects:
  • It uses on_construct and after_destruct so it should be compatible with all destroying mods
  • There should be no lag because if the calculations take to long they are processed later

A known bug is that if a natural block is removed but not by the player, then the blocks around it dont get updated

Re: [Mod] simple block physics [block_physics][WIP][2.0]

PostPosted: Sat Dec 31, 2016 17:36
by Diamond knight
I think custom blocks for this mod would be nice: eg. Steel cables, steel frames, etc.
and support for all the default (and some mods) non natural blocks, and a setting for difficulty (easy, medium, hard, realistic) (will affect the supporting qualities of materials, and some way to make all default natural blocks work for physics (something special way for them to work)

Re: [Mod] simple block physics [block_physics][WIP][2.0]

PostPosted: Sat Dec 31, 2016 18:42
by DS-minetest
nodes for building should be provided by another mod, not this one

theres a problem:
if the position is higher from ground the nodes are more likely to fall down, not only at straight 1² towers but also if you want to build a small bridge between 2 towers

Re: [Mod] simple block physics [block_physics][WIP][2.0]

PostPosted: Sun Jan 01, 2017 12:16
by ManElevation
it might cause a bit of lag if a lot of blocks start falling at the same time, but its a good mod

Re: [Mod] simple block physics [block_physics][WIP][2.0]

PostPosted: Sun Jan 01, 2017 13:22
by Swablu
Diamond knight wrote:I think custom blocks for this mod would be nice: eg. Steel cables, steel frames, etc.
and support for all the default (and some mods) non natural blocks, and a setting for difficulty (easy, medium, hard, realistic) (will affect the supporting qualities of materials, and some way to make all default natural blocks work for physics (something special way for them to work)

A setting for difficulty would be nice indeed, but it would make sharing worlds more difficult because you would need to use the same setting for your buildings to stay upright.
I am planning to add some modes e.g. one that doesn't collapse your buildings, but only reports weak spots. i don't think the supporting qualities of materials should be affected.
Still not sure how to implement physics for all natural blocks, but suggestions are welkom.

DS-minetest wrote:theres a problem:
if the position is higher from ground the nodes are more likely to fall down, not only at straight 1² towers but also if you want to build a small bridge between 2 towers

I want to make overhangs on top of a tower less stable, but this should not prevent you from building a bridge.
Hopefully i will come up with a way to make thick connections more stable, and bridges more stable then overhangs

Re: [Mod] simple block physics [block_physics][WIP][2.0]

PostPosted: Sat Jan 14, 2017 15:45
by Diamond knight
I think that the attributes should be scaled by a factor or ten so that there can be more variance in weight (wood blocks are currently the lightest thing possible)
And you forgot some wood blocks in the code (I had to add in jungle wood planks myself :( to the code) it would be interesting to have slabs be lighter than planks and some support for all the non natural blocks and moreblocks slabs (they would be lighter but weaker the thinner the slab)

Re: [Mod] simple block physics [block_physics][WIP][2.0]

PostPosted: Sat Jan 28, 2017 16:12
by Swablu
I did a little update, pilars in a crossshape can be build higher than single block pilars.
Also added junglewood and pine_wood (thanks for pointing this out Diamond knight)

Diamond knight wrote:I think that the attributes should be scaled by a factor or ten so that there can be more variance in weight (wood blocks are currently the lightest thing possible)
And you forgot some wood blocks in the code (I had to add in jungle wood planks myself :( to the code) it would be interesting to have slabs be lighter than planks and some support for all the non natural blocks and moreblocks slabs (they would be lighter but weaker the thinner the slab)


Param1 and param2 can store integers from 0 to 255 these are used by the physics for the amound of overhang and a general force.
I want this mod to be able to handle big structures, weights of for example 20 would limit all buildings to a height of about 11 nodes.
This said, this update makes it possible to build unlimitedly high pilars, given a wide enough base..
Anyway, I still think weights should be as low as possible.

For the lighter nodes i will propably add a different "class" of nodes, all non opaque nodes etc.
These lighter "decoration nodes" would then only be able to be placed touching a real physics block, and will fall down when this block is removed.

I hope my english is clear :P

Re: [Mod] simple block physics [block_physics][WIP][2.0]

PostPosted: Sun Jan 29, 2017 17:54
by Swablu
Update 2.1
changelog:
  • Added wall and floor physics, strange to get used to (needs more improvemend)
  • Added physics for all stairs and slabs, optional dependency.
  • Added physics for glass and other default deco
  • Also Propably lots of bugs, so watch out

Try building an underwater house with this and https://forum.minetest.net/viewtopic.php?f=9&t=16485=[dynamic_liquid]

Re: [Mod] simple block physics [block_physics][WIP][2.0]

PostPosted: Sun Jan 29, 2017 18:25
by azekill_DIABLO
it's an awesome idea!

Re: [Mod] simple block physics [block_physics][WIP][2.2]

PostPosted: Thu Feb 02, 2017 16:44
by Swablu
Update 2.2
changelog:
  • replaced the floor wall code with a more generic aproach
  • balanced for fun gameplay
  • bugfixes

I think the physics are almost finished.
The only things that i have left on my list are:
  • fix attached node removal
  • add physics for natural nodes
  • falling node double check or something
  • add group for delay

If something is missng, i would like to know!