forked from VoxeLibre/VoxeLibre
Add proper logging + some fixes
This commit is contained in:
parent
a895292371
commit
a0bed1d8bc
|
@ -8,7 +8,7 @@ local adjacents = {
|
||||||
}
|
}
|
||||||
|
|
||||||
local function makegeode(pos,pr)
|
local function makegeode(pos,pr)
|
||||||
local size = pr:next(2,8)
|
local size = pr:next(4,7)
|
||||||
local p1 = vector.offset(pos,-size,-size,-size)
|
local p1 = vector.offset(pos,-size,-size,-size)
|
||||||
local p2 = vector.offset(pos,size,size,size)
|
local p2 = vector.offset(pos,size,size,size)
|
||||||
local nn = minetest.find_nodes_in_area(p1,p2,{"group:material_stone"})
|
local nn = minetest.find_nodes_in_area(p1,p2,{"group:material_stone"})
|
||||||
|
@ -47,21 +47,20 @@ local function makegeode(pos,pr)
|
||||||
minetest.set_node(vector.offset(v,0,1,0),{name="mcl_amethyst:amethyst_cluster",param2=1})
|
minetest.set_node(vector.offset(v,0,1,0),{name="mcl_amethyst:amethyst_cluster",param2=1})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_structures.register_structure("geode",{
|
mcl_structures.register_structure("geode",{
|
||||||
place_on = {"mcl_core:stone"},
|
place_on = {"mcl_core:stone"},
|
||||||
spawn_by = {"air"},
|
fill_ratio = 0.0001,
|
||||||
num_spawn_by = 2,
|
|
||||||
fill_ratio = 0.002,
|
|
||||||
flags = "place_center_x, place_center_z, force_placement",
|
flags = "place_center_x, place_center_z, force_placement",
|
||||||
biomes = ocean_biomes,
|
biomes = ocean_biomes,
|
||||||
y_max = mcl_vars.mg_overworld_max,
|
y_max = -24,
|
||||||
y_min = mcl_vars.mg_overworld_min,
|
y_min = mcl_vars.mg_overworld_min,
|
||||||
filenames = schems,
|
filenames = schems,
|
||||||
y_offset = function(pr) return pr:next(-4,-2) end,
|
y_offset = function(pr) return pr:next(-4,-2) end,
|
||||||
place_func = function(pos,def,pr)
|
place_func = function(pos,def,pr)
|
||||||
local p = vector.new(pos.x + pr:next(-30,30),pos.y,pos.z + pr:next(-30,30))
|
local p = vector.new(pos.x + pr:next(-30,30),pos.y,pos.z + pr:next(-30,30))
|
||||||
makegeode(pos,pr)
|
return makegeode(pos,pr)
|
||||||
end,
|
end
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
# mcl_structures
|
# mcl_structures
|
||||||
Structure placement API for MCL2.
|
Structure placement API for MCL2.
|
||||||
|
|
||||||
## mcl_structures.register_structure(name,structure definition)
|
## mcl_structures.register_structure(name,structure definition,nospawn)
|
||||||
|
If nospawn is truthy the structure will not be placed by mapgen and the decoration parameters can be omitted. This is intended for secondary structures the placement of which gets triggered by the placement of other structures. It can also be used to register testing structures so they can be used with /spawnstruct.
|
||||||
|
|
||||||
### structure definition
|
### structure definition
|
||||||
{
|
{
|
||||||
fill_ratio = OR noise = {},
|
fill_ratio = OR noise = {},
|
||||||
|
@ -14,9 +16,9 @@ Structure placement API for MCL2.
|
||||||
flags = (default: "place_center_x, place_center_z, force_placement")
|
flags = (default: "place_center_x, place_center_z, force_placement")
|
||||||
(same as decoration def)
|
(same as decoration def)
|
||||||
y_offset =, --can be a number or a function returning a number
|
y_offset =, --can be a number or a function returning a number
|
||||||
filenames = {} OR place_func = function(pos,filename)
|
filenames = {} OR place_func = function(pos,def,pr)
|
||||||
-- filenames can be a list of any schematics accepted by mcl_structures.place_schematic
|
-- filenames can be a list of any schematics accepted by mcl_structures.place_schematic / minetest.place_schematic
|
||||||
after_place = function(pos)
|
after_place = function(pos,def,pr)
|
||||||
}
|
}
|
||||||
## mcl_structures.registered_structures
|
## mcl_structures.registered_structures
|
||||||
Table of the registered structure defintions indexed by name.
|
Table of the registered structure defintions indexed by name.
|
||||||
|
|
|
@ -1,24 +1,8 @@
|
||||||
mcl_structures.registered_structures = {}
|
mcl_structures.registered_structures = {}
|
||||||
|
|
||||||
--[[] structure def:
|
|
||||||
{
|
|
||||||
fill_ratio = OR noise = {}
|
|
||||||
biomes =
|
|
||||||
y_min =
|
|
||||||
y_max =
|
|
||||||
place_on =
|
|
||||||
spawn_by =
|
|
||||||
num_spawn_by =
|
|
||||||
flags = (default: "place_center_x, place_center_z, force_placement")
|
|
||||||
(same as decoration def)
|
|
||||||
y_offset =
|
|
||||||
filenames = {} OR place_func = function(pos,filename)
|
|
||||||
after_place = function(pos)
|
|
||||||
}
|
|
||||||
]]--
|
|
||||||
|
|
||||||
function mcl_structures.place_structure(pos, def, pr)
|
function mcl_structures.place_structure(pos, def, pr)
|
||||||
if not def then return end
|
if not def then return end
|
||||||
|
local y_offset = 0
|
||||||
if type(def.y_offset) == "function" then
|
if type(def.y_offset) == "function" then
|
||||||
y_offset = def.y_offset(pr)
|
y_offset = def.y_offset(pr)
|
||||||
elseif def.y_offset then
|
elseif def.y_offset then
|
||||||
|
@ -28,10 +12,16 @@ function mcl_structures.place_structure(pos, def, pr)
|
||||||
local file = def.filenames[pr:next(1,#def.filenames)]
|
local file = def.filenames[pr:next(1,#def.filenames)]
|
||||||
local pp = vector.offset(pos,0,y_offset,0)
|
local pp = vector.offset(pos,0,y_offset,0)
|
||||||
mcl_structures.place_schematic(pp, file, "random", nil, true, "place_center_x,place_center_z",def.after_place,pr,{pos,def})
|
mcl_structures.place_schematic(pp, file, "random", nil, true, "place_center_x,place_center_z",def.after_place,pr,{pos,def})
|
||||||
|
minetest.log("action","[mcl_structures] "..def.name.." placed at "..minetest.pos_to_string(pos))
|
||||||
|
return true
|
||||||
elseif def.place_func and def.place_func(pos,def,pr) then
|
elseif def.place_func and def.place_func(pos,def,pr) then
|
||||||
def.after_place(pos,def,pr)
|
if not def.after_place or ( def.after_place and def.after_place(pos,def,pr) ) then
|
||||||
|
minetest.log("action","[mcl_structures] "..def.name.." placed at "..minetest.pos_to_string(pos))
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
minetest.log("warning","[mcl_structures] placing "..def.name.." failed at "..minetest.pos_to_string(pos))
|
||||||
|
end
|
||||||
|
|
||||||
function mcl_structures.register_structure(name,def,nospawn) --nospawn means it will be placed by another (non-nospawn) structure that contains it's structblock i.e. it will not be placed by mapgen directly
|
function mcl_structures.register_structure(name,def,nospawn) --nospawn means it will be placed by another (non-nospawn) structure that contains it's structblock i.e. it will not be placed by mapgen directly
|
||||||
local structblock = "mcl_structures:structblock_"..name
|
local structblock = "mcl_structures:structblock_"..name
|
||||||
|
|
Loading…
Reference in New Issue