1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-12-24 17:50:37 +01:00

Updated riesenpilz

This commit is contained in:
LeMagnesium 2015-06-20 21:17:29 +02:00
parent 5cb1581e77
commit e88cf46770
6 changed files with 239 additions and 207 deletions

View File

@ -10,5 +10,5 @@ If you got ideas or found bugs, please tell them to me.
TODO: TODO:
— add giant nethershroom — add more giant mushrooms
— finish supporting the mushrooms mod — finish supporting the mushrooms mod

View File

@ -5,6 +5,9 @@ riesenpilz = {}
dofile(minetest.get_modpath("riesenpilz").."/settings.lua") dofile(minetest.get_modpath("riesenpilz").."/settings.lua")
dofile(minetest.get_modpath("riesenpilz").."/functions.lua") dofile(minetest.get_modpath("riesenpilz").."/functions.lua")
--Growing Functions
local function r_area(manip, width, height, pos) local function r_area(manip, width, height, pos)
local emerged_pos1, emerged_pos2 = manip:read_from_map( local emerged_pos1, emerged_pos2 = manip:read_from_map(
{x=pos.x-width, y=pos.y, z=pos.z-width}, {x=pos.x-width, y=pos.y, z=pos.z-width},
@ -13,105 +16,104 @@ local function r_area(manip, width, height, pos)
return VoxelArea:new({MinEdge=emerged_pos1, MaxEdge=emerged_pos2}) return VoxelArea:new({MinEdge=emerged_pos1, MaxEdge=emerged_pos2})
end end
riesenpilz.vm_update = true
local function set_vm_data(manip, nodes, pos, t1, name) local function set_vm_data(manip, nodes, pos, t1, name)
manip:set_data(nodes) manip:set_data(nodes)
manip:write_to_map() manip:write_to_map()
riesenpilz.inform("a "..name.." mushroom grew at ("..pos.x.."|"..pos.y.."|"..pos.z..")", 3, t1) riesenpilz.inform("a "..name.." mushroom grew at ("..pos.x.."|"..pos.y.."|"..pos.z..")", 3, t1)
if riesenpilz.vm_update then local t1 = os.clock()
local t1 = os.clock() manip:update_map()
manip:update_map() riesenpilz.inform("map updated", 3, t1)
riesenpilz.inform("map updated", 3, t1)
end
end end
--Growing Functions
local c local c
function riesenpilz_hybridpilz(pos) function riesenpilz.red(pos, nodes, area, w)
local w = w or math.random(MAX_SIZE)
local h = w+2
local t1 = os.clock() for i = 0, h do
local manip = minetest.get_voxel_manip()
local area = r_area(manip, MAX_SIZE+1, MAX_SIZE+3, pos)
local nodes = manip:get_data()
local breite = math.random(MAX_SIZE)
local br = breite+1
local height = breite+2
for i = 0, height do
nodes[area:index(pos.x, pos.y+i, pos.z)] = c.stem nodes[area:index(pos.x, pos.y+i, pos.z)] = c.stem
end end
for l = -br+1, br do local br = w+1
for k = -1, 1, 2 do for k = -1, 1, 2 do
nodes[area:index(pos.x+br*k, pos.y+height, pos.z-l*k)] = c.head_red for l = -br+1, br do
nodes[area:index(pos.x+l*k, pos.y+height, pos.z+br*k)] = c.head_red nodes[area:index(pos.x+br*k, pos.y+h, pos.z-l*k)] = c.head_red
nodes[area:index(pos.x+l*k, pos.y+h, pos.z+br*k)] = c.head_red
end end
end end
for k = -breite, breite do for k = -w, w do
for l = -breite, breite do for l = -w, w do
nodes[area:index(pos.x+l, pos.y+height+1, pos.z+k)] = c.head_red nodes[area:index(pos.x+l, pos.y+h+1, pos.z+k)] = c.head_red
nodes[area:index(pos.x+l, pos.y+height, pos.z+k)] = c.lamellas nodes[area:index(pos.x+l, pos.y+h, pos.z+k)] = c.lamellas
end end
end end
end
local function riesenpilz_hybridpilz(pos)
local t1 = os.clock()
local w = math.random(MAX_SIZE)
local manip = minetest.get_voxel_manip()
local area = r_area(manip, w+1, w+3, pos)
local nodes = manip:get_data()
riesenpilz.red(pos, nodes, area, w)
set_vm_data(manip, nodes, pos, t1, "red") set_vm_data(manip, nodes, pos, t1, "red")
end end
function riesenpilz_brauner_minecraftpilz(pos) function riesenpilz.brown(pos, nodes, area, br)
local br = br or math.random(MAX_SIZE-1)+1
local h = br+2
local t1 = os.clock() for i in area:iterp(pos, {x=pos.x, y=pos.y+h, z=pos.z}) do
local manip = minetest.get_voxel_manip()
local area = r_area(manip, MAX_SIZE+1, MAX_SIZE+2, pos)
local nodes = manip:get_data()
local random = math.random(MAX_SIZE-1)
local br = random+1
local breite = br+1
local height = br+2
for i in area:iterp(pos, {x=pos.x, y=pos.y+height, z=pos.z}) do
nodes[i] = c.stem nodes[i] = c.stem
end end
local w = br+1
for l = -br, br do for l = -br, br do
for k = -breite, breite, breite*2 do for k = -w, w, w*2 do
nodes[area:index(pos.x+k, pos.y+height+1, pos.z+l)] = c.head_brown nodes[area:index(pos.x+k, pos.y+h+1, pos.z+l)] = c.head_brown
nodes[area:index(pos.x+l, pos.y+height+1, pos.z+k)] = c.head_brown nodes[area:index(pos.x+l, pos.y+h+1, pos.z+k)] = c.head_brown
end end
for k = -br, br do for k = -br, br do
nodes[area:index(pos.x+l, pos.y+height+1, pos.z+k)] = c.head_brown nodes[area:index(pos.x+l, pos.y+h+1, pos.z+k)] = c.head_brown
end end
end end
end
local function riesenpilz_brauner_minecraftpilz(pos)
local t1 = os.clock()
local br = math.random(MAX_SIZE-1)+1
local manip = minetest.get_voxel_manip()
local area = r_area(manip, br+1, br+3, pos)
local nodes = manip:get_data()
riesenpilz.brown(pos, nodes, area, br)
set_vm_data(manip, nodes, pos, t1, "brown") set_vm_data(manip, nodes, pos, t1, "brown")
end end
function riesenpilz_minecraft_fliegenpilz(pos) function riesenpilz.fly_agaric(pos, nodes, area, param2s)
local h = 3
local t1 = os.clock() for i = 0, h do
local manip = minetest.get_voxel_manip()
local area = r_area(manip, 2, 4, pos)
local nodes = manip:get_data()
local param2s = manip:get_param2_data()
local height = 3
for i = 0, height do
nodes[area:index(pos.x, pos.y+i, pos.z)] = c.stem nodes[area:index(pos.x, pos.y+i, pos.z)] = c.stem
end end
for j = -1, 1 do for j = -1, 1 do
for k = -1, 1 do for k = -1, 1 do
nodes[area:index(pos.x+j, pos.y+height+1, pos.z+k)] = c.head_red nodes[area:index(pos.x+j, pos.y+h+1, pos.z+k)] = c.head_red
end end
for l = 1, height do for l = 1, h do
local y = pos.y+l local y = pos.y+l
for _,p in pairs({ for _,p in pairs({
{area:index(pos.x+j, y, pos.z+2), 0}, {area:index(pos.x+j, y, pos.z+2), 0},
@ -125,6 +127,17 @@ function riesenpilz_minecraft_fliegenpilz(pos)
end end
end end
end end
end
local function riesenpilz_minecraft_fliegenpilz(pos)
local t1 = os.clock()
local manip = minetest.get_voxel_manip()
local area = r_area(manip, 2, 4, pos)
local nodes = manip:get_data()
local param2s = manip:get_param2_data()
riesenpilz.fly_agaric(pos, nodes, area, param2s)
manip:set_data(nodes) manip:set_data(nodes)
manip:set_param2_data(param2s) manip:set_param2_data(param2s)
@ -141,52 +154,48 @@ local function ran_node(a, b, ran)
return b return b
end end
function riesenpilz_lavashroom(pos) function riesenpilz.lavashroom(pos, nodes, area, h)
local h = h or 3+math.random(MAX_SIZE-2)
local t1 = os.clock() -- remove the mushroom
local manip = minetest.get_voxel_manip() nodes[area:indexp(pos)] = c.air
local area = r_area(manip, 4, MAX_SIZE+7, pos)
local nodes = manip:get_data()
local height = 3+math.random(MAX_SIZE-2)
nodes[area:index(pos.x, pos.y, pos.z)] = c.air
for i = -1, 1, 2 do for i = -1, 1, 2 do
local o = 2*i -- set the stem
for n = 0, h do
for n = 0, height do
nodes[area:index(pos.x+i, pos.y+n, pos.z)] = c.stem_brown nodes[area:index(pos.x+i, pos.y+n, pos.z)] = c.stem_brown
nodes[area:index(pos.x, pos.y+n, pos.z+i)] = c.stem_brown nodes[area:index(pos.x, pos.y+n, pos.z+i)] = c.stem_brown
end end
local o = 2*i
for l = -1, 1 do for l = -1, 1 do
for k = 2, 3 do for k = 2, 3 do
nodes[area:index(pos.x+k*i, pos.y+height+2, pos.z+l)] = c.head_brown_full nodes[area:index(pos.x+k*i, pos.y+h+2, pos.z+l)] = c.head_brown_full
nodes[area:index(pos.x+l, pos.y+height+2, pos.z+k*i)] = c.head_brown_full nodes[area:index(pos.x+l, pos.y+h+2, pos.z+k*i)] = c.head_brown_full
end end
nodes[area:index(pos.x+l, pos.y+height+1, pos.z+o)] = c.head_brown_full nodes[area:index(pos.x+l, pos.y+h+1, pos.z+o)] = c.head_brown_full
nodes[area:index(pos.x+o, pos.y+height+1, pos.z+l)] = c.head_brown_full nodes[area:index(pos.x+o, pos.y+h+1, pos.z+l)] = c.head_brown_full
end end
for m = -1, 1, 2 do for m = -1, 1, 2 do
for k = 2, 3 do for k = 2, 3 do
for j = 2, 3 do for j = 2, 3 do
nodes[area:index(pos.x+j*i, pos.y+height+2, pos.z+k*m)] = ran_node(c.head_yellow, c.head_orange, 7) nodes[area:index(pos.x+j*i, pos.y+h+2, pos.z+k*m)] = ran_node(c.head_yellow, c.head_orange, 7)
end end
end end
nodes[area:index(pos.x+i, pos.y+height+1, pos.z+m)] = c.head_brown_full nodes[area:index(pos.x+i, pos.y+h+1, pos.z+m)] = c.head_brown_full
nodes[area:index(pos.x+m*2, pos.y+height+1, pos.z+o)] = c.head_brown_full nodes[area:index(pos.x+m*2, pos.y+h+1, pos.z+o)] = c.head_brown_full
end end
for l = -3+1, 3 do for l = -3+1, 3 do
nodes[area:index(pos.x+3*i, pos.y+height+5, pos.z-l*i)] = ran_node(c.head_yellow, c.head_orange, 5) nodes[area:index(pos.x+3*i, pos.y+h+5, pos.z-l*i)] = ran_node(c.head_yellow, c.head_orange, 5)
nodes[area:index(pos.x+l*i, pos.y+height+5, pos.z+3*i)] = ran_node(c.head_yellow, c.head_orange, 5) nodes[area:index(pos.x+l*i, pos.y+h+5, pos.z+3*i)] = ran_node(c.head_yellow, c.head_orange, 5)
end end
for j = 0, 1 do for j = 0, 1 do
for l = -3, 3 do for l = -3, 3 do
nodes[area:index(pos.x+i*4, pos.y+height+3+j, pos.z+l)] = ran_node(c.head_yellow, c.head_orange, 6) nodes[area:index(pos.x+i*4, pos.y+h+3+j, pos.z+l)] = ran_node(c.head_yellow, c.head_orange, 6)
nodes[area:index(pos.x+l, pos.y+height+3+j, pos.z+i*4)] = ran_node(c.head_yellow, c.head_orange, 6) nodes[area:index(pos.x+l, pos.y+h+3+j, pos.z+i*4)] = ran_node(c.head_yellow, c.head_orange, 6)
end end
end end
@ -194,40 +203,46 @@ function riesenpilz_lavashroom(pos)
for k = -2, 2 do for k = -2, 2 do
for l = -2, 2 do for l = -2, 2 do
nodes[area:index(pos.x+k, pos.y+height+6, pos.z+l)] = ran_node(c.head_yellow, c.head_orange, 4) nodes[area:index(pos.x+k, pos.y+h+6, pos.z+l)] = ran_node(c.head_yellow, c.head_orange, 4)
end end
end end
end
local function riesenpilz_lavashroom(pos)
local t1 = os.clock()
local h = 3+math.random(MAX_SIZE-2)
local manip = minetest.get_voxel_manip()
local area = r_area(manip, 4, h+6, pos)
local nodes = manip:get_data()
riesenpilz.lavashroom(pos, nodes, area, h)
set_vm_data(manip, nodes, pos, t1, "lavashroom") set_vm_data(manip, nodes, pos, t1, "lavashroom")
end end
function riesenpilz_glowshroom(pos) function riesenpilz.glowshroom(pos, nodes, area, h)
local h = h or 2+math.random(MAX_SIZE)
local t1 = os.clock() for i = 0, h do
local manip = minetest.get_voxel_manip()
local area = r_area(manip, 2, MAX_SIZE+5, pos)
local nodes = manip:get_data()
local height = 2+math.random(MAX_SIZE)
local br = 2
for i = 0, height do
nodes[area:index(pos.x, pos.y+i, pos.z)] = c.stem_blue nodes[area:index(pos.x, pos.y+i, pos.z)] = c.stem_blue
end end
local br = 2
for i = -1, 1, 2 do for i = -1, 1, 2 do
for k = -br, br, 2*br do for k = -br, br, 2*br do
for l = 2, height do for l = 2, h do
nodes[area:index(pos.x+i*br, pos.y+l, pos.z+k)] = c.head_blue nodes[area:index(pos.x+i*br, pos.y+l, pos.z+k)] = c.head_blue
end end
nodes[area:index(pos.x+i*br, pos.y+1, pos.z+k)] = c.head_blue_bright nodes[area:index(pos.x+i*br, pos.y+1, pos.z+k)] = c.head_blue_bright
end end
for l = -br+1, br do for l = -br+1, br do
nodes[area:index(pos.x+i*br, pos.y+height, pos.z-l*i)] = c.head_blue nodes[area:index(pos.x+i*br, pos.y+h, pos.z-l*i)] = c.head_blue
nodes[area:index(pos.x+l*i, pos.y+height, pos.z+br*i)] = c.head_blue nodes[area:index(pos.x+l*i, pos.y+h, pos.z+br*i)] = c.head_blue
end end
end end
@ -235,69 +250,83 @@ function riesenpilz_glowshroom(pos)
for l = 0, br do for l = 0, br do
for i = -br+l, br-l do for i = -br+l, br-l do
for k = -br+l, br-l do for k = -br+l, br-l do
nodes[area:index(pos.x+i, pos.y+height+1+l, pos.z+k)] = c.head_blue nodes[area:index(pos.x+i, pos.y+h+1+l, pos.z+k)] = c.head_blue
end end
end end
end end
end
local function riesenpilz_glowshroom(pos)
local t1 = os.clock()
local h = 2+math.random(MAX_SIZE)
local manip = minetest.get_voxel_manip()
local area = r_area(manip, 2, h+3, pos)
local nodes = manip:get_data()
riesenpilz.glowshroom(pos, nodes, area, h)
set_vm_data(manip, nodes, pos, t1, "glowshroom") set_vm_data(manip, nodes, pos, t1, "glowshroom")
end end
function riesenpilz_parasol(pos) function riesenpilz.parasol(pos, nodes, area, w, h)
local t1 = os.clock() local h = h or 6+math.random(MAX_SIZE)
local height = 6+math.random(MAX_SIZE)
local br = math.random(MAX_SIZE+1,MAX_SIZE+2)
local manip = minetest.get_voxel_manip()
local area = r_area(manip, br, height, pos)
local nodes = manip:get_data()
local rh = math.random(2,3)
local bhead1 = br-1
local bhead2 = math.random(1,br-2)
--stem --stem
for i in area:iterp(pos, {x=pos.x, y=pos.y+height-2, z=pos.z}) do for i in area:iterp(pos, {x=pos.x, y=pos.y+h-2, z=pos.z}) do
nodes[i] = c.stem nodes[i] = c.stem
end end
local w = w or math.random(MAX_SIZE+1,MAX_SIZE+2)
local bhead1 = w-1
local bhead2 = math.random(1,w-2)
for _,j in pairs({ for _,j in pairs({
{bhead2, 0, c.head_brown_bright}, {bhead2, 0, c.head_brown_bright},
{bhead1, -1, c.head_binge} {bhead1, -1, c.head_binge}
}) do }) do
for i in area:iter(pos.x-j[1], pos.y+height+j[2], pos.z-j[1], pos.x+j[1], pos.y+height+j[2], pos.z+j[1]) do for i in area:iter(pos.x-j[1], pos.y+h+j[2], pos.z-j[1], pos.x+j[1], pos.y+h+j[2], pos.z+j[1]) do
nodes[i] = j[3] nodes[i] = j[3]
end end
end end
local rh = math.random(2,3)
for k = -1, 1, 2 do for k = -1, 1, 2 do
for l = 0, 1 do for l = 0, 1 do
nodes[area:index(pos.x+k, pos.y+rh, pos.z-l*k)] = c.head_white nodes[area:index(pos.x+k, pos.y+rh, pos.z-l*k)] = c.head_white
nodes[area:index(pos.x+l*k, pos.y+rh, pos.z+k)] = c.head_white nodes[area:index(pos.x+l*k, pos.y+rh, pos.z+k)] = c.head_white
end end
for l = -br+1, br do for l = -w+1, w do
nodes[area:index(pos.x+br*k, pos.y+height-2, pos.z-l*k)] = c.head_binge nodes[area:index(pos.x+w*k, pos.y+h-2, pos.z-l*k)] = c.head_binge
nodes[area:index(pos.x+l*k, pos.y+height-2, pos.z+br*k)] = c.head_binge nodes[area:index(pos.x+l*k, pos.y+h-2, pos.z+w*k)] = c.head_binge
end end
for l = -bhead1+1, bhead1 do for l = -bhead1+1, bhead1 do
nodes[area:index(pos.x+bhead1*k, pos.y+height-2, pos.z-l*k)] = c.head_white nodes[area:index(pos.x+bhead1*k, pos.y+h-2, pos.z-l*k)] = c.head_white
nodes[area:index(pos.x+l*k, pos.y+height-2, pos.z+bhead1*k)] = c.head_white nodes[area:index(pos.x+l*k, pos.y+h-2, pos.z+bhead1*k)] = c.head_white
end end
end end
end
local function riesenpilz_parasol(pos)
local t1 = os.clock()
local w = math.random(MAX_SIZE+1,MAX_SIZE+2)
local h = 6+math.random(MAX_SIZE)
local manip = minetest.get_voxel_manip()
local area = r_area(manip, w, h, pos)
local nodes = manip:get_data()
riesenpilz.parasol(pos, nodes, area, w, h)
set_vm_data(manip, nodes, pos, t1, "parasol") set_vm_data(manip, nodes, pos, t1, "parasol")
end end
function riesenpilz_apple(pos) function riesenpilz.apple(pos, nodes, area)
local t1 = os.clock()
local manip = minetest.get_voxel_manip()
local area = r_area(manip, 5, 14, pos)
local nodes = manip:get_data()
local size = 5 local size = 5
local a = size*2 local a = size*2
local b = size-1 local b = size-1
@ -329,6 +358,16 @@ function riesenpilz_apple(pos)
end end
nodes[area:index(pos.x+1, c, pos.z)] = c.brown nodes[area:index(pos.x+1, c, pos.z)] = c.brown
nodes[area:index(pos.x-3, c+1, pos.z+1)] = c.brown nodes[area:index(pos.x-3, c+1, pos.z+1)] = c.brown
end
local function riesenpilz_apple(pos)
local t1 = os.clock()
local manip = minetest.get_voxel_manip()
local area = r_area(manip, 5, 14, pos)
local nodes = manip:get_data()
riesenpilz.apple(pos, nodes, area)
manip:set_data(nodes) manip:set_data(nodes)
manip:write_to_map() manip:write_to_map()
@ -427,7 +466,7 @@ local mushrooms_list = {
r = {min=5, max=6}, r = {min=5, max=6},
grounds = {cracky=3}, grounds = {cracky=3},
neighbours = {"default:lava_source"}, neighbours = {"default:lava_source"},
light = {min=10, max=14}, light = {min=10, max=12},
interval = 1010, interval = 1010,
chance = 60, chance = 60,
}, },
@ -642,19 +681,29 @@ for name,i in pairs(mushrooms_list) do
local f = minetest.get_node({x=p.x, y=p.y+y-1, z=p.z}).name local f = minetest.get_node({x=p.x, y=p.y+y-1, z=p.z}).name
if f ~= "air" then if f ~= "air" then
-- they grown on walkable, cubic nodes -- they grown on specific nodes
local data = minetest.registered_nodes[f] local data = minetest.registered_nodes[f]
if data if data
and data.walkable and data.walkable
and data.groups
and (not data.drawtype and (not data.drawtype
or data.drawtype == "normal" or data.drawtype == "normal"
) then ) then
local ground_disallowed
for n,i in pairs(grounds) do
if data.groups[n] ~= i then
ground_disallowed = true
break
end
end
if not ground_disallowed then
-- they also need specific light strengths -- they also need specific light strengths
local light = minetest.get_node_light(pos, 0.5) local light = minetest.get_node_light(pos, 0.5)
if light >= lmin if light >= lmin
and light <= lmax then and light <= lmax then
table.insert(ps, pos) table.insert(ps, pos)
end
end end
end end
break break
@ -688,7 +737,7 @@ end)
--Mushroom Blocks --Mushroom Nodes
local pilznode_list = { local pilznode_list = {
@ -821,7 +870,7 @@ for _,i in pairs(pilznode_list) do
minetest.register_node(nodename, { minetest.register_node(nodename, {
description = desctiption, description = desctiption,
tiles = textures, tiles = textures,
groups = {oddly_breakable_by_hand=3}, groups = {oddly_breakable_by_hand=3, fall_damage_add_percent=-80},
drop = drop, drop = drop,
sounds = sounds, sounds = sounds,
}) })
@ -832,7 +881,7 @@ minetest.register_node("riesenpilz:head_red_side", {
tiles = {"riesenpilz_head.png", "riesenpilz_lamellas.png", "riesenpilz_head.png", tiles = {"riesenpilz_head.png", "riesenpilz_lamellas.png", "riesenpilz_head.png",
"riesenpilz_head.png", "riesenpilz_head.png", "riesenpilz_lamellas.png"}, "riesenpilz_head.png", "riesenpilz_head.png", "riesenpilz_lamellas.png"},
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {oddly_breakable_by_hand=3}, groups = {oddly_breakable_by_hand=3, fall_damage_add_percent=-80},
drop = {max_items = 1, drop = {max_items = 1,
items = {{items = {"riesenpilz:fly_agaric"},rarity = 20,}, items = {{items = {"riesenpilz:fly_agaric"},rarity = 20,},
{items = {"riesenpilz:head_red"},rarity = 1,}}}, {items = {"riesenpilz:head_red"},rarity = 1,}}},

View File

@ -1,7 +1,9 @@
local c local c
local function define_contents() local function define_contents()
c = { c = {
ignore = minetest.get_content_id("ignore"),
air = minetest.get_content_id("air"), air = minetest.get_content_id("air"),
stone = minetest.get_content_id("default:stone"), stone = minetest.get_content_id("default:stone"),
dirt = minetest.get_content_id("default:dirt"), dirt = minetest.get_content_id("default:dirt"),
desert_sand = minetest.get_content_id("default:desert_sand"), desert_sand = minetest.get_content_id("default:desert_sand"),
@ -43,8 +45,8 @@ end
local function find_ground(a,list) local function find_ground(a,list)
for _,nam in ipairs(list) do for i = 1,#list do
if a == nam then if a == list[i] then
return true return true
end end
end end
@ -52,25 +54,14 @@ local function find_ground(a,list)
end end
local function fix_light(minp, maxp)
local manip = minetest.get_voxel_manip()
local emerged_pos1, emerged_pos2 = manip:read_from_map(minp, maxp)
local area = VoxelArea:new({MinEdge=emerged_pos1, MaxEdge=emerged_pos2})
local nodes = manip:get_data()
manip:set_data(nodes)
manip:write_to_map()
manip:update_map()
end
local data, area local data, area
function riesenpilz_circle(nam, pos, radius, chance) function riesenpilz_circle(nam, pos, radius, chance)
for _,p in pairs(vector.circle(radius)) do for _,p in pairs(vector.circle(radius)) do
if pr:next(1,chance) == 1 then if pr:next(1,chance) == 1 then
local p = vector.add(pos, p) local p = vector.add(pos, p)
local p_p = area:indexp(p) local p_p = area:indexp(p)
if data[p_p] == c.air if (data[p_p] == c.air or data[p_p] == c.ignore)
and data[area:index(p.x, p.y-1, p.z)] == c.ground then and find_ground(data[area:index(p.x, p.y-1, p.z)], c.GROUND) then
data[p_p] = nam data[p_p] = nam
end end
end end
@ -115,6 +106,9 @@ minetest.register_on_generated(function(minp, maxp, seed)
break break
end end
end end
if biome_allowed then
break
end
end end
if not biome_allowed then if not biome_allowed then
return return
@ -198,36 +192,29 @@ minetest.register_on_generated(function(minp, maxp, seed)
if in_biome then if in_biome then
for b = minp.y,maxp.y,1 do --remove usual stuff
local p_pos = area:index(x, b, z)
local d_p_pos = data[p_pos]
for _,nam in ipairs(c.USUAL_STUFF) do
if d_p_pos == nam then
data[p_pos] = c.air
break
end
end
end
local ground_y = nil --Definition des Bodens: local ground_y = nil --Definition des Bodens:
-- for y=maxp.y,0,-1 do -- for y=maxp.y,0,-1 do
for y=maxp.y,1,-1 do for y=maxp.y,1,-1 do
if find_ground(data[area:index(x, y, z)], c.GROUND) then local p_pos = area:index(x, y, z)
local d_p_pos = data[p_pos]
for _,nam in pairs(c.USUAL_STUFF) do --remove usual stuff
if d_p_pos == nam then
data[p_pos] = c.air
p_pos = nil
break
end
end
if p_pos --else search ground_y
and find_ground(d_p_pos, c.GROUND) then
ground_y = y ground_y = y
break break
end end
end end
if ground_y then if ground_y then
local p_ground = area:index(x, ground_y, z) data[area:index(x, ground_y, z)] = c.ground
local p_boden = area:index(x, ground_y+1, z)
local d_p_ground = data[p_ground]
local d_p_boden = data[p_boden]
data[p_ground] = c.ground
for i = -1,-5,-1 do for i = -1,-5,-1 do
local p_pos = area:index(x, ground_y+i, z) local p_pos = area:index(x, ground_y+i, z)
local d_p_pos = data[p_pos] if data[p_pos] == c.desert_sand then
if d_p_pos == c.desert_sand then
data[p_pos] = c.dirt data[p_pos] = c.dirt
else else
break break
@ -235,7 +222,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
end end
local boden = {x=x,y=ground_y+1,z=z} local boden = {x=x,y=ground_y+1,z=z}
if pr:next(1,15) == 1 then if pr:next(1,15) == 1 then
data[p_boden] = c.dry_shrub data[area:index(x, ground_y+1, z)] = c.dry_shrub
elseif pr:next(1,80) == 1 then elseif pr:next(1,80) == 1 then
riesenpilz_circle(c.riesenpilz_brown, boden, pr:next(3,4), 3) riesenpilz_circle(c.riesenpilz_brown, boden, pr:next(3,4), 3)
elseif pr:next(1,85) == 1 then elseif pr:next(1,85) == 1 then
@ -248,16 +235,6 @@ minetest.register_on_generated(function(minp, maxp, seed)
riesenpilz_circle(c.riesenpilz_lavashroom, boden, pr:next(5,6), 3) riesenpilz_circle(c.riesenpilz_lavashroom, boden, pr:next(5,6), 3)
elseif pr:next(1,5000) == 1 then elseif pr:next(1,5000) == 1 then
riesenpilz_circle(c.riesenpilz_glowshroom, boden, 3, 3) riesenpilz_circle(c.riesenpilz_glowshroom, boden, 3, 3)
--[[elseif pr:next(1,80) == 1 then
env:add_node(boden, {name="riesenpilz:brown"})
elseif pr:next(1,90) == 1 then
env:add_node(boden, {name="riesenpilz:red"})
elseif pr:next(1,100) == 1 then
env:add_node(boden, {name="riesenpilz:fly_agaric"})
elseif pr:next(1,4000) == 1 then
env:add_node(boden, {name="riesenpilz:lavashroom"})
elseif pr:next(1,5000) == 1 then
env:add_node(boden, {name="riesenpilz:glowshroom"})]]
elseif pr:next(1,380) == 1 then elseif pr:next(1,380) == 1 then
tab[num] = {1, boden} tab[num] = {1, boden}
num = num+1 num = num+1
@ -278,35 +255,41 @@ minetest.register_on_generated(function(minp, maxp, seed)
end end
end end
end end
vm:set_data(data)
vm:write_to_map()
riesenpilz.inform("ground finished", 2, t1) riesenpilz.inform("ground finished", 2, t1)
local t2 = os.clock() local param2s
local single_map_update = #tab > 3 if num ~= 1 then
if single_map_update then local t2 = os.clock()
riesenpilz.vm_update = false for _,v in pairs(tab) do
end local p = v[2]
for _,v in pairs(tab) do local m = v[1]
local p = v[2] if m == 1 then
local m = v[1] riesenpilz.red(p, data, area)
if m == 1 then elseif m == 2 then
riesenpilz_hybridpilz(p) riesenpilz.brown(p, data, area)
elseif m == 2 then elseif m == 3 then
riesenpilz_brauner_minecraftpilz(p) if not param2s then
elseif m == 3 then param2s = vm:get_param2_data()
riesenpilz_minecraft_fliegenpilz(p) end
elseif m == 4 then riesenpilz.fly_agaric(p, data, area, param2s)
riesenpilz_lavashroom(p) elseif m == 4 then
elseif m == 5 then riesenpilz.lavashroom(p, data, area)
riesenpilz_parasol(p) elseif m == 5 then
riesenpilz.parasol(p, data, area)
end
end end
riesenpilz.inform("giant shrooms generated", 2, t2)
end end
if single_map_update then
riesenpilz.vm_update = true local t2 = os.clock()
fix_light(minp, maxp) vm:set_data(data)
if param2s then
vm:set_param2_data(param2s)
end end
riesenpilz.inform("giant shrooms generated", 2, t2) vm:set_lighting({day=0, night=0})
vm:calc_lighting()
vm:write_to_map()
riesenpilz.inform("data set", 2, t2)
riesenpilz.inform("done", 1, t1) riesenpilz.inform("done", 1, t1)
end) end)

View File

@ -6,10 +6,10 @@ function riesenpilz_circle(nam, pos, radius, rand, seed)
if math.floor( math.sqrt(i^2+j^2) +0.5) == radius then if math.floor( math.sqrt(i^2+j^2) +0.5) == radius then
random = PseudoRandom(ra) random = PseudoRandom(ra)
p={x=pos.x+i, y=pos.y, z=pos.z+j} p={x=pos.x+i, y=pos.y, z=pos.z+j}
if minetest.env:get_node(p).name == "air" if minetest.get_node(p).name == "air"
and random:next(1,rand) == 1 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 and minetest.get_node({x=pos.x+i, y=pos.y-1, z=pos.z+j}).name ~= "air" then
minetest.env:add_node(p, {name=nam}) minetest.add_node(p, {name=nam})
end end
ra = ra+1 ra = ra+1
end end
@ -32,10 +32,10 @@ function riesenpilz_circle(nam, pos, radius, chance)
for i = -radius, radius, 1 do for i = -radius, radius, 1 do
for j = -radius, radius, 1 do for j = -radius, radius, 1 do
if math.floor( math.sqrt(i^2+j^2) +0.5) == radius if math.floor( math.sqrt(i^2+j^2) +0.5) == radius
and minetest.env:get_node({x=pos.x+i, y=pos.y, z=pos.z+j}).name == "air" and minetest.get_node({x=pos.x+i, y=pos.y, z=pos.z+j}).name == "air"
and math.random(1,chance) == 1 and math.random(1,chance) == 1
and minetest.env:get_node({x=pos.x+i, y=pos.y-1, z=pos.z+j}).name == "riesenpilz:ground" then and minetest.get_node({x=pos.x+i, y=pos.y-1, z=pos.z+j}).name == "riesenpilz:ground" then
minetest.env:add_node({x=pos.x+i, y=pos.y, z=pos.z+j}, {name=nam}) minetest.add_node({x=pos.x+i, y=pos.y, z=pos.z+j}, {name=nam})
end end
end end
end end
@ -43,7 +43,7 @@ end
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.get_node(pos).name == evground then
return true return true
end end
end end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 254 B

After

Width:  |  Height:  |  Size: 252 B

View File

Before

Width:  |  Height:  |  Size: 232 B

After

Width:  |  Height:  |  Size: 232 B