[Mod] Simple Gravelslabs [v0.1]

Nubm
Member
 
Posts: 20
Joined: Thu Nov 20, 2014 09:33

[Mod] Simple Gravelslabs [v0.1]

by Nubm » Sun May 31, 2015 18:08

Well, i guess the idea isn't new, but was the first mod i 'created' and i somewhat like it. This mod adds simple gravelslabs to the game: Quarter-, half- and 3/4-slabs.

Receipes and Demonstration: (uses Misa's Texture Pack, converted by Calinou)
Video: https://www.youtube.com/watch?v=kvgP2SlwFQg

Code: WTFPL
Mod dependencies: default
Install: Unpack the gravelslabs.zip into the Minetest/mods folder

[WIP]:
Another idea i had is to 'liquify' gravel (and sand), but this would probably cause problems with water, since slabs cannot mix with them. Would be great if they would...

However, what i am trying next is to make them stack (mix/transform) if they drop onto each other - so 2 halfslabs will transform into a full block, a quarter and a half into a 3/4-slab, two 3/4 into a full and a half etc.
Im not very good at modding tho, so if anyone else wants to do it let me know and i will gladly use your mod. :)
Attachments
gravelslabs.zip
(913 Bytes) Downloaded 97 times
Last edited by Nubm on Mon Jun 01, 2015 18:36, edited 1 time in total.
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

Re: [Mod] Simple Gravelslabs V0.1

by Sokomine » Sun May 31, 2015 18:36

Nubm wrote:Another idea i had is to 'liquify' gravel (and sand), but this would probably cause problems with water, since slabs cannot mix with them. Would be great if they would...

Just wondering...what if there where rocks (like those found in Dreambuilder or Realtest) on ocean floors occasionally? The might "stretch" up from the ground node into the water. Though perhaps that's a bit far-fetched and tricky for a start. More diverse gravel paths are nice as well.

Nubm wrote:Im not very good at modding tho, so if anyone else wants to do it let me know and i will gladly use your mod. :)

Just keep at it and continue modding. You'll get the experience over time. We all started that way :-)
A list of my mods can be found here.
 

User avatar
jordan4ibanez
Member
 
Posts: 1865
Joined: Tue Sep 27, 2011 18:44
GitHub: jordan4ibanez
IRC: jordan4ibanez
In-game: jordan4ibanez

Re: [Mod] Simple Gravelslabs V0.1

by jordan4ibanez » Sun May 31, 2015 23:25

That's a good idea, along with dirt slabs and grass slabs.
 

User avatar
Nathan.S
Member
 
Posts: 679
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21

Re: [Mod] Simple Gravelslabs V0.1

by Nathan.S » Mon Jun 01, 2015 03:31

This looks really nice. I must ask what mod provides those beautiful street lamps I saw in the video?

It is possible to change the nodes when placing them, example you have a half node placed and then place a quarter node, you can change to a three quarter node. You need to have a function that runs on_place which checks what the node under is and then replaces it. You can look at the mydecks or mylandscaping mods for examples, or put the code on github and I can make a pull request.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website.
 

Nubm
Member
 
Posts: 20
Joined: Thu Nov 20, 2014 09:33

Re: [Mod] Simple Gravelslabs V0.1

by Nubm » Mon Jun 01, 2015 06:01

Replacing the ground block to strech them out into the water might work. I'll check that mods, thanks!

I think someone did a world generated with slabs some time ago. As far as i remember it had problems with water and everything generated on top of slabs, like trees and plants. Would be way above my level to pull something like that off, but i always liked that idea too. :)

The street lamps are part of my ceramic mod, but i always thought they look too edged. Im doing some experiments with meshes to rework them.
I will take a closer look into that on_place function. Just wonder how it workes when gravel (which is a falling_node=1) falls onto another gravel node and how to verify that. Will check those mods, thanks for the advice. :)

EDIT: The code works fine and replaces the slabs. However, it does not work on falling slabs. Have to take a closer look, but i will try to add the 'stack' feature for now. Also i have to place another node on top of the replaced node in case the stack gets higher than one full node (for example, two 3/4 slabs).

Also i have to look into calling that function so i don't have to write it to every single node. Even tho there are not that many it might be a good training. Im thankful for any advise or suggestions on that. :)

Edit 2: Video of v0.1.1
https://www.youtube.com/watch?v=nPkkSOsjkJc
 

User avatar
Nathan.S
Member
 
Posts: 679
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21

Re: [Mod] Simple Gravelslabs [v0.1]

by Nathan.S » Mon Jun 01, 2015 23:38

