forked from minetest/minetest_game
Generate dry shrubs on deserts
This commit is contained in:
parent
51fce37fc1
commit
5296dc1518
|
@ -1224,6 +1224,23 @@ minetest.register_node("default:apple", {
|
||||||
sounds = default.node_sound_defaults(),
|
sounds = default.node_sound_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_node("default:dry_shrub", {
|
||||||
|
description = "Dry Shrub",
|
||||||
|
drawtype = "plantlike",
|
||||||
|
visual_scale = 1.0,
|
||||||
|
tile_images = {"default_dry_shrub.png"},
|
||||||
|
inventory_image = "default_dry_shrub.png",
|
||||||
|
wield_image = "default_dry_shrub.png",
|
||||||
|
paramtype = "light",
|
||||||
|
walkable = false,
|
||||||
|
groups = {snappy=3},
|
||||||
|
sounds = default.node_sound_leaves_defaults(),
|
||||||
|
selection_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {-1/3, -1/2, -1/3, 1/3, 1/6, 1/3},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Crafting items
|
-- Crafting items
|
||||||
--
|
--
|
||||||
|
|
|
@ -183,6 +183,39 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- Generate dry shrubs
|
||||||
|
local perlin1 = minetest.env:get_perlin(329, 3, 0.6, 100)
|
||||||
|
-- Assume X and Z lengths are equal
|
||||||
|
local divlen = 16
|
||||||
|
local divs = (maxp.x-minp.x)/divlen+1;
|
||||||
|
for divx=0,divs-1 do
|
||||||
|
for divz=0,divs-1 do
|
||||||
|
local x0 = minp.x + math.floor((divx+0)*divlen)
|
||||||
|
local z0 = minp.z + math.floor((divz+0)*divlen)
|
||||||
|
local x1 = minp.x + math.floor((divx+1)*divlen)
|
||||||
|
local z1 = minp.z + math.floor((divz+1)*divlen)
|
||||||
|
-- Determine cactus amount from perlin noise
|
||||||
|
local cactus_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 5 + 2)
|
||||||
|
-- Find random positions for cactus based on this random
|
||||||
|
local pr = PseudoRandom(seed+1)
|
||||||
|
for i=0,cactus_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.env:get_node({x=x,y=y,z=z}).name ~= "air" then
|
||||||
|
ground_y = y
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- If desert sand, make cactus
|
||||||
|
if ground_y and minetest.env:get_node({x=x,y=ground_y,z=z}).name == "default:desert_sand" then
|
||||||
|
minetest.env:set_node({x=x,y=ground_y+1,z=z}, {name="default:dry_shrub"})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
BIN
mods/default/textures/default_dry_shrub.png
Normal file
BIN
mods/default/textures/default_dry_shrub.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 450 B |
Loading…
Reference in New Issue
Block a user