Big update (1)
Update README. Add 'Swampland' biome. More common cave. 'Cutted tree' bugfix. Add 'amgmt_regenerate' to regenerate map chunk. Add 'amgmt_fixlight' to fix lighting. Add Savanna and Pine sapling, tree, leaves, and wood. Experimenting with minetest.register_ore.
This commit is contained in:
parent
1066dd9a81
commit
f1885aa687
13
README.md
13
README.md
@ -13,11 +13,19 @@ CC0 1.0 Universal
|
||||
- flowers
|
||||
|
||||
##Feature
|
||||
- 15 biome
|
||||
- 16 biome
|
||||
- Biomes, Trees, Nodes, Ores, etc. are modifyable
|
||||
- Experimental water lakes!
|
||||
- 'Moreores' mod support
|
||||
- New caving system! (May intersect with fissure)
|
||||
- Using 9 2D perlin noise and 1 3D perlin noise
|
||||
- Using 25 2D perlin noise and 1 3D perlin noise
|
||||
|
||||
##Noise usage
|
||||
- 2 noise for height
|
||||
- 2 noise for temperature and humidity
|
||||
- 1 noise for experimental water lake
|
||||
- 10 noise for caves
|
||||
- 10 noise for cave deepness
|
||||
|
||||
##List of Biomes
|
||||
- Frozen River
|
||||
@ -31,6 +39,7 @@ CC0 1.0 Universal
|
||||
- Plains
|
||||
- Flower Plains
|
||||
- River
|
||||
- Swampland
|
||||
- Forest
|
||||
- Jungle
|
||||
- Savanna
|
||||
|
63
biome.lua
63
biome.lua
@ -34,7 +34,7 @@ badd({
|
||||
return c_ice
|
||||
elseif y < base - 2 then
|
||||
return c_stone
|
||||
elseif y < base and y > base - 3 then
|
||||
elseif y < base and y >= base - 3 then
|
||||
return c_sandstone
|
||||
else
|
||||
return c_sand
|
||||
@ -55,7 +55,7 @@ badd({
|
||||
return c_water
|
||||
elseif y < base - 2 then
|
||||
return c_stone
|
||||
elseif y < base and y > base - 3 then
|
||||
elseif y < base and y >= base - 3 then
|
||||
return c_sandstone
|
||||
else
|
||||
return c_sand
|
||||
@ -85,7 +85,7 @@ badd({
|
||||
end
|
||||
elseif y < base - 2 then
|
||||
return c_stone
|
||||
elseif y < base and y > base - 3 then
|
||||
elseif y < base and y >= base - 3 then
|
||||
return c_dirt
|
||||
else
|
||||
if y < wl then
|
||||
@ -116,7 +116,7 @@ badd({
|
||||
end
|
||||
elseif y < base - 2 then
|
||||
return c_stone
|
||||
elseif y < base and y > base - 3 then
|
||||
elseif y < base and y >= base - 3 then
|
||||
return c_dirt
|
||||
else
|
||||
if y < wl then
|
||||
@ -145,7 +145,7 @@ badd({
|
||||
end
|
||||
elseif y < base - 2 then
|
||||
return c_stone
|
||||
elseif y < base and y > base - 3 then
|
||||
elseif y < base and y >= base - 3 then
|
||||
return c_dirt
|
||||
else
|
||||
if y < wl then
|
||||
@ -224,7 +224,7 @@ badd({
|
||||
end
|
||||
elseif y < base - 2 then
|
||||
return c_stone
|
||||
elseif y < base and y > base - 3 then
|
||||
elseif y < base and y >= base - 3 then
|
||||
return c_dirt
|
||||
else
|
||||
if y < wl then
|
||||
@ -253,7 +253,7 @@ badd({
|
||||
end
|
||||
elseif y < base - 2 then
|
||||
return c_stone
|
||||
elseif y < base and y > base - 3 then
|
||||
elseif y < base and y >= base - 3 then
|
||||
return c_dirt
|
||||
else
|
||||
if y < wl then
|
||||
@ -283,7 +283,7 @@ badd({
|
||||
end
|
||||
elseif y < base - 2 then
|
||||
return c_stone
|
||||
elseif y < base and y > base - 3 then
|
||||
elseif y < base and y >= base - 3 then
|
||||
return c_dirt
|
||||
else
|
||||
if y < wl then
|
||||
@ -316,7 +316,7 @@ badd({
|
||||
end
|
||||
elseif y < base - 2 then
|
||||
return c_stone
|
||||
elseif y < base and y > base - 3 then
|
||||
elseif y < base and y >= base - 3 then
|
||||
return c_dirt
|
||||
else
|
||||
if y < wl then
|
||||
@ -327,13 +327,48 @@ badd({
|
||||
end
|
||||
end
|
||||
})
|
||||
badd({
|
||||
name = "Swampland",
|
||||
mint = 1.25,
|
||||
maxt = 1.5,
|
||||
minh = 45,
|
||||
maxh = 55,
|
||||
trees = {{"normal",27},{"grass14",16}},
|
||||
get_block = function(temp, humi, base_, wl, y)
|
||||
local base = base_
|
||||
if base_ < 5 and base_ > -1 then base = base % 2 - 1 end
|
||||
if y > base and y > wl then
|
||||
return c_air
|
||||
elseif y > base and y <= wl then
|
||||
if base < wl then
|
||||
return c_water
|
||||
elseif base >= wl then
|
||||
return c_air
|
||||
end
|
||||
elseif y < base - 2 then
|
||||
return c_stone
|
||||
elseif y < base and y >= base - 3 then
|
||||
return c_dirt
|
||||
else
|
||||
if y < wl then
|
||||
return c_dirt
|
||||
else
|
||||
if temp > 1.6 and base == wl then
|
||||
return c_sand
|
||||
else
|
||||
return c_dirt_grass
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
||||
badd({
|
||||
name = "Forest",
|
||||
mint = 1.25,
|
||||
maxt = 1.5,
|
||||
minh = 0,
|
||||
maxh = 95,
|
||||
trees = {{"normal",15},{"grass14",60},{"grass35",5},{"papyrus",15},{"flowers",15}},
|
||||
trees = {{"normal",19},{"grass14",60},{"grass35",5},{"papyrus",16},{"flowers",18}},
|
||||
get_block = function(temp, humi, base, wl, y)
|
||||
if y > base and y > wl then
|
||||
return c_air
|
||||
@ -345,7 +380,7 @@ badd({
|
||||
end
|
||||
elseif y < base - 2 then
|
||||
return c_stone
|
||||
elseif y < base and y > base - 3 then
|
||||
elseif y < base and y >= base - 3 then
|
||||
return c_dirt
|
||||
else
|
||||
if y < wl then
|
||||
@ -374,7 +409,7 @@ badd({
|
||||
end
|
||||
elseif y < base - 2 then
|
||||
return c_stone
|
||||
elseif y < base and y > base - 3 then
|
||||
elseif y < base and y >= base - 3 then
|
||||
return c_dirt
|
||||
else
|
||||
if y < wl then
|
||||
@ -402,7 +437,7 @@ badd({
|
||||
end
|
||||
elseif y < base - 2 then
|
||||
return c_stone
|
||||
elseif y < base and y > base - 3 then
|
||||
elseif y < base and y >= base - 3 then
|
||||
return c_dirt
|
||||
else
|
||||
if y < wl then
|
||||
@ -434,7 +469,7 @@ badd({
|
||||
end
|
||||
elseif y < base - 2 then
|
||||
return c_sandstone
|
||||
elseif y < base and y > base - 3 then
|
||||
elseif y < base and y >= base - 3 then
|
||||
return c_sand
|
||||
else
|
||||
return c_sand
|
||||
|
191
init.lua
191
init.lua
@ -1,22 +1,16 @@
|
||||
-- Another Map Generator for Minetest [amgmt]
|
||||
-- Made by srifqi
|
||||
-- Another Map Generator for Minetest [amgmt] by srifqi
|
||||
-- License: CC0 1.0 Universal
|
||||
-- Dependencies: default, flowers
|
||||
|
||||
amgmt = {}
|
||||
print("[amgmt] (Another Map Generator for Minetest)")
|
||||
|
||||
minetest.register_on_mapgen_init(function(mgparams)
|
||||
minetest.set_mapgen_params({mgname="singlenode"})
|
||||
end)
|
||||
|
||||
--param?
|
||||
DEBUG = true -- turn this off if your debug.txt is too full
|
||||
wl = 0
|
||||
wl = 0 -- water level
|
||||
HMAX = 500
|
||||
HMIN = -30000
|
||||
BEDROCK = -4999
|
||||
BEDROCK2 = -29999
|
||||
BEDROCK = -29999 -- bedrock level
|
||||
|
||||
function amgmt.debug(text)
|
||||
if DEBUG == true then print("[amgmt]:"..(text or "")) end
|
||||
@ -29,6 +23,11 @@ dofile(minetest.get_modpath(minetest.get_current_modname()).."/trees.lua")
|
||||
dofile(minetest.get_modpath(minetest.get_current_modname()).."/biomemgr.lua")
|
||||
dofile(minetest.get_modpath(minetest.get_current_modname()).."/oremgr.lua")
|
||||
|
||||
minetest.register_on_mapgen_init(function(mgparams)
|
||||
amgmt.seed = mgparams.seed
|
||||
minetest.set_mapgen_params({mgname="singlenode", flags="nolight"})
|
||||
end)
|
||||
|
||||
local function get_perlin_map(np, minp, maxp)
|
||||
local sidelen = maxp.x - minp.x +1
|
||||
local pm = minetest.get_perlin_map(
|
||||
@ -45,11 +44,9 @@ amgmt.np = {
|
||||
m = {s = 4321, o = 6, p = 0.5, c = 256},
|
||||
t = {s = 5678, o = 7, p = 0.5, c = 512},
|
||||
h = {s = 8765, o = 7, p = 0.5, c = 512},
|
||||
c1 = {s = 1111, o = 7, p = 0.5, c = 512},
|
||||
d1 = {s = 2222, o = 7, p = 0.5, c = 512},
|
||||
c2 = {s = 3333, o = 7, p = 0.5, c = 512},
|
||||
d2 = {s = 4444, o = 7, p = 0.5, c = 512},
|
||||
l = {s = 125, o = 6, p = 0.5, c = 256},
|
||||
c = {s = 1024, o = 7, p = 0.5, c = 512},
|
||||
d = {s = 2048, o = 7, p = 0.5, c = 512},
|
||||
}
|
||||
|
||||
local np = amgmt.np
|
||||
@ -101,7 +98,12 @@ local function build_cave_segment(x, y, z, data, area, shape, radius, deletednod
|
||||
for yy = -radius, radius do
|
||||
for xx = -radius, radius do
|
||||
local vi = area:index(x+xx,y+yy,z+zz)
|
||||
if data[vi] == deletednodes and distance3(x,y,z,x+xx,y+yy,z+zz) <= radius then
|
||||
local via = area:index(x+xx,y+yy+1,z+zz)
|
||||
if
|
||||
data[vi] == deletednodes and
|
||||
distance3(x,y,z,x+xx,y+yy,z+zz) <= radius and
|
||||
data[via] == deletednodes
|
||||
then
|
||||
data[vi] = c_air
|
||||
end
|
||||
end
|
||||
@ -112,7 +114,8 @@ local function build_cave_segment(x, y, z, data, area, shape, radius, deletednod
|
||||
for yy = -radius, radius do
|
||||
for xx = -radius, radius do
|
||||
local vi = area:index(x+xx,y+yy,z+zz)
|
||||
if data[vi] == deletednodes then
|
||||
local via = area:index(x+xx,y+yy+1,z+zz)
|
||||
if data[vi] == deletednodes and data[via] == deletednodes then
|
||||
data[vi] = c_air
|
||||
end
|
||||
end
|
||||
@ -124,7 +127,8 @@ local function build_cave_segment(x, y, z, data, area, shape, radius, deletednod
|
||||
if distance2(x,z,x+xx,z+zz) <= radius then
|
||||
for yy = -radius, radius do
|
||||
local vi = area:index(x+xx,y+yy,z+zz)
|
||||
if data[vi] == deletednodes then
|
||||
local via = area:index(x+xx,y+yy+1,z+zz)
|
||||
if data[vi] == deletednodes and data[via] == deletednodes then
|
||||
data[vi] = c_air
|
||||
end
|
||||
end
|
||||
@ -143,16 +147,29 @@ local function amgmt_generate(minp, maxp, seed, vm, emin, emax)
|
||||
MaxEdge={x=emax.x, y=emax.y, z=emax.z},
|
||||
}
|
||||
local data = vm:get_data()
|
||||
|
||||
--noise
|
||||
local base = get_perlin_map(np.b, minp, maxp) -- base height
|
||||
local moun = get_perlin_map(np.m, minp, maxp) -- addition
|
||||
local temp = get_perlin_map(np.t, minp, maxp) -- temperature (0-2)
|
||||
local humi = get_perlin_map(np.h, minp, maxp) -- humidity (0-100)
|
||||
local lake = get_perlin_map(np.l, minp, maxp) -- lake
|
||||
local cav1 = get_perlin_map(np.c1, minp, maxp) -- cave1
|
||||
local dep1 = get_perlin_map(np.d1, minp, maxp) -- deep1
|
||||
local cav2 = get_perlin_map(np.c2, minp, maxp) -- cave2
|
||||
local dep2 = get_perlin_map(np.d2, minp, maxp) -- deep2
|
||||
|
||||
local cave = {} -- list of caves
|
||||
local deep = {} -- list of cave deepness
|
||||
for o = 1, 10 do
|
||||
local cnp = np.c
|
||||
cnp.s = cnp.s + o
|
||||
cave[o] = get_perlin_map(cnp, minp, maxp)
|
||||
local dnp = np.d
|
||||
dnp.s = dnp.s + o
|
||||
deep[o] = get_perlin_map(dnp, minp, maxp)
|
||||
end
|
||||
|
||||
local fissure = minetest.get_perlin(3456, 6, 0.5, 360) -- fissure
|
||||
amgmt.debug("noise calculated")
|
||||
|
||||
--terraforming
|
||||
local nizx = 0
|
||||
for z = minp.z, maxp.z do
|
||||
for x = minp.x, maxp.x do
|
||||
@ -174,17 +191,19 @@ local function amgmt_generate(minp, maxp, seed, vm, emin, emax)
|
||||
-- world height limit :(
|
||||
if y_ < HMIN or y_ > HMAX then
|
||||
-- air
|
||||
elseif y_ == BEDROCK or y_ == BEDROCK2 then
|
||||
elseif y_ == BEDROCK then
|
||||
data[vi] = c_bedrock
|
||||
--
|
||||
-- fissure
|
||||
elseif math.abs(fissure:get3d({x=x,y=y_,z=z})) < 0.0045 then
|
||||
data[vi] = c_air
|
||||
-- air
|
||||
--]]
|
||||
-- biome
|
||||
else
|
||||
--data[vi] = c_air
|
||||
data[vi] = amgmt.biome.get_block_by_temp_humi(temp_, humi_, base_, wl, y_, x, z)
|
||||
local node = amgmt.biome.get_block_by_temp_humi(temp_, humi_, base_, wl, y_, x, z)
|
||||
if node ~= c_air then
|
||||
data[vi] = node
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -200,36 +219,34 @@ local function amgmt_generate(minp, maxp, seed, vm, emin, emax)
|
||||
for z = minp.z, maxp.z do
|
||||
for x = minp.x, maxp.x do
|
||||
nizx = nizx + 1
|
||||
local cav1_ = math.abs(cav1[nizx])
|
||||
local dep1_ = dep1[nizx] * 30 + 5
|
||||
local cav2_ = math.abs(cav2[nizx])
|
||||
local dep2_ = dep2[nizx] * 50 - 25
|
||||
local base_ = math.ceil((base[nizx] * -50) + wl + 16.67 + (moun[nizx] * 15))
|
||||
--amgmt.debug(x..","..z..":"..cav1_..","..dep1_..","..cav2_..","..dep2_)
|
||||
|
||||
if cav1_ < 0.015 or cav1_ > 1-0.015 then
|
||||
local y = math.floor(wl + dep1_ + 0.5)
|
||||
local shape = (base_%3) + 1
|
||||
build_cave_segment(x, y, z, data, area, shape, 1, c_stone)
|
||||
build_cave_segment(x, y, z, data, area, shape, 1, c_dirt)
|
||||
build_cave_segment(x, y, z, data, area, shape, 1, c_dirt_grass)
|
||||
build_cave_segment(x, y, z, data, area, shape, 1, c_dirt_snow)
|
||||
build_cave_segment(x, y, z, data, area, shape, 1, c_dirt_savanna)
|
||||
--amgmt.debug("cave generated at:"..x..","..y..","..z)
|
||||
for o = 1, 10 do
|
||||
local cave_ = (cave[o][nizx]+1)/2
|
||||
local deep_ = deep[o][nizx]
|
||||
if o < 4 then
|
||||
deep_ = deep_ * 30 + 5
|
||||
elseif o < 7 then
|
||||
deep_ = deep_ * 50 - 25
|
||||
else
|
||||
deep_ = deep_ * 50 - 45
|
||||
end
|
||||
|
||||
if cav2_ < 0.015 or cav2_ > 1-0.015 then
|
||||
local y = math.floor(wl - dep2_ - 0.5)
|
||||
if cave_ < 0.001 or cave_ > 1-0.001 then
|
||||
local y = math.floor(wl + deep_ + 0.5)
|
||||
local shape = (base_%3) + 1
|
||||
build_cave_segment(x, y, z, data, area, shape, 1, c_stone)
|
||||
build_cave_segment(x, y, z, data, area, shape, 1, c_dirt)
|
||||
build_cave_segment(x, y, z, data, area, shape, 1, c_dirt_grass)
|
||||
build_cave_segment(x, y, z, data, area, shape, 1, c_dirt_snow)
|
||||
build_cave_segment(x, y, z, data, area, shape, 1, c_dirt_savanna)
|
||||
build_cave_segment(x, y, z, data, area, shape, 1, c_sandstone)
|
||||
build_cave_segment(x, y, z, data, area, shape, 1, c_sand)
|
||||
--amgmt.debug("cave generated at:"..x..","..y..","..z)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
amgmt.debug("cave generated")
|
||||
|
||||
--forming lake
|
||||
@ -239,9 +256,9 @@ local function amgmt_generate(minp, maxp, seed, vm, emin, emax)
|
||||
for cx = 0, chulen-1 do
|
||||
nizx = (cz*chulen + cx) * 16
|
||||
local found_lake = false
|
||||
for z = minp.z + cz*16, minp.z + (cz+1)*16 do
|
||||
for z = minp.z + cz*16 +3, minp.z + (cz+1)*16 -3 do -- +-3 for lake borders
|
||||
if found_lake == true then break end
|
||||
for x = minp.x + cx*16, minp.x + (cx+1)*16 do
|
||||
for x = minp.x + cx*16 +3, minp.x + (cx+1)*16 -3 do -- +-3 for lake borders
|
||||
if found_lake == true then break end
|
||||
nizx = nizx + 1
|
||||
local base_ = math.ceil((base[nizx] * -50) + wl + 16.67 + (moun[nizx] * 15))
|
||||
@ -292,6 +309,7 @@ local function amgmt_generate(minp, maxp, seed, vm, emin, emax)
|
||||
end
|
||||
amgmt.debug("lake formed")
|
||||
|
||||
--
|
||||
--tree planting
|
||||
local nizx = 0
|
||||
for z = minp.z, maxp.z do
|
||||
@ -334,21 +352,6 @@ local function amgmt_generate(minp, maxp, seed, vm, emin, emax)
|
||||
end
|
||||
end
|
||||
amgmt.debug("tree planted")
|
||||
|
||||
--[[
|
||||
for z = minp.z, maxp.z do
|
||||
for y = minp.y, maxp.y do
|
||||
local vi = area:index(x,y,z)
|
||||
for x = minp.x, maxp.x do
|
||||
local pos = {x:x,y:y,z:z}
|
||||
if data[vi] = c_dirt then
|
||||
if minetest.find_node_near(pos, 3, {"default:dirt_with_grass"}) ~= nil then
|
||||
data[vi] = c_dirt_grass
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
--]]
|
||||
|
||||
amgmt.debug("applying map data")
|
||||
@ -367,6 +370,80 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
||||
amgmt_generate(minp, maxp, seed, vm, emin, emax)
|
||||
end)
|
||||
|
||||
local function amgmt_regenerate(pos, name)
|
||||
minetest.chat_send_all("Regenerating "..name.."'s map chunk...")
|
||||
local minp = {x = 80*math.floor((pos.x+32)/80)-32,
|
||||
y = 80*math.floor((pos.y+32)/80)-32,
|
||||
z = 80*math.floor((pos.z+32)/80)-32}
|
||||
local maxp = {x = minp.x+79, y = minp.y+79, z = minp.z+79}
|
||||
local vm = minetest.get_voxel_manip()
|
||||
local emin, emax = vm:read_from_map(minp, maxp)
|
||||
local data = {}
|
||||
for i = 1, (maxp.x-minp.x+1)*(maxp.y-minp.y+1)*(maxp.z-minp.z+1) do
|
||||
data[i] = c_air
|
||||
end
|
||||
vm:set_data(data)
|
||||
vm:write_to_map()
|
||||
amgmt_generate(minp, maxp, amgmt.seed or os.clock(), vm, emin, emax)
|
||||
|
||||
minetest.chat_send_player(name, "Regenerating done, fixing lighting. This may take a while...")
|
||||
-- Fix lighting
|
||||
local nodes = minetest.find_nodes_in_area(minp, maxp, "air")
|
||||
local nnodes = #nodes
|
||||
local p = math.floor(nnodes/5)
|
||||
local dig_node = minetest.dig_node
|
||||
for _, pos in ipairs(nodes) do
|
||||
dig_node(pos)
|
||||
if _%p == 0 then
|
||||
minetest.chat_send_player(name, math.floor(_/nnodes*100).."%")
|
||||
end
|
||||
end
|
||||
minetest.chat_send_all("Done")
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("amgmt_regenerate", {
|
||||
privs = {server = true},
|
||||
func = function(name, param)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if player then
|
||||
local pos = player:getpos()
|
||||
amgmt_regenerate(pos, name)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
local function amgmt_fixlight(pos, name)
|
||||
minetest.chat_send_player(name, "Fixing lightning. This may take a while...")
|
||||
local minp = {x = 80*math.floor((pos.x+32)/80)-32,
|
||||
y = 80*math.floor((pos.y+32)/80)-32,
|
||||
z = 80*math.floor((pos.z+32)/80)-32}
|
||||
local maxp = {x = minp.x+79, y = minp.y+79, z = minp.z+79}
|
||||
|
||||
-- Fix lighting
|
||||
local nodes = minetest.find_nodes_in_area(minp, maxp, "air")
|
||||
local nnodes = #nodes
|
||||
local p = math.floor(nnodes/5)
|
||||
local dig_node = minetest.dig_node
|
||||
for _, pos in ipairs(nodes) do
|
||||
dig_node(pos)
|
||||
if _%p == 0 then
|
||||
minetest.chat_send_player(name, math.floor(_/nnodes*100).."%")
|
||||
end
|
||||
end
|
||||
minetest.chat_send_all("Done")
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("amgmt_fixlight", {
|
||||
privs = {server = true},
|
||||
func = function(name, param)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if player then
|
||||
local pos = player:getpos()
|
||||
amgmt_fixlight(pos, name)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
dofile(minetest.get_modpath(minetest.get_current_modname()).."/hud.lua")
|
||||
|
||||
print("[amgmt]:"..amgmt.tree.count.." tree(s) registered")
|
||||
|
93
nodes.lua
93
nodes.lua
@ -1,5 +1,5 @@
|
||||
minetest.register_node("amgmt:bedrock", {
|
||||
description = "amgmt's BEDROCK",
|
||||
description = "amgmt's BEDROCK (How you get this?)",
|
||||
tiles ={"default_cobble.png"},
|
||||
groups = {unbreakable = 1, not_in_creative_inventory = 1},
|
||||
sounds = default.node_sound_stone_defaults()
|
||||
@ -15,3 +15,94 @@ minetest.register_node("amgmt:dirt_at_savanna", {
|
||||
footstep = {name="default_grass_footstep", gain=0.25},
|
||||
}),
|
||||
})
|
||||
|
||||
local tree_add = {
|
||||
{"savanna","Savanna"},
|
||||
{"pine","Pine"},
|
||||
}
|
||||
|
||||
for i=1, #tree_add do
|
||||
minetest.register_node("amgmt:"..tree_add[i][1].."_tree", {
|
||||
description = tree_add[i][2].." Tree",
|
||||
tiles = {
|
||||
"default_tree_top.png",
|
||||
"default_tree_top.png",
|
||||
"default_tree.png",
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = false,
|
||||
groups = {tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_place = minetest.rotate_node
|
||||
})
|
||||
|
||||
minetest.register_node("amgmt:"..tree_add[i][1].."_sapling", {
|
||||
description = tree_add[i][2].." Sapling",
|
||||
drawtype = "plantlike",
|
||||
visual_scale = 1.0,
|
||||
tiles = {"amgmt_"..tree_add[i][1].."_sapling.png"},
|
||||
inventory_image = "amgmt_"..tree_add[i][1].."_sapling.png",
|
||||
wield_image = "amgmt_"..tree_add[i][1].."_sapling.png",
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
is_ground_content = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
|
||||
},
|
||||
groups = {snappy=2,dig_immediate=3,flammable=2,attached_node=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("amgmt:"..tree_add[i][1].."_leaves", {
|
||||
description = tree_add[i][2].." Leaves",
|
||||
drawtype = "allfaces_optional",
|
||||
waving = 1,
|
||||
visual_scale = 1.3,
|
||||
tiles = {"amgmt_"..tree_add[i][1].."_leaves.png"},
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
groups = {snappy=3, leafdecay=3, flammable=2, leaves=1},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
{
|
||||
-- player will get sapling with 1/20 chance
|
||||
items = {'amgmt:'..tree_add[i][1]..'_sapling'},
|
||||
rarity = 20,
|
||||
},
|
||||
{
|
||||
-- player will get leaves only if he get no saplings,
|
||||
-- this is because max_items is 1
|
||||
items = {'amgmt:'..tree_add[i][1]..'_leaves'},
|
||||
}
|
||||
}
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"amgmt:"..tree_add[i][1].."_sapling"},
|
||||
interval = 10,
|
||||
chance = 50,
|
||||
action = function(pos, node)
|
||||
local nu = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
|
||||
local is_soil = minetest.get_item_group(nu, "soil")
|
||||
if is_soil == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.log("action", "A "..tree_add[i][1].." sapling grows into a tree at "..minetest.pos_to_string(pos))
|
||||
local vm = minetest.get_voxel_manip()
|
||||
local minp, maxp = vm:read_from_map({x=pos.x-16, y=pos.y, z=pos.z-16}, {x=pos.x+16, y=pos.y+16, z=pos.z+16})
|
||||
local area = VoxelArea:new{MinEdge=minp, MaxEdge=maxp}
|
||||
local data = vm:get_data()
|
||||
amgmt.tree[tree_add[i][1].."_tree"](
|
||||
pos, data, area, (amgmt.seed or i), minp, maxp, PseudoRandom(os.clock())
|
||||
)
|
||||
vm:set_data(data)
|
||||
vm:write_to_map(data)
|
||||
vm:update_map()
|
||||
end
|
||||
})
|
||||
end
|
28
oremgr.lua
28
oremgr.lua
@ -35,6 +35,34 @@ function amgmt.ore.register_sheet(def)
|
||||
seeddiff_count = seeddiff_count +1
|
||||
end
|
||||
|
||||
|
||||
--[[
|
||||
minetest.register_ore({
|
||||
ore_type = "scatter",
|
||||
ore = "default:stone_with_coal",
|
||||
wherein = "default:stone",
|
||||
clust_scarcity = 8*8*8,
|
||||
clust_num_ores = 8,
|
||||
clust_size = 3,
|
||||
height_min = -31000,
|
||||
height_max = 64,
|
||||
})
|
||||
--]]
|
||||
function minetest.register_ore(def)
|
||||
amgmt.debug(def.ore.." added")
|
||||
if def.ore_type == "scatter" then
|
||||
def.wherein = def.wherein or "default:stone"
|
||||
|
||||
local multiplier = 16*16*16 / clust_scarcity
|
||||
def.clust_num = def.clust_size * multiplier
|
||||
|
||||
def.minh = def.height_min
|
||||
def.maxh = def.height_max
|
||||
|
||||
amgmt.ore.register_ore(def)
|
||||
end
|
||||
end
|
||||
|
||||
local function get_nearest_cube(n)
|
||||
for i=1, 16 do if i*i*i>=n then return i end end
|
||||
return 0
|
||||
|
BIN
textures/amgmt_pine_leaves.png
Normal file
BIN
textures/amgmt_pine_leaves.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
BIN
textures/amgmt_pine_sapling.png
Normal file
BIN
textures/amgmt_pine_sapling.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.0 KiB |
BIN
textures/amgmt_pine_wood.png
Normal file
BIN
textures/amgmt_pine_wood.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
BIN
textures/amgmt_savanna_leaves.png
Normal file
BIN
textures/amgmt_savanna_leaves.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
BIN
textures/amgmt_savanna_sapling.png
Normal file
BIN
textures/amgmt_savanna_sapling.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.0 KiB |
BIN
textures/amgmt_savanna_wood.png
Normal file
BIN
textures/amgmt_savanna_wood.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
BIN
textures/jpg.jpg
Normal file
BIN
textures/jpg.jpg
Normal file
Binary file not shown.
222
trees.lua
222
trees.lua
@ -32,6 +32,7 @@ local c_ignore = gci("ignore")
|
||||
local c_dirt_grass = gci("default:dirt_with_grass")
|
||||
local c_tree = gci("default:tree")
|
||||
local c_leaves = gci("default:leaves")
|
||||
local c_apple = gci("default:apple")
|
||||
local c_jungletree = gci("default:jungletree")
|
||||
local c_jungleleaves = gci("default:jungleleaves")
|
||||
local c_snow = gci("default:snow")
|
||||
@ -45,28 +46,36 @@ local function add_leaves(data, vi, c_leaf, other)
|
||||
end
|
||||
|
||||
--normal tree
|
||||
regtr({
|
||||
name = "normal",
|
||||
chance = 15,
|
||||
minh = 1,
|
||||
maxh = 85,
|
||||
grows_on = "default:dirt_with_grass",
|
||||
grow = function(pos, data, area, seed, minp, maxp, pr)
|
||||
function amgmt.tree.normal_tree(pos, data, area, seed, minp, maxp, pr)
|
||||
local x, y, z = pos.x, pos.y, pos.z
|
||||
local is_apple_tree = false
|
||||
if pr:next(1,100) < 25 then
|
||||
is_apple_tree = true
|
||||
end
|
||||
local th = pr:next(4,5)
|
||||
|
||||
for yy = math.max(y,minp.y), math.min(y+th,maxp.y) do
|
||||
for yy = y, y+th 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
|
||||
for xx = x-1, x+1 do
|
||||
for yy = y-1, y+1 do
|
||||
for zz = z-1, z+1 do
|
||||
if area:contains(xx,yy,zz) then
|
||||
local vi = area:index(xx, yy, zz)
|
||||
if pr:next(1,100) > 25 then
|
||||
add_leaves(data, vi, c_leaves)
|
||||
else
|
||||
if is_apple_tree == true then
|
||||
add_leaves(data, vi, c_apple)
|
||||
else
|
||||
add_leaves(data, vi, c_leaves)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -78,52 +87,59 @@ regtr({
|
||||
for xxx = 0, 1 do
|
||||
for yyy = 0, 1 do
|
||||
for zzz = 0, 1 do
|
||||
if area:contains(xx+xxx, yy+yyy, zz+zzz) then
|
||||
local vi = area:index(xx+xxx, yy+yyy, zz+zzz)
|
||||
add_leaves(data, vi, c_leaves, c_leaves)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
regtr({
|
||||
name = "normal",
|
||||
chance = 15,
|
||||
minh = 1,
|
||||
maxh = 85,
|
||||
grows_on = "default:dirt_with_grass",
|
||||
grow = function(pos, data, area, seed, minp, maxp, pr)
|
||||
amgmt.tree.normal_tree(pos, data, area, seed, minp, maxp, pr)
|
||||
|
||||
--amgmt.debug("normal tree spawned at:"..x..","..y..","..z)
|
||||
end
|
||||
})
|
||||
|
||||
--jungle tree
|
||||
regtr({
|
||||
name = "jungle",
|
||||
chance = 10,
|
||||
minh = 1,
|
||||
maxh = 85,
|
||||
grows_on = "default:dirt_with_grass",
|
||||
grow = function(pos, data, area, seed, minp, maxp, pr)
|
||||
function amgmt.tree.jungle_tree(pos, data, area, seed, minp, maxp, pr)
|
||||
local x, y, z = pos.x, pos.y, pos.z
|
||||
local th = pr:next(8,12)
|
||||
|
||||
for zz = math.max(z-1,minp.z), math.min(z+1,maxp.z) do
|
||||
for xx = math.max(x-1,minp.x), math.min(x+1,maxp.x) do
|
||||
if pr:next(1,3) >= 2 then
|
||||
for zz = z-1, z+1,maxp.z do
|
||||
for xx = x-1, x+1,maxp.x do
|
||||
if pr:next(1,3) >= 2 and area:contains(xx,y,zz) then
|
||||
local vi = area:index(xx, y, zz)
|
||||
add_leaves(data, vi, c_jungletree)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for yy = math.max(y,minp.y), math.min(y+th,maxp.y) do
|
||||
for yy = y, y+th do
|
||||
local vi = area:index(x, yy, z)
|
||||
data[vi] = c_jungletree
|
||||
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
|
||||
for xx = x-1, x+1 do
|
||||
for yy = y-1, y+1 do
|
||||
for zz = z-1, z+1 do
|
||||
if area:contains(xx,yy,zz) then
|
||||
local vi = area:index(xx, yy, zz)
|
||||
add_leaves(data, vi, c_jungleleaves)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for ii = 1, 30 do
|
||||
local xx = x + pr:next(-3,3)
|
||||
@ -132,39 +148,48 @@ regtr({
|
||||
for xxx = 0, 1 do
|
||||
for yyy = 0, 1 do
|
||||
for zzz = 0, 1 do
|
||||
if area:contains(xx+xxx, yy+yyy, zz+zzz) then
|
||||
local vi = area:index(xx+xxx, yy+yyy, zz+zzz)
|
||||
add_leaves(data, vi, c_jungleleaves, c_jungleleaves)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
regtr({
|
||||
name = "jungle",
|
||||
chance = 10,
|
||||
minh = 1,
|
||||
maxh = 85,
|
||||
grows_on = "default:dirt_with_grass",
|
||||
grow = function(pos, data, area, seed, minp, maxp, pr)
|
||||
amgmt.tree.jungle_tree(pos, data, area, seed, minp, maxp, pr)
|
||||
|
||||
--amgmt.debug("jungle tree spawned at:"..x..","..y..","..z)
|
||||
end
|
||||
})
|
||||
|
||||
--savanna tree
|
||||
regtr({
|
||||
name = "savanna",
|
||||
chance = 225,
|
||||
minh = 1,
|
||||
maxh = 85,
|
||||
grows_on = "amgmt:dirt_at_savanna",
|
||||
grow = function(pos, data, area, seed, minp, maxp, pr)
|
||||
local c_savanna_tree = gci("amgmt:savanna_tree")
|
||||
local c_savanna_leaves = gci("amgmt:savanna_leaves")
|
||||
function amgmt.tree.savanna_tree(pos, data, area, seed, minp, maxp, pr)
|
||||
local x, y, z = pos.x, pos.y, pos.z
|
||||
local th = pr:next(7,11)
|
||||
|
||||
for yy = math.max(y,minp.y), math.min(y+th,maxp.y) do
|
||||
for yy = y, y+th do
|
||||
local vi = area:index(x, yy, z)
|
||||
data[vi] = c_tree
|
||||
data[vi] = c_savanna_tree
|
||||
end
|
||||
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
|
||||
for xx = x-1, x+1 do
|
||||
for yy = y-1, y+1 do
|
||||
for zz = z-1, z+1 do
|
||||
if area:contains(xx,yy,zz) then
|
||||
local vi = area:index(xx, yy, zz)
|
||||
add_leaves(data, vi, c_leaves)
|
||||
add_leaves(data, vi, c_savanna_leaves)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -177,18 +202,58 @@ regtr({
|
||||
for xxx = 0, 1 do
|
||||
for yyy = 0, 1 do
|
||||
for zzz = 0, 1 do
|
||||
if area:contains(xx+xxx, yy+yyy, zz+zzz) then
|
||||
local vi = area:index(xx+xxx, yy+yyy, zz+zzz)
|
||||
add_leaves(data, vi, c_leaves, c_leaves)
|
||||
add_leaves(data, vi, c_savanna_leaves, c_leaves)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
regtr({
|
||||
name = "savanna",
|
||||
chance = 225,
|
||||
minh = 1,
|
||||
maxh = 85,
|
||||
grows_on = "amgmt:dirt_at_savanna",
|
||||
grow = function(pos, data, area, seed, minp, maxp, pr)
|
||||
amgmt.tree.savanna_tree(pos, data, area, seed, minp, maxp, pr)
|
||||
|
||||
--amgmt.debug("savanna tree spawned at:"..x..","..y..","..z)
|
||||
end
|
||||
})
|
||||
|
||||
local c_pine_tree = gci("amgmt:pine_tree")
|
||||
local c_pine_leaves = gci("amgmt:pine_leaves")
|
||||
--pine tree at cold taiga
|
||||
function amgmt.tree.pine_cold_tree(pos, data, area, seed, minp, maxp, pr)
|
||||
local x, y, z = pos.x, pos.y, pos.z
|
||||
local th = pr:next(8,9)
|
||||
|
||||
for yy = y, y+th do
|
||||
local vi = area:index(x, yy, z)
|
||||
data[vi] = c_pine_tree
|
||||
end
|
||||
|
||||
for xx = x-1, x+1 do
|
||||
for yy = 1, 3 do
|
||||
for zz = z-1, z+1 do
|
||||
if area:contains(xx, y+(yy*2)+1, zz) then
|
||||
local vi = area:index(xx, y+(yy*2)+1, zz)
|
||||
add_leaves(data, vi, c_pine_leaves)
|
||||
local vi = area:index(xx, y+(yy*2)+2, zz)
|
||||
add_leaves(data, vi, c_snow)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local vi = area:index(x, y+th+1, z)
|
||||
add_leaves(data, vi, c_pine_leaves)
|
||||
local vi = area:index(x, y+th+2, z)
|
||||
add_leaves(data, vi, c_snow)
|
||||
end
|
||||
regtr({
|
||||
name = "pine_cold",
|
||||
chance = 40,
|
||||
@ -196,42 +261,36 @@ regtr({
|
||||
maxh = 100,
|
||||
grows_on = "default:dirt_with_snow",
|
||||
grow = function(pos, data, area, seed, minp, maxp, pr)
|
||||
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)
|
||||
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)
|
||||
add_leaves(data, vi, c_snow)
|
||||
|
||||
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
|
||||
amgmt.tree.pine_cold_tree(pos, data, area, seed, minp, maxp, pr)
|
||||
|
||||
--amgmt.debug("pine tree spawned at:"..x..","..y..","..z)
|
||||
end
|
||||
})
|
||||
|
||||
--pine tree at taiga
|
||||
function amgmt.tree.pine_tree(pos, data, area, seed, minp, maxp, pr)
|
||||
local x, y, z = pos.x, pos.y, pos.z
|
||||
local th = pr:next(8,9)
|
||||
|
||||
for yy = y, y+th do
|
||||
local vi = area:index(x, yy, z)
|
||||
data[vi] = c_pine_tree
|
||||
end
|
||||
|
||||
for xx = x-1, x+1 do
|
||||
for yy = 1, 3 do
|
||||
for zz = z-1, z+1 do
|
||||
if area:contains(xx, y+(yy*2)+1, zz) then
|
||||
local vi = area:index(xx, y+(yy*2)+1, zz)
|
||||
add_leaves(data, vi, c_pine_leaves)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local vi = area:index(x, y+th+1, z)
|
||||
add_leaves(data, vi, c_pine_leaves)
|
||||
end
|
||||
regtr({
|
||||
name = "pine_taiga",
|
||||
chance = 40,
|
||||
@ -239,30 +298,7 @@ regtr({
|
||||
maxh = 100,
|
||||
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 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)
|
||||
add_leaves(data, vi, c_leaves)
|
||||
end
|
||||
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
|
||||
local vi = area:index(xx, y+th, zz)
|
||||
add_leaves(data, vi, c_leaves)
|
||||
end
|
||||
end
|
||||
|
||||
local vi = area:index(x, y+th+1, z)
|
||||
add_leaves(data, vi, c_leaves)
|
||||
amgmt.tree.pine_tree(pos, data, area, seed, minp, maxp, pr)
|
||||
|
||||
--amgmt.debug("pine tree spawned at:"..x..","..y..","..z)
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user