I'm on a tablet now but I'll try and get something together yet tonight to give you a start.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
after_place_node = function(pos)
         local nodeu = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})
         if nodeu.name == "gravelslabs:gravel_quarter_slab" then
            minetest.set_node(pos,{name="air"})
            minetest.set_node({x=pos.x,y=pos.y-1,z=pos.z},{name="gravelslabs:gravel_slab"})
         elseif nodeu.name == 'gravelslabs:gravel_half_slab' then
            minetest.set_node(pos,{name='gravelslabs:gravel_quarter_slab'
            minetest.set_node({{x=pos.x,y=pos.y-1,z=pos.z},{name="gravelslabs:gravel_slab"})
         end


There must be a better way to do all this though, as right now each slab part needs it's own function to check against the lower slab to determine what slabs should be placed.

In the elseif we place a 1/4 slab where the user placed the 3/4 because the lower 1/2 of it was used to fill the 1/2 from the node below changing that into the full slab.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website.
 

User avatar
Nathan.S
Member
 
Posts: 679
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21

Re: [Mod] Simple Gravelslabs [v0.1]

by Nathan.S » Tue Jun 02, 2015 02:38

Well this might work, bear with me please.

We make a function that takes two custom inputs, a group and a height. The function first checks the group of the lower node, if it isn't the same it does nothing, if they are the same it carries on to check what height that node is and then adds the height to the height of the Nide being placed if the result is one or less it removes the placed node and replaces the lower node with the correct height node. If however the value is greater than one it replaces the lower node with a full block and places the node with the remaining height. It might look a little something like this.
Myfunction(pos, gravel, .25)
This line tells the function the type of node and the height of the node you are placing, so in this case it would be the quarter node, for the half node you would use .5 and etc.
Now the actual function would be a little more confusing, something like this
If type = group then
Local bn = minetest.get_node(pos.y-1)
If bn = gravelslab:*_quarter then
Local height = .25
Elseif bn =gravelslab:*_half then
Local height = .50
[We do the same for the 3/4 and full nodes typing on a tablet again]
Now we add the heights.
Local total_height = height + var2 where var2 is the value we passed to the function.
If total_height <= 1 then
If total_height = .25 then
Local Gravelslabsomething = 'gravelslab:gravel_quarter_slab'
We do the same for .5 and .75
Minetest.set_node(pos, {name=air})
Minetest.set_node(pos =pos.y -1, {name = gravelslabsomething})
End

We also check if the value is greater then one and then do the same thing to figure out ewhich nodes to place. Of course this is just an idea and the code is riddled with errors and mistakes, again typing this on a tablet. I can mess around with this some tomorrow and more on Wednesday if you'd like.
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website.
 

User avatar
Don
Member
 
Posts: 1641
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: [Mod] Simple Gravelslabs [v0.1]

by Don » Tue Jun 02, 2015 04:54

If you want a falling node to join the one it galls on I think you need to use an abm
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here
 

Nubm
Member
 
Posts: 20
Joined: Thu Nov 20, 2014 09:33

Re: [Mod] Simple Gravelslabs [v0.1]

by Nubm » Tue Jun 02, 2015 20:17

The falling node can trigger certain events. It stops when hitting another solid block, and it destroys plants and such. Is there maybe a way to check on collision with the ground? It will fall as long as air is under the node anyways, but how does it checks for and probably trigger the first non-air block it hits?
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

Re: [Mod] Simple Gravelslabs [v0.1]

by Hybrid Dog » Wed Jun 03, 2015 11:09

l think you could also use a leveled node box instead of 3 nodes
https://github.com/Splizard/minetest-mo ... l.lua#L120
 

Nubm
Member
 
Posts: 20
Joined: Thu Nov 20, 2014 09:33

Re: [Mod] Simple Gravelslabs [v0.1]

by Nubm » Sun Jun 07, 2015 06:53

As an idea:
I want to try to add the count of quarter slabs as a number (quarter slabs = 1, half slab = 2, threequarter slab = 3, full block = 4).
on_place will call a function which will look for possible slabs below the placed slab (with a 3 node vertical range to override the falling_node effect and allow to stack up slabs from a higher distance), then adds the placed and the detected node together (2x quarter slabs = 2, 2x half slabs = 4, etc.). If no other slabs are detected, the count value remains unaltered. That means that the value is among 1 (a quarter slab on a non-slab node) and 7 (a full gravel block on a threequarter slab).

After the addition, it will place the node/-s from the result:
(y is the value above the first node below the placed slab was detected in, remains y if no other slab was detected)
If the total count is 4 it will replace the node at y-1 with a full gravel block.
If the total count is >4 it will subtract 4 and replace the y-1 node with a full gravel block. The next node is placed on y instead of y-1.
If the total count is below 4 the node is replaced on y-1 (placed on y if number was above 4) depending on its value: 1 = quarter slab, 2 = half slab, 3 = three quarter slab, 4 = full gravel block.


It will take some time to figure out how to put this together. It will not stack nodes that are falling from 4 or more blocks height tho, but im ok with that.
What do you think?
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 8 guests

cron