1) Create a new mod (e.g. junglegrass) with a init.lua file.
2) Insert this code into the init.lua:
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
minetest.register_on_generated(function(minp, maxp, blockseed)
-- Code here
end)
The code between "-- Code here" and "end)" will be executed each time the mapgenerator creates a new mapblock (16x16x16).
3) You only want to create junglegrass on the surface so check if minp.y is lower than 0 and maxp.y is greater than 0:
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
minetest.register_on_generated(function(minp, maxp, blockseed)
-- Code here
if minp.y<0 and maxp.y>0 then
end
end)
4) (most difficult part) Create an algorithm that puts the junglegrass randomly (maybe with perlin noise) in the block if dirt with grass is under it. To place the junglegrass you have to do this:
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
if minetest.env:get_node(pos_under_the_grass).name == "default:dirt_with_grass" then
minetest.env:set_node(pos_of_the_grass, {name="default:junglegrass"})
end