Can i spawn junglegrass ??

sky
Member
 
Posts: 152
Joined: Tue Oct 16, 2012 11:59

Can i spawn junglegrass ??

by sky » Sun Oct 28, 2012 09:48

how i do it mapgen or something and tell me step by step
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Sun Oct 28, 2012 10:18

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
Last edited by PilzAdam on Sun Oct 28, 2012 10:19, edited 1 time in total.
 

User avatar
Topywo
Member
 
Posts: 1718
Joined: Fri May 18, 2012 20:27

by Topywo » Sun Oct 28, 2012 10:57

 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 6 guests

cron