1
0
mirror of https://github.com/HybridDog/riesenpilz.git synced 2025-07-16 14:50:36 +02:00

1 Commits

Author SHA1 Message Date
8bf81458bd Version MFF. 2018-09-08 16:04:54 +02:00
89 changed files with 177 additions and 574 deletions

BIN
/ 😿

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

View File

@ -1,2 +0,0 @@
frying from http://freesound.org/people/davidkay/sounds/132472/ (WTFPL)
cutting from http://freesound.org/people/nhaudio/sounds/192416/ (WTFPL)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 303 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 276 B

View File

@ -1,203 +0,0 @@
--[[
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.get_node(p).name == "air"
and random:next(1,rand) == 1
and minetest.get_node({x=pos.x+i, y=pos.y-1, z=pos.z+j}).name ~= "air" then
minetest.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)
]]
function riesenpilz_circle(nam, pos, radius, chance)
for i = -radius, radius, 1 do
for j = -radius, radius, 1 do
if math.floor( math.sqrt(i^2+j^2) +0.5) == radius
and minetest.get_node({x=pos.x+i, y=pos.y, z=pos.z+j}).name == "air"
and math.random(1,chance) == 1
and minetest.get_node({x=pos.x+i, y=pos.y-1, z=pos.z+j}).name == "riesenpilz:ground" then
minetest.add_node({x=pos.x+i, y=pos.y, z=pos.z+j}, {name=nam})
end
end
end
end
local function find_ground(pos, nodes)
for _, evground in ipairs(nodes) do
if minetest.get_node(pos).name == evground then
return true
end
end
return false
end
local GROUND = {"default:dirt_with_grass","default:dirt","default:sand","default:desert_sand"}
USUAL_STUFF = {"default:leaves","default:apple","default:tree","default:cactus","default:papyrus"}
minetest.register_on_generated(function(minp, maxp, seed)
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)
--remove usual stuff
local trees = env:find_nodes_in_area(minp, maxp, USUAL_STUFF)
for i,v in pairs(trees) do
env:remove_node(v)
end
--Information:
local geninfo = "-#- giant mushrooms generate: x=["..minp.x.."; "..maxp.x.."] z=["..minp.z.."; "..maxp.z.."]"
print(geninfo)
minetest.chat_send_all(geninfo)
local smooth = riesenpilz.smooth
for j=0,divs do
for i=0,divs do
local x,z = x0+i,z0+j
--Check if we are in a "riesenpilz biome"
local in_biome = false
local test = perlin1:get2d({x=x, y=z})
--smooth mapgen
if smooth and (test > 0.73 or (test > 0.43 and pr:next(0,29) > (0.73 - test) * 100 )) then
in_biome = true
elseif (not smooth) and test > 0.53 then
in_biome = true
end
if in_biome then
local ground_y = nil --Definition des Bodens:
for y=maxp.y,0,-1 do
if find_ground({x=x,y=y,z=z}, GROUND) then
ground_y = y
break
end
end
if ground_y then
env:add_node({x=x,y=ground_y,z=z}, {name="riesenpilz:ground"})
for i = -1,-5,-1 do
local pos = {x=x,y=ground_y+i,z=z}
if env:get_node(pos).name == "default:desert_sand" then
env:add_node(pos, {name="default:dirt"})
else
break
end
end
local boden = {x=x,y=ground_y+1,z=z}
if pr:next(1,15) == 1 then
env:add_node(boden, {name="default:dry_shrub"})
elseif pr:next(1,80) == 1 then
riesenpilz_circle("riesenpilz:brown", boden, pr:next(3,4), 3)
elseif pr:next(1,90) == 1 then
riesenpilz_circle("riesenpilz:red", boden, pr:next(4,5), 3)
elseif pr:next(1,100) == 1 then
riesenpilz_circle("riesenpilz:fly_agaric", boden, 4, 3)
elseif pr:next(1,4000) == 1 then
riesenpilz_circle("riesenpilz:lavashroom", boden, pr:next(5,6), 3)
elseif pr:next(1,5000) == 1 then
riesenpilz_circle("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
riesenpilz_hybridpilz(boden)
elseif pr:next(1,340) == 10 then
riesenpilz_brauner_minecraftpilz(boden)
elseif pr:next(1,390) == 20 then
riesenpilz_minecraft_fliegenpilz(boden)
elseif pr:next(1,6000) == 2 and pr:next(1,200) == 15 then
riesenpilz_lavashroom(boden)
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)

Binary file not shown.

0
.gitignore vendored Normal file → Executable file
View File

0
LICENSE.txt Normal file → Executable file
View File

19
README.md Normal file → Executable file
View File

