[lightning] Fix critical attempt to index local mob (a nil value)
parent
4de3bfda8e
commit
9498ccc279
|
@ -19,7 +19,6 @@ local set_node = minetest.set_node
|
||||||
local sound_play = minetest.sound_play
|
local sound_play = minetest.sound_play
|
||||||
local add_particlespawner = minetest.add_particlespawner
|
local add_particlespawner = minetest.add_particlespawner
|
||||||
local after = minetest.after
|
local after = minetest.after
|
||||||
local add_entity = minetest.add_entity
|
|
||||||
local get_objects_inside_radius = minetest.get_objects_inside_radius
|
local get_objects_inside_radius = minetest.get_objects_inside_radius
|
||||||
local get_item_group = minetest.get_item_group
|
local get_item_group = minetest.get_item_group
|
||||||
|
|
||||||
|
@ -144,7 +143,7 @@ function lightning.strike(pos)
|
||||||
if lua and lua.name == "mobs_mc:pig" then
|
if lua and lua.name == "mobs_mc:pig" then
|
||||||
local rot = obj:get_yaw()
|
local rot = obj:get_yaw()
|
||||||
obj:remove()
|
obj:remove()
|
||||||
obj = add_entity(pos2, "mobs_mc:pigman")
|
obj = minetest.add_entity(pos2, "mobs_mc:pigman")
|
||||||
obj:set_yaw(rot)
|
obj:set_yaw(rot)
|
||||||
-- mooshroom: toggle color red/brown (no damage)
|
-- mooshroom: toggle color red/brown (no damage)
|
||||||
elseif lua and lua.name == "mobs_mc:mooshroom" then
|
elseif lua and lua.name == "mobs_mc:mooshroom" then
|
||||||
|
@ -168,7 +167,7 @@ function lightning.strike(pos)
|
||||||
elseif lua and lua.name == "mobs_mc:creeper" then
|
elseif lua and lua.name == "mobs_mc:creeper" then
|
||||||
local rot = obj:get_yaw()
|
local rot = obj:get_yaw()
|
||||||
obj:remove()
|
obj:remove()
|
||||||
obj = add_entity(pos2, "mobs_mc:creeper_charged")
|
obj = minetest.add_entity(pos2, "mobs_mc:creeper_charged")
|
||||||
obj:set_yaw(rot)
|
obj:set_yaw(rot)
|
||||||
-- Other objects: Just damage
|
-- Other objects: Just damage
|
||||||
else
|
else
|
||||||
|
@ -205,17 +204,19 @@ function lightning.strike(pos)
|
||||||
if get_node(pos2).name == "air" then
|
if get_node(pos2).name == "air" then
|
||||||
-- Low chance for a lightning to spawn skeleton horse + skeletons
|
-- Low chance for a lightning to spawn skeleton horse + skeletons
|
||||||
if skeleton_lightning then
|
if skeleton_lightning then
|
||||||
add_entity(pos2, "mobs_mc:skeleton_horse")
|
minetest.add_entity(pos2, "mobs_mc:skeleton_horse")
|
||||||
|
|
||||||
local angle, posadd
|
local angle, posadd
|
||||||
angle = math.random(0, math.pi*2)
|
angle = math.random(0, math.pi*2)
|
||||||
for i=1,3 do
|
for i=1,3 do
|
||||||
posadd = {x=math.cos(angle),y=0,z=math.sin(angle)}
|
posadd = {x=math.cos(angle),y=0,z=math.sin(angle)}
|
||||||
posadd = vector.normalize(posadd)
|
posadd = vector.normalize(posadd)
|
||||||
local mob = add_entity(vector.add(pos2, posadd), "mobs_mc:skeleton")
|
local mob = minetest.add_entity(vector.add(pos2, posadd), "mobs_mc:skeleton")
|
||||||
|
if mob then
|
||||||
mob:set_yaw(angle-math.pi/2)
|
mob:set_yaw(angle-math.pi/2)
|
||||||
angle = angle + (math.pi*2) / 3
|
angle = angle + (math.pi*2) / 3
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Cause a fire
|
-- Cause a fire
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue