From befc604af39a3d0adeec1657a10c694564894433 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 7 Apr 2012 15:37:31 +0300 Subject: [PATCH] Add cactus generation, desert_sand and desert_stone --- mods/default/init.lua | 19 ++++++++ mods/default/mapgen.lua | 46 +++++++++++++++++- mods/default/textures/default_cactus_side.png | Bin 279 -> 763 bytes mods/default/textures/default_cactus_top.png | Bin 236 -> 682 bytes mods/default/textures/default_desert_sand.png | Bin 0 -> 627 bytes .../default/textures/default_desert_stone.png | Bin 0 -> 517 bytes 6 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 mods/default/textures/default_desert_sand.png create mode 100644 mods/default/textures/default_desert_stone.png diff --git a/mods/default/init.lua b/mods/default/init.lua index 6f0ed21..3ff05e2 100644 --- a/mods/default/init.lua +++ b/mods/default/init.lua @@ -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 diff --git a/mods/default/mapgen.lua b/mods/default/mapgen.lua index c6e7d24..e6e08c7 100644 --- a/mods/default/mapgen.lua +++ b/mods/default/mapgen.lua @@ -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 diff --git a/mods/default/textures/default_cactus_side.png b/mods/default/textures/default_cactus_side.png index fc479fde6f9dc859180035ee3974c1ffb198136c..395dd0d64ffde7c81d97de2282d412c8a7e9a4ca 100644 GIT binary patch delta 699 zcmV;s0!00n0{aD!On=-22Miz+*rSa2bNptuqQi_j)ER(mLZ(29yX7rN-eg$gc21QA85xCq!LT7rw0f(Q!k1^)!W zBG!eqmBgB8a_>FoxOiK-8;0kZdFGj!toeZY?nf9;m|Y^D=6|0pnmMCgvW!ND-5X3* zY&;X4-YkT`m7fUBKI4Dcd@icSRAbt0CSxXhTsRp`MzlI)4OTubG+NXZGqZ&6--%SL zepZlCj#KB!F4c%*?-%Ma5!O#e{e@Jhn(*D*Q8;q8kWbT{OLEH*UmTChF`F+%tv)Jb zoLDRL=TRr6kAJ;h2s1IS% zLRoVDsi-}hfb9VxXZ6!U9_S9zDAk0=-zrSE2<1LU-z{W0dCu{3g?691M7 z(@ntf9)DMVX8thS*IB%mOfqt3i|J|hwg~aHsM@ETB*|;b(Re>?p*(Vb66R!vwt z7PWfm7REbd&HL4h57HcvO>ylq!-EO%)$`GdmkN!Un+8i}&K+X!FD{;mLTDtTEa2`(IHN!USCuc8Ls6OVF$-R+R%R92ZY6Qy(D6r?(&$o4-OBoh{$+xz{t#={!I9nd5i7eJ%~7}nP=g7 zsG4Q=s%1i@WIf21>}wN$wGr{MiT>kcIQ>jlWAqlAh@6?q)fhM3 diff --git a/mods/default/textures/default_cactus_top.png b/mods/default/textures/default_cactus_top.png index f9e68df5114b04f48290dc277b9d73f49db941cc..60a193c4a811d0890d52ac24bbcc21f3784aba7d 100644 GIT binary patch delta 617 zcmV-v0+#*k0jdR%On=-22Miz*u2@6^0006!NkldJl6;4%y@LB0T50}4nG8i*d0h8Uqfg`G!^@vbE$Xn!W4wUMIs9NIbf8e)JD zp?jLGH7Sw zZfH8H8nWykcuKH!*Rg(NDMq08#txlz24;}=K<5HbokDdY9_U=&Oabdh7E?;SetKvz zJwXnQXigEny>NsIe!O(V7E+)y;J*Xt{)LWOfKRs_{(oFT^!TGCUx0`2tpv$KTY+z2 z^Nu6M4)6LKQVJ5JW+J9Rm%ae|W5@EoB{SW$beEMrWIa$f-jYHq&CMT~zbV0tAnQP4 zl97f=*kyev1_Gp`2S1k+8u+~GP)5wkhfpp;xd5go%=X5TiFyLF-=MC&BGproKoV5b zlg6yy?P66BX7v=>iTDv)_`2cH^AlO3gH?y=f$77J?MwWJJ$o7|Iy!9CzzjOQrDoPa))M*p;00000NkvXXu0mjf Di9#HU delta 168 zcmV;Z09XI21?&NkOn=)2903_Ms&gh60001fNklPx#32;bRa{vGf6951U69E94oEQKA00(qQO+^RX1P2Tw9AeEn#{d8V1xZ9fR5;5u zkz11EMhpbAfNoNn*Y1SR8?_&_50F4rmj3?hPpgZ)07DNm95@XF zY(oUHSrYagmNme|*CT1UCfim3v{uXl$@G9&p@!I}5oRy(w9sxQ!P~WHw{O!swAY5` zq+v2d8Mdbx172PrA_3@{L=ReuZ8M=}`c(*%Ya)qi!L}8brTF*^`fD=7+`cCLeMPPF z&#$6p(AGuRMu5lJx1NLbl0fminHhzrc=>GHejUuiEG4#4LC$pj05gZ_|SgN>3uR0cO^eRd`bgc6QW>FBryuMBUr=yxER!_?V#-$ z>^uB;H&ij7V#+X$5+Z_Q7t`kL0#e|b%;)5O1nqG%mtJi5Px#32;bRa{vGf6951U69E94oEQKA00(qQO+^RX1P2Tm4K38fOaK4@m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