1
0
mirror of https://github.com/HybridDog/riesenpilz.git synced 2024-11-05 01:40:40 +01:00

add 3apple

This commit is contained in:
HybridDog 2013-05-10 20:08:50 +02:00
parent 9c221d1918
commit 096e27c050
5 changed files with 136 additions and 0 deletions

View File

@ -198,6 +198,70 @@ function riesenpilz_glowshroom(pos)
end end
function riesenpilz_apple(pos)
local size = 5
local a = size*2
local b = size-1
local red = "default:copperblock"
local brown = "default:desert_stone"
for l = -b, b, 1 do
for j = 1, a-1, 1 do
for k = -size, size, a do
minetest.env:add_node({x=pos.x+k, y=pos.y+j, z=pos.z+l}, {name=red})
minetest.env:add_node({x=pos.x+l, y=pos.y+j, z=pos.z+k}, {name=red})
end
end
for i = -b, b, 1 do
minetest.env:add_node({x=pos.x+i, y=pos.y, z=pos.z+l}, {name=red})
minetest.env:add_node({x=pos.x+i, y=pos.y+a, z=pos.z+l}, {name=red})
end
end
for i = a+1, a+b, 1 do
minetest.env:add_node({x=pos.x, y=pos.y+i, z=pos.z}, {name="default:tree"})
end
local c = pos.y+1
for i = -3,1,1 do
minetest.env:add_node({x=pos.x+i, y=c, z=pos.z+1}, {name=brown})
end
for i = 0,1,1 do
minetest.env:add_node({x=pos.x+1+i, y=c, z=pos.z-1-i}, {name=brown})
minetest.env:add_node({x=pos.x+2+i, y=c, z=pos.z-1-i}, {name=brown})
end
minetest.env:add_node({x=pos.x+1, y=c, z=pos.z}, {name=brown})
minetest.env:add_node({x=pos.x-3, y=c+1, z=pos.z+1}, {name=brown})
end
--3D apple [3apple]
minetest.register_node(":default:apple", {
description = "Apple",
drawtype = "nodebox",
visual_scale = 1.0,
tiles = {"3apple_apple_top.png","3apple_apple_bottom.png","3apple_apple.png"},
inventory_image = "default_apple.png",
paramtype = "light",
sunlight_propagates = true,
node_box = {
type = "fixed",
fixed = {
{-3/16, -7/16, -3/16, 3/16, 1/16, 3/16},
{-1/4, -3/8, -3/16, 1/4, 0, 3/16},
{-3/16, -3/8, -1/4, 3/16, 0, 1/4},
{0, 1/16, -1/16, 1/16, 1/4, 0},
{-1/16, 1/16, 0, 0, 1/4, 1/16},
}
},
groups = {fleshy=3,dig_immediate=3,flammable=2},
on_use = minetest.item_eat(4),
sounds = default.node_sound_defaults(),
})
--Mushroom Nodes --Mushroom Nodes
@ -347,6 +411,8 @@ minetest.register_on_punchnode(function(pos, node, puncher)
riesenpilz_lavashroom(pos) riesenpilz_lavashroom(pos)
elseif minetest.env:get_node(pos).name == "riesenpilz:glowshroom" then elseif minetest.env:get_node(pos).name == "riesenpilz:glowshroom" then
riesenpilz_glowshroom(pos) riesenpilz_glowshroom(pos)
elseif minetest.env:get_node(pos).name == "default:apple" then
riesenpilz_apple(pos)
end end
end end
end) end)

View File

@ -1,3 +1,32 @@
--[[
function riesenpilz_circle(nam, pos, radius, rand, seed)
local ra = seed
for i = -radius, radius, 1 do
for j = -radius, radius, 1 do
if math.floor( math.sqrt(i^2+j^2) +0.5) == radius then
random = PseudoRandom(ra)
p={x=pos.x+i, y=pos.y, z=pos.z+j}
if minetest.env:get_node(p).name == "air"
and random:next(1,rand) == 1
and minetest.env:get_node({x=pos.x+i, y=pos.y-1, z=pos.z+j}).name ~= "air" then
minetest.env:add_node(p, {name=nam})
end
ra = ra+1
end
end
end
end
elseif pr:next(1,80) == 1 then
riesenpilz_circle("riesenpilz:brown", boden, pr:next(2,3), 3, seed)
elseif pr:next(1,90) == 1 then
riesenpilz_circle("riesenpilz:red", boden, pr:next(3,4), 3, seed)
elseif pr:next(1,100) == 1 then
riesenpilz_circle("riesenpilz:fly_agaric", boden, 3, 3, seed)
elseif pr:next(1,4000) == 1 then
riesenpilz_circle("riesenpilz:lavashroom", boden, pr:next(4,5), 3, seed)
elseif pr:next(1,5000) == 1 then
riesenpilz_circle("riesenpilz:glowshroom", boden, 2, 3, seed)
]]
local function find_ground(pos, nodes) local function find_ground(pos, nodes)
for _, evground in ipairs(nodes) do for _, evground in ipairs(nodes) do
if minetest.env:get_node(pos).name == evground then if minetest.env:get_node(pos).name == evground then
@ -106,4 +135,45 @@ minetest.register_on_generated(function(minp, maxp, seed)
end end
end end
end end
if maxp.y < -10 then
local x0,z0,x1,z1 = minp.x,minp.z,maxp.x,maxp.z -- Assume X and Z lengths are equal
local env = minetest.env --Should make things a bit faster.
local perlin1 = env:get_perlin(11,3, 0.5, 200) --Get map specific perlin
--[[if not (perlin1:get2d({x=x0, y=z0}) > 0.53) and not (perlin1:get2d({x=x1, y=z1}) > 0.53)
and not (perlin1:get2d({x=x0, y=z1}) > 0.53) and not (perlin1:get2d({x=x1, y=z0}) > 0.53)
and not (perlin1:get2d({x=(x1-x0)/2, y=(z1-z0)/2}) > 0.53) then]]
if not ( perlin1:get2d( {x=x0, y=z0} ) > 0.53 ) --top left
and not ( perlin1:get2d( { x = x0 + ( (x1-x0)/2), y=z0 } ) > 0.53 )--top middle
and not (perlin1:get2d({x=x1, y=z1}) > 0.53) --bottom right
and not (perlin1:get2d({x=x1, y=z0+((z1-z0)/2)}) > 0.53) --right middle
and not (perlin1:get2d({x=x0, y=z1}) > 0.53) --bottom left
and not (perlin1:get2d({x=x1, y=z0}) > 0.53) --top right
and not (perlin1:get2d({x=x0+((x1-x0)/2), y=z1}) > 0.53) --left middle
and not (perlin1:get2d({x=(x1-x0)/2, y=(z1-z0)/2}) > 0.53) --middle
and not (perlin1:get2d({x=x0, y=z1+((z1-z0)/2)}) > 0.53) then --bottom middle
print("abortsumpf")
return
end
local divs = (maxp.x-minp.x);
local pr = PseudoRandom(seed+68)
for j=0,divs do
for i=0,divs do
local x,z = x0+i,z0+j
for y=minp.y,maxp.y,1 do
local pos = {x=x, y=y, z=z}
if env:get_node(pos).name == "air"
and env:get_node({x=x, y=y-1, z=z}).name == "default:stone"
and pr:next(1,40) == 33
and env:find_node_near(pos, 4, "group:igniter")
and not env:find_node_near(pos, 3, "group:igniter") then
env:add_node(pos, {name="riesenpilz:lavashroom"})
end
end
end
end
end
end) end)

BIN
textures/3apple_apple.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 B