mirror of
https://codeberg.org/tenplus1/farming.git
synced 2024-12-27 11:10:20 +01:00
mapgen uses 0.4.12 for plants generation
This commit is contained in:
parent
450c2be4c3
commit
5902909121
@ -13,6 +13,7 @@ This mod works by adding your new plant to the {growing=1} group and numbering t
|
|||||||
|
|
||||||
Changelog:
|
Changelog:
|
||||||
|
|
||||||
|
1.13 - Fixed seed double-placement glitch. Mapgen now uses 0.4.12+ for plant generation
|
||||||
1.12 - Player cannot place seeds in protected area, also growing speeds changed to match defaults
|
1.12 - Player cannot place seeds in protected area, also growing speeds changed to match defaults
|
||||||
1.11 - Added Straw Bale, streamlined growing abm a little, fixed melon rotation bug with screwdriver
|
1.11 - Added Straw Bale, streamlined growing abm a little, fixed melon rotation bug with screwdriver
|
||||||
1.10 - Added Blueberry Bush and Blueberry Muffins, also Pumpkin/Melon easier to pick up, added check for unloaded map
|
1.10 - Added Blueberry Bush and Blueberry Muffins, also Pumpkin/Melon easier to pick up, added check for unloaded map
|
||||||
|
133
mapgen.lua
133
mapgen.lua
@ -1,102 +1,45 @@
|
|||||||
|
|
||||||
-- Generate new foods on map
|
-- spawn new foods on map
|
||||||
|
|
||||||
function farming.mgv6ongen(minp, maxp, seed)
|
local function register_plant(name, min, max, spawnby, num)
|
||||||
|
minetest.register_decoration({
|
||||||
if maxp.y < 2 and minp.y > 0 then return end
|
deco_type = "simple",
|
||||||
|
place_on = {"default:dirt_with_grass"},
|
||||||
local perlin1 = minetest.get_perlin(329, 3, 0.6, 100)
|
sidelen = 16,
|
||||||
|
noise_params = {
|
||||||
-- Assume X and Z lengths are equal
|
offset = 0,
|
||||||
local divlen = 16
|
scale = 0.006,
|
||||||
local divs = (maxp.x-minp.x)/divlen+1
|
spread = {x=100, y=100, z=100},
|
||||||
|
seed = 329,
|
||||||
for divx=0,divs-1 do
|
octaves = 3,
|
||||||
for divz=0,divs-1 do
|
persist = 0.6
|
||||||
|
},
|
||||||
local x0 = minp.x + math.floor((divx+0)*divlen)
|
y_min = min,
|
||||||
local z0 = minp.z + math.floor((divz+0)*divlen)
|
y_max = max,
|
||||||
local x1 = minp.x + math.floor((divx+1)*divlen)
|
decoration = "farming:"..name,
|
||||||
local z1 = minp.z + math.floor((divz+1)*divlen)
|
spawn_by = spawnby,
|
||||||
|
num_spawn_by = num,
|
||||||
-- Determine plant amount from perlin noise
|
})
|
||||||
local plant_amount = math.floor(perlin1:get2d({x=x0, y=z0}) ^ 3 * 9)
|
|
||||||
|
|
||||||
-- Find random positions for plant
|
|
||||||
local pr = PseudoRandom(seed+420)
|
|
||||||
|
|
||||||
for i=0,plant_amount do
|
|
||||||
|
|
||||||
local x = pr:next(x0, x1)
|
|
||||||
local z = pr:next(z0, z1)
|
|
||||||
|
|
||||||
-- Find ground level (0...15)
|
|
||||||
local ground_y = nil
|
|
||||||
|
|
||||||
for y=30,0,-1 do
|
|
||||||
if minetest.get_node({x=x,y=y,z=z}).name ~= "air" then
|
|
||||||
ground_y = y
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if ground_y then
|
function farming.register_mgv6_decorations()
|
||||||
|
register_plant("potato_3", 15, 40, "", -1)
|
||||||
local p = {x=x,y=ground_y+1,z=z}
|
register_plant("tomato_7", 5, 20, "", -1)
|
||||||
local nn = minetest.get_node(p).name
|
register_plant("carrot_8", 1, 30, "group:water", 1)
|
||||||
|
register_plant("cucumber_4", 1, 20, "group:water", 1)
|
||||||
-- Check if the node can be replaced
|
register_plant("corn_7", 12, 22, "", -1)
|
||||||
if minetest.registered_nodes[nn]
|
register_plant("corn_8", 10, 20, "", -1)
|
||||||
and minetest.registered_nodes[nn].buildable_to then
|
register_plant("coffee_5", 20, 45, "", -1)
|
||||||
|
register_plant("melon_8", 1, 20, "group:water", 1)
|
||||||
nn = minetest.get_node({x=x,y=ground_y,z=z}).name
|
register_plant("pumpkin_8", 1, 20, "group:water", 1)
|
||||||
|
register_plant("raspberry_4", 3, 10, "", -1)
|
||||||
-- If dirt with grass, add plant in various stages of maturity
|
register_plant("rhubarb_3", 3, 15, "group:tree", 1)
|
||||||
if nn == "default:dirt_with_grass" then
|
register_plant("blueberry_4", 3, 10, "", -1)
|
||||||
|
|
||||||
local type = math.random(1,11)
|
|
||||||
local plant
|
|
||||||
|
|
||||||
if type == 1 and ground_y > 15 then
|
|
||||||
plant = "farming:potato_"..pr:next(3, 4)
|
|
||||||
elseif type == 2 then
|
|
||||||
plant = "farming:tomato_"..pr:next(7, 8)
|
|
||||||
elseif type == 3 then
|
|
||||||
plant = "farming:carrot_"..pr:next(7, 8)
|
|
||||||
elseif type == 4 then
|
|
||||||
plant = "farming:cucumber_4"
|
|
||||||
elseif type == 5 then
|
|
||||||
plant = "farming:corn_"..pr:next(7, 8)
|
|
||||||
elseif type == 6 and ground_y > 20 then
|
|
||||||
plant = "farming:coffee_5"
|
|
||||||
elseif type == 7 and minetest.find_node_near(p, 3, {"group:water"}) then
|
|
||||||
plant = "farming:melon_8"
|
|
||||||
elseif type == 8 and ground_y > 15 then
|
|
||||||
plant = "farming:pumpkin_8"
|
|
||||||
elseif type == 9 and ground_y > 5 then
|
|
||||||
plant = "farming:raspberry_4"
|
|
||||||
elseif type == 10 and ground_y > 10 then
|
|
||||||
plant = "farming:rhubarb_3"
|
|
||||||
elseif type == 11 and ground_y > 5 then
|
|
||||||
plant = "farming:blueberry_4"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Add plant
|
-- enable in mapgen v6 only
|
||||||
if plant then
|
|
||||||
minetest.set_node(p, {name=plant})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Enable in mapgen v6 only (disabled)
|
local mg_params = minetest.get_mapgen_params()
|
||||||
|
if mg_params.mgname == "v6" then
|
||||||
minetest.register_on_mapgen_init(function(mg_params)
|
farming.register_mgv6_decorations()
|
||||||
--if mg_params.mgname == "v6" then
|
end
|
||||||
minetest.register_on_generated(farming.mgv6ongen)
|
|
||||||
--end
|
|
||||||
end)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user