Add checks for invalid spawners not containing spawn_in

master
Sapier 2015-12-28 10:48:40 +01:00
parent 9d7e4279f4
commit ec41aa93f6
3 changed files with 16 additions and 5 deletions

View File

@ -8,7 +8,7 @@
--
-------------------------------------------------------------------------------
local version = "0.0.12"
local version = "0.0.13"
if adv_spawning ~= nil then
core.log("error", "MOD: adv_spawning requires adv_spawning variable to be available")

View File

@ -423,6 +423,10 @@ function adv_spawning.handlespawner(spawnername,spawnerpos,minp,maxp,ignore_acti
new_pos.y, yreason = adv_spawning.get_surface(lower_y,upper_y,new_pos,
spawndef.spawn_inside)
else
if spawndef.spawn_inside == nil then
print("ERROR: " .. spawnername .. " tries to spawn within nil")
assert(false)
end
new_pos.y, yreason = adv_spawning.get_relative_pos(lower_y,upper_y,new_pos,
spawndef.spawn_inside,
spawndef.relative_height,
@ -1660,9 +1664,11 @@ end
--------------------------------------------------------------------------------
function adv_spawning.find_nodes_in(pos, min_range, max_range, nodetypes)
local nodetypes_to_use = nodetypes
if type(nodetypes) == "string" then
local templist = { nodetypes }
nodetypes = templist
nodetypes_to_use = { }
table.insert(nodetypes_to_use, nodetypes)
end
for i = min_range, max_range, 1 do
@ -1672,8 +1678,8 @@ function adv_spawning.find_nodes_in(pos, min_range, max_range, nodetypes)
local node = minetest.get_node_or_nil(positions[i])
if node ~= nil then
for i = 1, #nodetypes, 1 do
if node.name == nodetypes[i] then
for i = 1, #nodetypes_to_use, 1 do
if node.name == nodetypes_to_use[i] then
return positions[i]
end
end

View File

@ -328,6 +328,11 @@ function adv_spawning.init_spawner(self, pos, name, spawnerdef)
return false
end
if spawnerdef.spawn_inside == nil then
print(name .. " tries to spawn within nil")
assert(false)
end
local resultpos = adv_spawning.find_nodes_in(pos, runidx, runidx, spawnerdef.spawn_inside)
if (resultpos ~= nil) then