Add fake beach. 12 biomes! Bugfix at hud text. Bugfix at planting tree. Bugfix at growing tree.

This commit is contained in:
srifqi 2014-08-21 16:22:19 +07:00
parent 64fb16df0e
commit c7ec8b237c
5 changed files with 113 additions and 71 deletions

View File

@ -2,3 +2,22 @@ amg
===
Another Map Generator mod for Minetest
##Feature
- 12 biome
- Biomes, Trees, Nodes, etc. are modifyable
##List of Biomes
- Ice Plains
- Ice Plains Spikes
- Cold Taiga
- Stone Plain
- Extreme Hills
- Taiga
- Plains
- Flower Plains
- River
- Forest
- Savanna
- Desert

View File

@ -209,7 +209,11 @@ badd({
if y < wl then
return c_dirt
else
return c_dirt_grass
if temp > 1 and (base == wl or base == wl+1) then
return c_sand
else
return c_dirt_grass
end
end
end
end
@ -312,7 +316,11 @@ badd({
if y < wl then
return c_dirt
else
return c_dirt_savanna
if temp > 1.7 and base == wl then
return c_sand
else
return c_dirt_savanna
end
end
end
end

19
hud.lua
View File

@ -1,13 +1,24 @@
amg.hud = {}
local bedrock_timer = 0
minetest.register_globalstep(function(dtime)
if dtime < 0.1 then return end
for _,player in ipairs(minetest.get_connected_players()) do
--local pos = vector.round(player:getpos())
local pos = player:getpos()
local name = player:get_player_name()
local temp = minetest.get_perlin(5678, 7, 0.5, 512):get2d({x=pos.x,y=pos.z})
local humi = minetest.get_perlin(8765, 7, 0.5, 512):get2d({x=pos.x,y=pos.z})
local base = minetest.get_perlin(1234, 6, 0.5, 256):get2d({x=pos.x,y=pos.z})
local moun = minetest.get_perlin(4321, 6, 0.5, 256):get2d({x=pos.x,y=pos.z})
local base = math.ceil((base * -30) + wl + 10 + (moun * 15))
local temp = 0
local humi = 0
if base > 95 then
temp = 0.05
humi = 0.9
else
temp = minetest.get_perlin(5678, 7, 0.5, 512):get2d({x=pos.x,y=pos.z})
humi = minetest.get_perlin(8765, 7, 0.5, 512):get2d({x=pos.x,y=pos.z})
end
local biometext = biome.get_by_temp_humi(math.abs(temp*2),math.abs(humi*100))[2]

View File

@ -47,7 +47,6 @@ local function amg_generate(minp, maxp, seed, vm, emin, emax)
local cave = minetest.get_perlin(3456, 6, 0.5, 360) -- cave
--local laca = minetest.get_perlin(1278, 6, 0.5, 360) -- lava cave
local nizx = 0
local nizx = 0
for z = minp.z, maxp.z do
for x = minp.x, maxp.x do
nizx = nizx + 1
@ -85,6 +84,24 @@ local function amg_generate(minp, maxp, seed, vm, emin, emax)
end
end
end
end
--tree planting
local nizx = 0
for z = minp.z, maxp.z do
for x = minp.x, maxp.x do
nizx = nizx + 1
local base_ = math.ceil((base[nizx] * -30) + wl + 10 + (moun[nizx] * 15))
local temp_ = 0
local humi_ = 0
if base_ > 95 then
temp_ = 0.10
humi_ = 90
else
temp_ = math.abs(temp[nizx] * 2)
humi_ = math.abs(humi[nizx] * 100)
end
local biome__ = biome.list[biome.get_by_temp_humi(temp_,humi_)[1]]
local tr = biome__.trees
local filled = false
@ -119,13 +136,6 @@ local function amg_generate(minp, maxp, seed, vm, emin, emax)
end
end
--[[
for i = 1, #biome.spawntree do
local st = biome.spawntree
tree.spawn(st[i][1],st[i][2],data,area,seed)
end
--]]
vm:set_data(data)
vm:set_lighting({day=0, night=0})
vm:update_liquids()

108
trees.lua
View File

@ -44,21 +44,16 @@ tree.register({
maxh = 85,
grows_on = "default:dirt_with_grass",
grow = function(pos, data, area, seed, minp, maxp, pr)
local x, y_, z = pos.x, pos.y, pos.z
local x, y, z = pos.x, pos.y, pos.z
local th = pr:next(4,5)
local y = y_ + th - 1
for xx = math.max(x-2,minp.x), math.min(x+2,maxp.x) do
for yy = math.max(y-2,minp.y), math.min(y+2,maxp.y) do
for zz = math.max(z-2,minp.z), math.min(z+2,maxp.z) do
if pr:next(1,100) <= 20 then
local vi = area:index(xx, yy, zz)
add_leaves(data, vi, c_leaves, c_leaves)
end
end
end
for yy = math.max(y,minp.y), math.min(y+th,maxp.y) do
local vi = area:index(x, yy, z)
data[vi] = c_tree
end
local y = y + th - 1
for xx = math.max(x-1,minp.x), math.min(x+1,maxp.x) do
for yy = math.max(y-1,minp.y), math.min(y+1,maxp.y) do
for zz = math.max(z-1,minp.z), math.min(z+1,maxp.z) do
@ -68,9 +63,12 @@ tree.register({
end
end
for yy = math.max(y_,minp.y), math.min(y_+th,maxp.y) do
local vi = area:index(x, yy, z)
data[vi] = c_tree
for ii = 1, 8 do
local xx = x + pr:next(-2,2)
local yy = y + pr:next(-2,2)
local zz = z + pr:next(-2,2)
local vi = area:index(xx, yy, zz)
add_leaves(data, vi, c_leaves, c_leaves)
end
--print("normal tree spawned at:"..x..","..y..","..z)
@ -97,23 +95,19 @@ tree.register({
for xx = math.max(x-1,minp.x), math.min(x+1,maxp.x) do
for yy = math.max(y-1,minp.y), math.min(y+1,maxp.y) do
for zz = math.max(z-1,minp.z), math.min(z+1,maxp.z) do
if (yy ~= y and xx ~= x and zz ~= z) or yy ~= y-1 then
local vi = area:index(xx, yy, zz)
add_leaves(data, vi, c_leaves)
end
local vi = area:index(xx, yy, zz)
add_leaves(data, vi, c_leaves)
end
end
end
for xx = math.max(x-2,minp.x), math.min(x+2,maxp.x) do
for yy = math.max(y-2,minp.y), math.min(y+2,maxp.y) do
for zz = math.max(z-2,minp.z), math.min(z+2,maxp.z) do
if ((yy ~= y and xx ~= x and zz ~= z) or yy ~= y-1) and pr:next(1,100) <= 20 then
local vi = area:index(xx, yy, zz)
add_leaves(data, vi, c_leaves, c_leaves)
end
end
end
for ii = 1, 12 do
local xx = x + pr:next(-2,2)
local yy = y + pr:next(-2,2)
local zz = z + pr:next(-2,2)
local vi = area:index(xx, yy, zz)
add_leaves(data, vi, c_leaves, c_leaves)
end
--print("savanna tree spawned at:"..x..","..y..","..z)
@ -131,36 +125,32 @@ tree.register({
local x, y, z = pos.x, pos.y, pos.z
local th = pr:next(5,8)
for xx = math.max(x-2,minp.x), math.min(x+2,maxp.x) do
for zz = math.max(z-2,minp.z), math.min(z+2,maxp.z) do
if xx ~= x and zz ~= z then
local vi = area:index(xx, y+3, zz)
add_leaves(data, vi, c_leaves)
local vi = area:index(xx, y+4, zz)
data[vi] = c_snow
end
end
for yy = math.max(y,minp.y), math.min(y+th,maxp.y) do
local vi = area:index(x, yy, z)
data[vi] = c_tree
end
for xx = math.max(x-1,minp.x), math.min(x+1,maxp.x) do
for zz = math.max(z-1,minp.z), math.min(z+1,maxp.z) do
if xx ~= x and zz ~= z then
local vi = area:index(xx, y+th, zz)
add_leaves(data, vi, c_leaves)
local vi = area:index(xx, y+th+1, zz)
data[vi] = c_snow
end
for xx = math.max(x-2,minp.x), math.min(x+2,maxp.x) do
for zz = math.max(z-2,minp.z), math.min(z+2,maxp.z) do
local vi = area:index(xx, y+3, zz)
add_leaves(data, vi, c_leaves)
local vi = area:index(xx, y+4, zz)
add_leaves(data, vi, c_snow)
end
end
local vi = area:index(x, y+th+1, z)
add_leaves(data, vi, c_leaves)
local vi = area:index(x, y+th+2, z)
data[vi] = c_snow
add_leaves(data, vi, c_snow)
for yy = math.max(y,minp.y), math.min(y+th,maxp.y) do
local vi = area:index(x, yy, z)
data[vi] = c_tree
for xx = math.max(x-1,minp.x), math.min(x+1,maxp.x) do
for zz = math.max(z-1,minp.z), math.min(z+1,maxp.z) do
local vi = area:index(xx, y+th, zz)
add_leaves(data, vi, c_leaves)
local vi = area:index(xx, y+th+1, zz)
add_leaves(data, vi, c_snow)
end
end
--print("pine tree spawned at:"..x..","..y..","..z)
@ -178,6 +168,11 @@ tree.register({
local x, y, z = pos.x, pos.y, pos.z
local th = pr:next(5,8)
for yy = math.max(y,minp.y), math.min(y+th,maxp.y) do
local vi = area:index(x, yy, z)
data[vi] = c_tree
end
for xx = math.max(x-2,minp.x), math.min(x+2,maxp.x) do
for zz = math.max(z-2,minp.z), math.min(z+2,maxp.z) do
local vi = area:index(xx, y+3, zz)
@ -195,11 +190,6 @@ tree.register({
local vi = area:index(x, y+th+1, z)
add_leaves(data, vi, c_leaves)
for yy = math.max(y,minp.y), math.min(y+th,maxp.y) do
local vi = area:index(x, yy, z)
data[vi] = c_tree
end
--print("pine tree spawned at:"..x..","..y..","..z)
end
})
@ -348,8 +338,10 @@ tree.register({
for u = -1, 1 do
for i = -1, 1 do
for o = 0, h do
local vi = area:index(x+u, y+o, z+i)
data[vi] = c_ice
if data[area:index(x+u, y-1, z+i)] == c_dirt_with_snow then
local vi = area:index(x+u, y+o, z+i)
data[vi] = c_ice
end
end
end
end
@ -357,8 +349,10 @@ tree.register({
for u = 0, 1 do
for i = -1, 0 do
for o = h, j do
local vi = area:index(x+u, y+o, z+i)
data[vi] = c_ice
if data[area:index(x+u, y-1, z+i)] == c_dirt_with_snow then
local vi = area:index(x+u, y+o, z+i)
data[vi] = c_ice
end
end
end
end