Fixing API to ensure it behaves same way it used to, when not passing spawn_on_sides or spawn_on_bottom flags.
This commit is contained in:
parent
281c5b151b
commit
dfea0959e3
11
api.lua
11
api.lua
|
@ -311,7 +311,6 @@ function biome_lib.populate_surfaces(b, nodes_or_function_or_model, snodes, chec
|
||||||
local pos = in_biome_nodes[math.random(1, num_in_biome_nodes)]
|
local pos = in_biome_nodes[math.random(1, num_in_biome_nodes)]
|
||||||
|
|
||||||
local will_place = true
|
local will_place = true
|
||||||
local p_top = { x = pos.x, y = pos.y + 1, z = pos.z }
|
|
||||||
local fdir = nil
|
local fdir = nil
|
||||||
if biome.random_facedir then
|
if biome.random_facedir then
|
||||||
fdir = math.random(biome.random_facedir[1], biome.random_facedir[2])
|
fdir = math.random(biome.random_facedir[1], biome.random_facedir[2])
|
||||||
|
@ -320,20 +319,22 @@ function biome_lib.populate_surfaces(b, nodes_or_function_or_model, snodes, chec
|
||||||
if biome.spawn_on_side then
|
if biome.spawn_on_side then
|
||||||
local onside = biome_lib.find_open_side(pos)
|
local onside = biome_lib.find_open_side(pos)
|
||||||
if onside then
|
if onside then
|
||||||
p_top = onside.newpos
|
pos = onside.newpos
|
||||||
fdir = onside.facedir
|
fdir = onside.facedir
|
||||||
else
|
else
|
||||||
will_place = false
|
will_place = false
|
||||||
end
|
end
|
||||||
elseif biome.spawn_on_bottom then
|
elseif biome.spawn_on_bottom then
|
||||||
if minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" then
|
if minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" then
|
||||||
p_top.y = pos.y - 1
|
pos.y = pos.y - 1
|
||||||
else
|
else
|
||||||
will_place = false
|
will_place = false
|
||||||
end
|
end
|
||||||
elseif biome.spawn_replace_node then
|
elseif biome.spawn_replace_node then
|
||||||
p_top.y = pos.y
|
pos.y = pos.y-1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local p_top = { x = pos.x, y = pos.y + 1, z = pos.z }
|
||||||
|
|
||||||
if will_place and not (biome.avoid_nodes and biome.avoid_radius
|
if will_place and not (biome.avoid_nodes and biome.avoid_radius
|
||||||
and minetest.find_node_near(p_top, biome.avoid_radius
|
and minetest.find_node_near(p_top, biome.avoid_radius
|
||||||
|
@ -378,7 +379,7 @@ function biome_lib.populate_surfaces(b, nodes_or_function_or_model, snodes, chec
|
||||||
biome_lib.dbg("Node \""..nodes_or_function_or_model.."\" was placed at "..minetest.pos_to_string(p_top), 4)
|
biome_lib.dbg("Node \""..nodes_or_function_or_model.."\" was placed at "..minetest.pos_to_string(p_top), 4)
|
||||||
spawned = true
|
spawned = true
|
||||||
elseif objtype == "function" then
|
elseif objtype == "function" then
|
||||||
nodes_or_function_or_model(p_top, fdir)
|
nodes_or_function_or_model(pos, fdir)
|
||||||
biome_lib.dbg("A function was run on surface node at "..minetest.pos_to_string(pos), 4)
|
biome_lib.dbg("A function was run on surface node at "..minetest.pos_to_string(pos), 4)
|
||||||
spawned = true
|
spawned = true
|
||||||
elseif objtype == "string" and pcall(loadstring(("return %s(...)"):
|
elseif objtype == "string" and pcall(loadstring(("return %s(...)"):
|
||||||
|
|
Loading…
Reference in New Issue