@ -2,20 +2,17 @@
This mod adds mushrooms to minetest. The growing tool can make them giant.
**Depends:** see [depends.txt](https://raw.githubusercontent.com/HybridDog/riesenpilz/master/depends.txt)<br/>
**License:** see [LICENSE.txt](https://raw.githubusercontent.com/HybridDog/riesenpilz/master/LICENSE.txt)<br/>
**Download:** [zip](https://github.com/HybridDog/riesenpilz/archive/master.zip), [tar.gz](https://github.com/HybridDog/riesenpilz/archive/master.tar.gz)<br/>
**Depends:** see [depends.txt](https://raw.githubusercontent.com/HybridDog/riesenpilz/master/depends.txt)
**License:** see [LICENSE.txt](https://raw.githubusercontent.com/HybridDog/riesenpilz/master/LICENSE.txt)
**Download:** [zip](https://github.com/HybridDog/riesenpilz/archive/master.zip), [tar.gz](https://github.com/HybridDog/riesenpilz/archive/master.tar.gz)
![I'm a screenshot!](https://cloud.githubusercontent.com/assets/3192173/5332059/421c735a-7e47-11e4-88cc-b9ed90b659a8.png)
If you got ideas or found bugs, please tell them to me.
TODO:
* add more giant mushrooms
* finish supporting the mushrooms mod
* add lava suit
* use visual_scale → crop textures and change nodeboxes (maybe automatically)
* make the growingtool craftable
* mapgen: do not use fixed tree stuff
* add settingtypes.txt
TODO:
add more giant mushrooms
finish supporting the mushrooms mod
add lava suit
— eating must become possible

3
depends.txt Normal file → Executable file
View File

@ -1,5 +1,4 @@
default
vector_extras
digilines?
fence_registration?
technic?
watershed?

2
functions.lua Normal file → Executable file
View File

@ -7,7 +7,7 @@ if riesenpilz.info then
else
info = "[riesenpilz] "..msg
end
print(info)
minetest.log("action", info)
if riesenpilz.inform_all then
minetest.chat_send_all(info)
end

276
init.lua Normal file → Executable file
View File

@ -17,55 +17,8 @@ local function r_area(manip, width, height, pos)
return VoxelArea:new({MinEdge=emerged_pos1, MaxEdge=emerged_pos2})
end
-- contents become added later
local c
-- cache buildable_to ids
local re_al_cache = {[minetest.get_content_id("ignore")] = true}
local function replacing_allowed(id)
if re_al_cache[id] ~= nil then
return re_al_cache[id]
end
local def = minetest.registered_nodes[minetest.get_name_from_content_id(id)]
if not def
or def.buildable_to then
re_al_cache[id] = true
return true
end
re_al_cache[id] = false
return false
end
local set_vm_nodes
if riesenpilz.giant_restrict_area then
function set_vm_nodes(manip, pznodes)
local nodes = manip:get_data()
for vi,id in pairs(pznodes) do
if not replacing_allowed(nodes[vi]) then
return false
end
nodes[vi] = id
end
manip:set_data(nodes)
return true
end
else
function set_vm_nodes(manip, pznodes)
local nodes = manip:get_data()
for vi,id in pairs(pznodes) do
if replacing_allowed(nodes[vi]) then
nodes[vi] = id
end
end
manip:set_data(nodes)
return true
end
end
local function set_vm_data(manip, pznodes, pos, t1, name)
if not set_vm_nodes(manip, pznodes) then
return
end
local function set_vm_data(manip, nodes, pos, t1, name)
manip:set_data(nodes)
manip:write_to_map()
riesenpilz.inform("a giant "..name.." mushroom grew at "..vector.pos_to_string(pos), 3, t1)
local t1 = os.clock()
@ -74,6 +27,9 @@ local function set_vm_data(manip, pznodes, pos, t1, name)
end
-- contents become added later
local c
function riesenpilz.red(pos, nodes, area, w)
local w = w or math.random(MAX_SIZE)
local h = w+2
@ -105,11 +61,11 @@ local function riesenpilz_hybridpilz(pos)
local manip = minetest.get_voxel_manip()
local area = r_area(manip, w+1, w+3, pos)
local nodes = manip:get_data()
local pznodes = {}
riesenpilz.red(pos, pznodes, area, w)
riesenpilz.red(pos, nodes, area, w)
set_vm_data(manip, pznodes, pos, t1, "red")
set_vm_data(manip, nodes, pos, t1, "red")
end
@ -140,11 +96,11 @@ local function riesenpilz_brauner_minecraftpilz(pos)
local manip = minetest.get_voxel_manip()
local area = r_area(manip, br+1, br+3, pos)
local nodes = manip:get_data()
local pznodes = {}
riesenpilz.brown(pos, pznodes, area, br)
riesenpilz.brown(pos, nodes, area, br)
set_vm_data(manip, pznodes, pos, t1, "brown")
set_vm_data(manip, nodes, pos, t1, "brown")
end
@ -180,14 +136,12 @@ local function riesenpilz_minecraft_fliegenpilz(pos)
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 pznodes = {}
riesenpilz.fly_agaric(pos, pznodes, area, param2s)
riesenpilz.fly_agaric(pos, nodes, area, param2s)
if not set_vm_nodes(manip, pznodes) then
return
end
manip:set_data(nodes)
manip:set_param2_data(param2s)
manip:write_to_map()
manip:update_map()
@ -263,11 +217,11 @@ local function riesenpilz_lavashroom(pos)
local manip = minetest.get_voxel_manip()
local area = r_area(manip, 4, h+6, pos)
local nodes = manip:get_data()
local pznodes = {}
riesenpilz.lavashroom(pos, pznodes, area, h)
riesenpilz.lavashroom(pos, nodes, area, h)
set_vm_data(manip, pznodes, pos, t1, "lavashroom")
set_vm_data(manip, nodes, pos, t1, "lavashroom")
end
@ -312,11 +266,11 @@ local function riesenpilz_glowshroom(pos)
local manip = minetest.get_voxel_manip()
local area = r_area(manip, 2, h+3, pos)
local nodes = manip:get_data()
local pznodes = {}
riesenpilz.glowshroom(pos, pznodes, area, h)
riesenpilz.glowshroom(pos, nodes, area, h)
set_vm_data(manip, pznodes, pos, t1, "glowshroom")
set_vm_data(manip, nodes, pos, t1, "glowshroom")
end
@ -366,11 +320,11 @@ local function riesenpilz_parasol(pos)
local manip = minetest.get_voxel_manip()
local area = r_area(manip, w, h, pos)
local nodes = manip:get_data()
local pznodes = {}
riesenpilz.parasol(pos, pznodes, area, w, h)
riesenpilz.parasol(pos, nodes, area, w, h)
set_vm_data(manip, pznodes, pos, t1, "parasol")
set_vm_data(manip, nodes, pos, t1, "parasol")
end
@ -446,11 +400,11 @@ local function riesenpilz_red45(pos)
local manip = minetest.get_voxel_manip()
local area = r_area(manip, 3, h, pos)
local nodes = manip:get_data()
local pznodes = {}
riesenpilz.red45(pos, pznodes, area, h1, h2)
riesenpilz.red45(pos, nodes, area, h1, h2)
set_vm_data(manip, pznodes, pos, t1, "red45")
set_vm_data(manip, nodes, pos, t1, "red45")
end
@ -476,16 +430,16 @@ function riesenpilz.apple(pos, nodes, area)
nodes[area:index(pos.x, pos.y+i, pos.z)] = c.tree
end
local d = pos.y+1
local c = pos.y+1
for i = -3,1,1 do
nodes[area:index(pos.x+i, d, pos.z+1)] = c.brown
nodes[area:index(pos.x+i, c, pos.z+1)] = c.brown
end
for i = 0,1,1 do
nodes[area:index(pos.x+i+1, d, pos.z-1-i)] = c.brown
nodes[area:index(pos.x+i+2, d, pos.z-1-i)] = c.brown
nodes[area:index(pos.x+i+1, c, pos.z-1-i)] = c.brown
nodes[area:index(pos.x+i+2, c, pos.z-1-i)] = c.brown
end
nodes[area:index(pos.x+1, d, pos.z)] = c.brown
nodes[area:index(pos.x-3, d+1, pos.z+1)] = 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
end
local function riesenpilz_apple(pos)
@ -493,13 +447,11 @@ 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()
local pznodes = {}
riesenpilz.apple(pos, pznodes, area)
riesenpilz.apple(pos, nodes, area)
if not set_vm_nodes(manip, pznodes) then
return
end
manip:set_data(nodes)
manip:write_to_map()
riesenpilz.inform("an apple grew at "..vector.pos_to_string(pos), 3, t1)
manip:update_map()
@ -554,7 +506,6 @@ for name,i in pairs({
interval = 100,
chance = 18,
},
hp = 2,
},
red = {
description = "red mushroom",
@ -573,7 +524,6 @@ for name,i in pairs({
interval = 50,
chance = 30,
},
hp = -2,
},
fly_agaric = {
description = "fly agaric",
@ -590,7 +540,6 @@ for name,i in pairs({
interval = 101,
chance = 30,
},
hp = -6,
},
lavashroom = {
description = "Lavashroom",
@ -608,7 +557,6 @@ for name,i in pairs({
interval = 1010,
chance = 60,
},
hp = -1,
},
glowshroom = {
description = "Glowshroom",
@ -629,7 +577,6 @@ for name,i in pairs({
interval = 710,
chance = 320,
},
hp = -2,
},
nether_shroom = {
description = "Nether mushroom",
@ -643,7 +590,6 @@ for name,i in pairs({
{ 2/16, -1/16, -2/16, 4/16, 1/16, 2/16}
},
burntime = 6,
hp = -3,
},
parasol = {
description = "white parasol mushroom",
@ -662,7 +608,6 @@ for name,i in pairs({
interval = 51,
chance = 36,
},
hp = 3,
},
red45 = {
description = "45 red mushroom",
@ -682,7 +627,6 @@ for name,i in pairs({
interval = 1000,
chance = 180,
},
hp = 1,
},
brown45 = {
description = "45 brown mushroom",
@ -701,7 +645,6 @@ for name,i in pairs({
interval = 100,
chance = 20,
},
hp = 1,
},
}) do
local burntime = i.burntime or 1
@ -712,14 +655,7 @@ for name,i in pairs({
local nd = "riesenpilz:"..name
minetest.register_node(nd, {
description = i.description,
tiles = {
--~ {name = "riesenpilz_"..name.."_top.png", tileable_vertical = false},
--~ {name = "riesenpilz_"..name.."_bottom.png", tileable_vertical = false},
--~ {name = "riesenpilz_"..name.."_side.png", tileable_vertical = false},
"riesenpilz_"..name.."_top.png",
"riesenpilz_"..name.."_bottom.png",
"riesenpilz_"..name.."_side.png",
},
tiles = {"riesenpilz_"..name.."_top.png", "riesenpilz_"..name.."_bottom.png", "riesenpilz_"..name.."_side.png"},
inventory_image = "riesenpilz_"..name.."_side.png",
walkable = false,
buildable_to = true,
@ -729,8 +665,7 @@ for name,i in pairs({
sounds = default.node_sound_leaves_defaults(),
node_box = box,
selection_box = box,
furnace_burntime = burntime,
on_secondary_use = minetest.item_eat(i.hp),
furnace_burntime = burntime
})
local g = i.growing
@ -770,7 +705,6 @@ for name,i in pairs({
neighbors = g.neighbours,
interval = g.interval,
chance = g.chance,
catch_up = false,
action = function(pos, node)
if not abm_allowed then
return
@ -811,7 +745,7 @@ for name,i in pairs({
-- should disallow lag
abm_allowed = false
minetest.after(2, function() abm_allowed = true end)
disallowed_ps[#disallowed_ps+1] = pos
table.insert(disallowed_ps, pos)
-- witch circles
local ps = {}
@ -851,7 +785,7 @@ for name,i in pairs({
local light = minetest.get_node_light(pos, 0.5)
if light >= lmin
and light <= lmax then
ps[#ps+1] = pos
table.insert(ps, pos)
end
end
end
@ -1104,83 +1038,37 @@ minetest.register_tool("riesenpilz:growingtool", {
inventory_image = "riesenpilz_growingtool.png",
})
local grow_functions = {
["riesenpilz:red"] = riesenpilz_hybridpilz,
["riesenpilz:fly_agaric"] = riesenpilz_minecraft_fliegenpilz,
["riesenpilz:brown"] = riesenpilz_brauner_minecraftpilz,
["riesenpilz:lavashroom"] = riesenpilz_lavashroom,
["riesenpilz:glowshroom"] = riesenpilz_glowshroom,
["riesenpilz:parasol"] = riesenpilz_parasol,
["riesenpilz:red45"] = riesenpilz_red45,
["default:apple"] = riesenpilz_apple
}
local function get_grow(name)
if grow_functions[name] then
return grow_functions[name]
end
local is = {}
for i = 1,#minetest.registered_abms do
local ad = minetest.registered_abms[i]
if ad.chance > 1
and table.indexof(ad.nodenames, name) ~= -1 then
is[#is+1] = ad.action
end
end
local func
if is[1] then
function func(pos, node)
for i = 1,#is do
is[i](pos, node)
end
end
else
local def = minetest.registered_nodes[name]
if def then
if def.on_timer then
func = def.on_timer
else
func = function(pos, node, player)
if def.on_place then
def.on_place(ItemStack(name), player, {
type = "node",
under = vector.new(pos),--{x=pos.x, y=pos.y-1, z=pos.z},
above = vector.new(pos)
})
end
if def.after_place_node then
def.after_place_node(pos)
end
end
end
else
func = function() end
end
end
grow_functions[name] = func
return func
end
minetest.register_on_punchnode(function(pos, node, player)
if player:get_wielded_item():get_name() ~= "riesenpilz:growingtool"
or minetest.is_protected(pos, player:get_player_name()) then
return
end
local func = get_grow(node.name)
if func then
func(pos, node, player)
local name = node.name
if name == "riesenpilz:red" then
riesenpilz_hybridpilz(pos)
elseif name == "riesenpilz:fly_agaric" then
riesenpilz_minecraft_fliegenpilz(pos)
elseif name == "riesenpilz:brown" then
riesenpilz_brauner_minecraftpilz(pos)
elseif name == "riesenpilz:lavashroom" then
riesenpilz_lavashroom(pos)
elseif name == "riesenpilz:glowshroom" then
riesenpilz_glowshroom(pos)
elseif name == "riesenpilz:parasol" then
riesenpilz_parasol(pos)
elseif name == "riesenpilz:red45" then
riesenpilz_red45(pos)
elseif name == "default:apple" then
riesenpilz_apple(pos)
end
end)
-- Uses
-- Food
-- mush45's meal
minetest.register_craftitem("riesenpilz:mush45_meal", {
description = "Mushroom Meal",
inventory_image = "riesenpilz_mush45_meal.png",
@ -1196,54 +1084,6 @@ minetest.register_craft({
})
--[[ unfinished
if minetest.global_exists(technic) then
if minetest.global_exists(digilines) then
-- digiline light value detector
minetest.register_node("riesenpilz:light_detector" {
tiles = {"riesenpilz_light_detector.png"},
paramtype = "light",
digiline = {
receive = function(pos)
local light = minetest.get_node_light(pos)
send("light_detector", light)
end,
},
--sounds = ,
})
--technic.comp({"riesenpilz:glowshroom 10", "coal"}, "riesenpilz:light_detector")
end
--[ [
if minetest.global_exists(3darmor) then add to depends
--lavashroom skin armor, swimming in lava possible
minetest.register_craftitem("riesenpilz:lavashroom_flesh", {
description = "lavashroom's flesh",
inventory_image = "riesenpilz_lavashroom_flesh.png",
on_use = minetest.item_eat(3),
})
minetest.register_craftitem("riesenpilz:lavashroom_skin", {
description = "lavashroom's skin",
inventory_image = "riesenpilz_lavashroom_skin.png",
})
minetest.register_craftitem("riesenpilz:antilava_plate", {
description = "lava protecting plate",
inventory_image = "riesenpilz_antilava_plate.png",
})
technic.centri("riesenpilz:lavashroom", {"riesenpilz:lavashroom_flesh", "riesenpilz:lavashroom_skin"})
technic.comp("riesenpilz:lavashroom_skin 5", "riesenpilz:antilava_plate")
armor_register(plate blah)
end--] ]
})
end--]]
if riesenpilz.enable_mapgen then
dofile(modpath.."mapgen.lua")
@ -1252,7 +1092,7 @@ end
local time = math.floor(tonumber(os.clock()-load_time_start)*100+0.5)/100
local msg = "[riesenpilz] loaded after ca. "..time
if time > 0.05 then
print(msg)
minetest.log("warning", msg)
else
minetest.log("info", msg)
end

233
mapgen.lua Normal file → Executable file
View File

@ -6,7 +6,6 @@ local function define_contents()
ignore = minetest.get_content_id("ignore"),
air = minetest.get_content_id("air"),
water = minetest.get_content_id("default:water_source"),
stone = minetest.get_content_id("default:stone"),
dirt = minetest.get_content_id("default:dirt"),
desert_sand = minetest.get_content_id("default:desert_sand"),
@ -21,6 +20,7 @@ local function define_contents()
riesenpilz_glowshroom = minetest.get_content_id("riesenpilz:glowshroom"),
riesenpilz_parasol = minetest.get_content_id("riesenpilz:parasol"),
GROUND = {},
TREE_STUFF = {
minetest.get_content_id("default:tree"),
minetest.get_content_id("default:leaves"),
@ -29,75 +29,74 @@ local function define_contents()
minetest.get_content_id("default:jungleleaves"),
minetest.get_content_id("default:junglegrass"),
},
USUAL_STUFF = {
minetest.get_content_id("default:cactus"),
minetest.get_content_id("default:papyrus"),
},
}
end
local grounds = {}
function is_ground(id)
local is = grounds[id]
if is ~= nil then
return is
end
local data = minetest.registered_nodes[minetest.get_name_from_content_id(id)]
if not data
or data.paramtype == "light" then
grounds[id] = false
return false
end
local groups = data.groups
if groups
and (groups.crumbly == 3 or groups.soil == 1) then
grounds[id] = true
return true
end
grounds[id] = false
return false
end
local toremoves = {}
function is_toremove(id)
local is = toremoves[id]
if is ~= nil then
return is
end
local data = minetest.registered_nodes[minetest.get_name_from_content_id(id)]
if not data then
toremoves[id] = false
return false
end
local groups = data.groups
if groups
and groups.flammable then
toremoves[id] = true
return true
end
toremoves[id] = false
return false
end
local data = {}
local area, pr
function riesenpilz_circle(nam, pos, radius, chance)
local circle = vector.circle(radius)
for i = 1,#circle do
if pr:next(1, chance) == 1 then
local vi = area:indexp(vector.add(pos, circle[i]))
if data[vi] == c.air
and is_ground(data[vi - area.ystride]) then
data[vi] = nam
for name,data in pairs(minetest.registered_nodes) do
local groups = data.groups
if groups then
if groups.crumbly == 3
or groups.soil == 1 then
table.insert(c.GROUND, minetest.get_content_id(name))
end
end
end
end
local nosmooth_rarity = 0.5
local smooth_rarity_max = 0.6
local smooth_rarity_min = 0.4
local smooth_rarity_dif = smooth_rarity_max - smooth_rarity_min
local perlin_scale = 500
local function find_ground(a,list)
for i = 1,#list do
if a == list[i] then
return true
end
end
return false
end
local data, area
function riesenpilz_circle(nam, pos, radius, chance)
for _,p in pairs(vector.circle(radius)) do
if pr:next(1,chance) == 1 then
local p = vector.add(pos, p)
local p_p = area:indexp(p)
if (data[p_p] == c.air or data[p_p] == c.ignore)
and find_ground(data[area:index(p.x, p.y-1, p.z)], c.GROUND) then
data[p_p] = nam
end
end
end
end
local function say_info(info)
local info = "[riesenpilz] "..info
print(info)
minetest.chat_send_all(info)
end
-- perlin noise "hills" are not peaks but looking like sinus curve
local function upper_rarity(rarity)
return math.sign(rarity)*math.sin(math.abs(rarity)*math.pi/2)
end
local rarity = riesenpilz.mapgen_rarity
local riesenpilz_size = riesenpilz.mapgen_size
local nosmooth_rarity = 1-rarity/50
local perlin_scale = riesenpilz_size*100/rarity
local smooth_rarity_max, smooth_rarity_min, smooth_rarity_dif
local smooth = riesenpilz.smooth
if smooth then
local smooth_trans_size = riesenpilz.smooth_trans_size
smooth_rarity_max = upper_rarity(nosmooth_rarity+smooth_trans_size*2/perlin_scale)
smooth_rarity_min = upper_rarity(nosmooth_rarity-smooth_trans_size/perlin_scale)
smooth_rarity_dif = smooth_rarity_max-smooth_rarity_min
end
nosmooth_rarity = upper_rarity(nosmooth_rarity)
--local USUAL_STUFF = {"default:leaves","default:apple","default:tree","default:cactus","default:papyrus"}
local contents_defined
minetest.register_on_generated(function(minp, maxp, seed)
@ -142,10 +141,9 @@ minetest.register_on_generated(function(minp, maxp, seed)
local heightmap = minetest.get_mapgen_object("heightmap")
local hmi = 1
local hm_zstride = divs+1
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
vm:get_data(data)
data = vm:get_data()
area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
for p_pos in area:iterp(minp, maxp) do --remove tree stuff
@ -182,54 +180,51 @@ minetest.register_on_generated(function(minp, maxp, seed)
if in_biome then
local ymin = math.max(heightmap[hmi]-5, minp.y)
local ymax = math.min(heightmap[hmi]+20, maxp.y)
local ymin = math.max(heightmap[hmi]-5, minp.y) -- -1
-- skip the air part
local ground
local vi = area:index(x, ymax, z)
for y = ymax, ymin, -1 do
if data[vi] ~= c.air then
for y = math.min(heightmap[hmi]+20, maxp.y),ymin,-1 do
if data[area:index(x, y, z)] ~= c.air then
ground = y
break
end
vi = vi - area.ystride
end
local ground_y
if ground then
for y = ground, ymin, -1 do
local d_p_pos = data[vi]
if is_toremove(d_p_pos) then
-- remove trees etc.
data[vi] = c.air
else
if is_ground(d_p_pos) then
ground_y = y
heightmap[hmi] = y
for y = ground,ymin,-1 do
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
break
end
vi = vi - area.ystride
end
end
if ground_y then
-- add ground and dirt below if needed
data[vi] = c.ground
data[area:index(x, ground_y, z)] = c.ground
for i = -1,-5,-1 do
local p_pos = vi + i * area.ystride
if not is_ground(data[p_pos])
or data[p_pos] == c.dirt then
local p_pos = area:index(x, ground_y+i, z)
if data[p_pos] == c.desert_sand then
data[p_pos] = c.dirt
else
break
end
data[p_pos] = c.dirt
end
local bigtype
local boden = {x=x,y=ground_y+1,z=z}
if pr:next(1,15) == 1 then
data[vi + area.ystride] = c.dry_shrub
data[area:index(x, ground_y+1, z)] = c.dry_shrub
elseif pr:next(1,80) == 1 then
riesenpilz_circle(c.riesenpilz_brown, boden, pr:next(3,4), 3)
elseif pr:next(1,85) == 1 then
@ -273,51 +268,22 @@ minetest.register_on_generated(function(minp, maxp, seed)
local t2 = os.clock()
for _,v in pairs(tab) do
local p = v[2]
-- simple test for the distance to the biome border
local found_border = false
local dist = 5
local xmin = math.max(minp.x, p.x - dist)
local xmax = math.min(maxp.x, p.x + dist)
local hm_vi = (p.z - minp.z) * hm_zstride + xmin - minp.x + 1
for _ = xmin, xmax do
if not heightmap[hm_vi] then
found_border = true
break
end
hm_vi = hm_vi+1
end
if not found_border then
local zmin = math.max(minp.z, p.z - dist)
local zmax = math.min(maxp.z, p.z + dist)
hm_vi = (zmin - minp.z) * hm_zstride + p.x - minp.x + 1
for _ = zmin, zmax do
if not heightmap[hm_vi] then
found_border = true
break
end
hm_vi = hm_vi + hm_zstride
end
end
if not found_border then
local m = v[1]
if m == 1 then
riesenpilz.red(p, data, area)
elseif m == 2 then
riesenpilz.brown(p, data, area)
elseif m == 3 then
if not param2s then
param2s = vm:get_param2_data()
end
riesenpilz.fly_agaric(p, data, area, param2s)
elseif m == 4 then
riesenpilz.lavashroom(p, data, area)
elseif m == 5 then
riesenpilz.parasol(p, data, area)
elseif m == 6 then
riesenpilz.red45(p, data, area)
local m = v[1]
if m == 1 then
riesenpilz.red(p, data, area)
elseif m == 2 then
riesenpilz.brown(p, data, area)
elseif m == 3 then
if not param2s then
param2s = vm:get_param2_data()
end
riesenpilz.fly_agaric(p, data, area, param2s)
elseif m == 4 then
riesenpilz.lavashroom(p, data, area)
elseif m == 5 then
riesenpilz.parasol(p, data, area)
elseif m == 6 then
riesenpilz.red45(p, data, area)
end
end
riesenpilz.inform("giant shrooms generated", 2, t2)
@ -331,6 +297,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
vm:set_lighting({day=0, night=0})
vm:calc_lighting()
vm:write_to_map()
data = nil
area = nil
riesenpilz.inform("data set", 2, t2)

13
settings.lua Normal file → Executable file
View File

@ -1,6 +1,5 @@
--This file contains configuration options for riesenpilz mod.
-- mapgen size etc. does not work
riesenpilz.enable_mapgen = false
--Generate giant mushroom biomes everywhere
@ -9,6 +8,15 @@ riesenpilz.always_generate = false
--Enables smooth transition of biomes.
riesenpilz.smooth = true
--rarity in %
riesenpilz.mapgen_rarity = 0.25 -- Modif MFF (default = 1)
--size of the generated... (has an effect to the rarity, too)
riesenpilz.mapgen_size = 50
--approximate size of smooth transitions
riesenpilz.smooth_trans_size = 2
--says some information.
riesenpilz.info = true
@ -20,6 +28,3 @@ riesenpilz.max_spam = 2
--3d apple
riesenpilz.change_apple = true
--disallows growing a mushroom if it not every node would have a free place
riesenpilz.giant_restrict_area = false

0
sounds/riesenpilz_head.0.ogg Normal file → Executable file
View File

0
sounds/riesenpilz_head.1.ogg Normal file → Executable file
View File

0
sounds/riesenpilz_head.2.ogg Normal file → Executable file
View File

0
sounds/riesenpilz_stem.0.ogg Normal file → Executable file
View File

0
sounds/riesenpilz_stem.1.ogg Normal file → Executable file
View File

0
sounds/riesenpilz_stem.2.ogg Normal file → Executable file
View File

0
textures/3apple_apple.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 252 B

After

Width:  |  Height:  |  Size: 252 B

BIN
textures/3apple_apple_bottom.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 236 B

After

Width:  |  Height:  |  Size: 246 B

BIN
textures/3apple_apple_top.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 349 B

After

Width:  |  Height:  |  Size: 321 B

0
textures/riesenpilz_brown45_bottom.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 118 B

After

Width:  |  Height:  |  Size: 118 B

0
textures/riesenpilz_brown45_side.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 105 B

After

Width:  |  Height:  |  Size: 105 B

0
textures/riesenpilz_brown45_top.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 112 B

After

Width:  |  Height:  |  Size: 112 B

0
textures/riesenpilz_brown_bottom.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 320 B

After

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 186 B

After

Width:  |  Height:  |  Size: 182 B

0
textures/riesenpilz_fly_agaric_bottom.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 313 B

After

Width:  |  Height:  |  Size: 313 B

0
textures/riesenpilz_fly_agaric_side.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 284 B

After

Width:  |  Height:  |  Size: 284 B

0
textures/riesenpilz_fly_agaric_top.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 220 B

After

Width:  |  Height:  |  Size: 220 B

0
textures/riesenpilz_glowshroom_bottom.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 188 B

After

Width:  |  Height:  |  Size: 188 B

0
textures/riesenpilz_glowshroom_side.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 150 B

After

Width:  |  Height:  |  Size: 150 B

0
textures/riesenpilz_glowshroom_top.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 109 B

After

Width:  |  Height:  |  Size: 109 B

0
textures/riesenpilz_ground_side.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 718 B

After

Width:  |  Height:  |  Size: 718 B

0
textures/riesenpilz_ground_side_normal.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 638 B

After

Width:  |  Height:  |  Size: 638 B

0
textures/riesenpilz_ground_top.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 619 B

After

Width:  |  Height:  |  Size: 619 B

0
textures/riesenpilz_ground_top_normal.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 500 B

After

Width:  |  Height:  |  Size: 500 B

0
textures/riesenpilz_growingtool.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

0
textures/riesenpilz_head.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 695 B

After

Width:  |  Height:  |  Size: 695 B

0
textures/riesenpilz_head_binge.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 305 B

After

Width:  |  Height:  |  Size: 305 B

0
textures/riesenpilz_head_blue.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 724 B

After

Width:  |  Height:  |  Size: 724 B

0
textures/riesenpilz_head_blue_bright.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 761 B

After

Width:  |  Height:  |  Size: 761 B

BIN
textures/riesenpilz_head_brown_bright.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 186 B

After

Width:  |  Height:  |  Size: 182 B

0
textures/riesenpilz_head_normal.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 525 B

After

Width:  |  Height:  |  Size: 525 B

0
textures/riesenpilz_head_orange.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 578 B

After

Width:  |  Height:  |  Size: 578 B

0
textures/riesenpilz_head_white.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 544 B

After

Width:  |  Height:  |  Size: 544 B

0
textures/riesenpilz_head_yellow.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 535 B

After

Width:  |  Height:  |  Size: 535 B

0
textures/riesenpilz_lamellas.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 1000 B

After

Width:  |  Height:  |  Size: 1000 B

0
textures/riesenpilz_lamellas_normal.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

0
textures/riesenpilz_lavashroom_bottom.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 141 B

After

Width:  |  Height:  |  Size: 141 B

0
textures/riesenpilz_lavashroom_side.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 149 B

After

Width:  |  Height:  |  Size: 149 B

0
textures/riesenpilz_lavashroom_top.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 297 B

After

Width:  |  Height:  |  Size: 297 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 282 B

BIN
textures/riesenpilz_mush45_meal.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 124 B

After

Width:  |  Height:  |  Size: 146 B

0
textures/riesenpilz_nether_shroom_bottom.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 264 B

After

Width:  |  Height:  |  Size: 264 B

0
textures/riesenpilz_nether_shroom_side.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 184 B

After

Width:  |  Height:  |  Size: 184 B

0
textures/riesenpilz_nether_shroom_top.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 255 B

After

Width:  |  Height:  |  Size: 255 B

0
textures/riesenpilz_parasol_bottom.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 236 B

After

Width:  |  Height:  |  Size: 236 B

0
textures/riesenpilz_parasol_side.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 196 B

After

Width:  |  Height:  |  Size: 196 B

0
textures/riesenpilz_parasol_top.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 183 B

After

Width:  |  Height:  |  Size: 183 B

0
textures/riesenpilz_red45_bottom.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 140 B

After

Width:  |  Height:  |  Size: 140 B

0
textures/riesenpilz_red45_side.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 131 B

After

Width:  |  Height:  |  Size: 131 B

0
textures/riesenpilz_red45_top.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 98 B

After

Width:  |  Height:  |  Size: 98 B

0
textures/riesenpilz_red_bottom.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 302 B

After

Width:  |  Height:  |  Size: 302 B

0
textures/riesenpilz_red_side.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 267 B

After

Width:  |  Height:  |  Size: 267 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 263 B

After

Width:  |  Height:  |  Size: 261 B

0
textures/riesenpilz_stem_blue.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 633 B

After

Width:  |  Height:  |  Size: 633 B

0
textures/riesenpilz_stem_brown.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 701 B

After

Width:  |  Height:  |  Size: 701 B

0
textures/riesenpilz_stem_top.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 130 B

After

Width:  |  Height:  |  Size: 130 B

0
textures/riesenpilz_stem_white.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 521 B

After

Width:  |  Height:  |  Size: 521 B

0
textures/riesenpilz_stem_white_normal.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 338 B

After

Width:  |  Height:  |  Size: 338 B