mirror of
https://github.com/minetest/minetest_game.git
synced 2024-12-22 14:12:26 +01:00
Add cactus generation, desert_sand and desert_stone
This commit is contained in:
parent
5f6039bc3c
commit
befc604af3
@ -698,6 +698,16 @@ minetest.register_node("default:stone", {
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("default:desert_stone", {
|
||||
description = "Desert stone",
|
||||
tile_images = {"default_desert_stone.png"},
|
||||
is_ground_content = true,
|
||||
groups = {cracky=3},
|
||||
drop = 'default:cobble',
|
||||
legacy_mineral = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("default:stone_with_coal", {
|
||||
description = "Stone with coal",
|
||||
tile_images = {"default_stone.png^default_mineral_coal.png"},
|
||||
@ -754,6 +764,14 @@ minetest.register_node("default:sand", {
|
||||
sounds = default.node_sound_sand_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("default:desert_sand", {
|
||||
description = "Desert sand",
|
||||
tile_images = {"default_desert_sand.png"},
|
||||
is_ground_content = true,
|
||||
groups = {sand=1, crumbly=3},
|
||||
sounds = default.node_sound_sand_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("default:gravel", {
|
||||
description = "Gravel",
|
||||
tile_images = {"default_gravel.png"},
|
||||
@ -1356,6 +1374,7 @@ end
|
||||
|
||||
default.register_falling_node("default:sand", "default_sand.png")
|
||||
default.register_falling_node("default:gravel", "default_gravel.png")
|
||||
default.register_falling_node("default:desert_sand", "default_desert_sand.png")
|
||||
|
||||
--
|
||||
-- Global callbacks
|
||||
|
@ -22,6 +22,8 @@ minetest.register_alias("mapgen_junglegrass", "default:junglegrass")
|
||||
minetest.register_alias("mapgen_stone_with_coal", "default:stone_with_coal")
|
||||
minetest.register_alias("mapgen_stone_with_iron", "default:stone_with_iron")
|
||||
minetest.register_alias("mapgen_mese", "default:mese")
|
||||
minetest.register_alias("mapgen_desert_sand", "default:desert_sand")
|
||||
minetest.register_alias("mapgen_desert_stone", "default:desert_stone")
|
||||
|
||||
--
|
||||
-- Ore generation
|
||||
@ -68,13 +70,20 @@ local function generate_ore(name, wherein, minp, maxp, seed, chunks_per_volume,
|
||||
--print("generate_ore done")
|
||||
end
|
||||
|
||||
local function make_papyrus(pos, size)
|
||||
function default.make_papyrus(pos, size)
|
||||
for y=0,size-1 do
|
||||
local p = {x=pos.x, y=pos.y+y, z=pos.z}
|
||||
minetest.env:set_node(p, {name="default:papyrus"})
|
||||
end
|
||||
end
|
||||
|
||||
function default.make_cactus(pos, size)
|
||||
for y=0,size-1 do
|
||||
local p = {x=pos.x, y=pos.y+y, z=pos.z}
|
||||
minetest.env:set_node(p, {name="default:cactus"})
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, seed)
|
||||
generate_ore("default:stone_with_coal", "default:stone", minp, maxp, seed, 1/8/8/8, 5, -31000, 64)
|
||||
generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+1, 1/16/16/16, 5, -5, 7)
|
||||
@ -136,7 +145,40 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
||||
local z = pr:next(z0, z1)
|
||||
if minetest.env:get_node({x=x,y=1,z=z}).name == "default:dirt_with_grass" and
|
||||
minetest.env:find_node_near({x=x,y=1,z=z}, 1, "default:water_source") then
|
||||
make_papyrus({x=x,y=2,z=z}, pr:next(2, 4))
|
||||
default.make_papyrus({x=x,y=2,z=z}, pr:next(2, 4))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Generate cactuses
|
||||
local perlin1 = minetest.env:get_perlin(230, 3, 0.7, 100)
|
||||
-- Assume X and Z lengths are equal
|
||||
local divlen = 8
|
||||
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}) * 6 - 5)
|
||||
-- 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
|
||||
default.make_cactus({x=x,y=ground_y+1,z=z}, pr:next(3, 4))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 279 B After Width: | Height: | Size: 763 B |
Binary file not shown.
Before Width: | Height: | Size: 236 B After Width: | Height: | Size: 682 B |
BIN
mods/default/textures/default_desert_sand.png
Normal file
BIN
mods/default/textures/default_desert_sand.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 627 B |
BIN
mods/default/textures/default_desert_stone.png
Normal file
BIN
mods/default/textures/default_desert_stone.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 517 B |
Loading…
Reference in New Issue
Block a user