Browse Source

add mapgen

pull/1/head
HybridDog 9 years ago
parent
commit
940974734d
  1. BIN
      233.png
  2. BIN
      BlockCSS.png
  3. 30
      init.lua
  4. 95
      mapgen.lua
  5. 7
      settings.lua
  6. BIN
      textures/riesenpilz_ground_side.png
  7. BIN
      textures/riesenpilz_ground_top.png

BIN
233.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 295 B

BIN
BlockCSS.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 B

30
init.lua

@ -8,7 +8,7 @@ local MAX_SIZE = 3
--Growing Functions
local function hybridpilz(pos)
function riesenpilz_hybridpilz(pos)
local random = math.random(MAX_SIZE)
local height = 2 + random
local breite = random
@ -40,7 +40,7 @@ local function hybridpilz(pos)
end
local function brauner_minecraftpilz(pos)
function riesenpilz_brauner_minecraftpilz(pos)
local random = math.random(MAX_SIZE-1)
local height = 3+random
local breite = 2+random
@ -58,7 +58,7 @@ local function brauner_minecraftpilz(pos)
end
local function minecraft_fliegenpilz(pos)
function riesenpilz_minecraft_fliegenpilz(pos)
local height = 3
for i = 0, height, 1 do
@ -248,6 +248,14 @@ minetest.register_node("riesenpilz:head_red_side", {
{items = {"riesenpilz:head_red"},rarity = 1,}}},
})
minetest.register_node("riesenpilz:ground", {
description = "Grass?",
tile_images = {"riesenpilz_ground_top.png","default_dirt.png","default_dirt.png^riesenpilz_ground_side.png"},
groups = {crumbly=3},
sounds = default.node_sound_dirt_defaults(),
drop = 'default:dirt'
})
--Growing
@ -261,13 +269,23 @@ minetest.register_tool("riesenpilz:growingtool", {
minetest.register_on_punchnode(function(pos, node, puncher)
if puncher:get_wielded_item():get_name() == "riesenpilz:growingtool" then
if minetest.env:get_node(pos).name == "riesenpilz:red" then
hybridpilz(pos)
riesenpilz_hybridpilz(pos)
elseif minetest.env:get_node(pos).name == "riesenpilz:fly_agaric" then
minecraft_fliegenpilz(pos)
riesenpilz_minecraft_fliegenpilz(pos)
elseif minetest.env:get_node(pos).name == "riesenpilz:brown" then
brauner_minecraftpilz(pos)
riesenpilz_brauner_minecraftpilz(pos)
elseif minetest.env:get_node(pos).name == "riesenpilz:lavashroom" then
lavashroom(pos)
end
end
end)
riesenpilz = {}
dofile(minetest.get_modpath("riesenpilz").."/settings.lua")
if riesenpilz.enable_mapgen then
dofile(minetest.get_modpath("riesenpilz") .. "/mapgen.lua")
end
print("[riesenpilz] Loaded!")

95
mapgen.lua

@ -0,0 +1,95 @@
local function find_ground(pos, nodes)
for _, evground in ipairs(nodes) do
if minetest.env: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
local boden = {x=x,y=ground_y+1,z=z}
if 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)
end
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
end
end
end
end
end
end)

7
settings.lua

@ -0,0 +1,7 @@
--This file contains configuration options for riesenpilz mod.
--Enables mapgen.
riesenpilz.enable_mapgen = false
--Enables smooth transition of biomes.
riesenpilz.smooth = false

BIN
textures/riesenpilz_ground_side.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 688 B

BIN
textures/riesenpilz_ground_top.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 633 B

Loading…
Cancel
Save