Fix calculation of pos2.
This needs to always be done, even if passed a pos.
This commit is contained in:
parent
e79965e3e8
commit
0cdcb34d6b
8
init.lua
8
init.lua
@ -57,7 +57,6 @@ local function choose_pos(pos)
|
|||||||
local r = rng:next(1, playercount)
|
local r = rng:next(1, playercount)
|
||||||
local randomplayer = playerlist[r]
|
local randomplayer = playerlist[r]
|
||||||
pos = randomplayer:getpos()
|
pos = randomplayer:getpos()
|
||||||
end
|
|
||||||
|
|
||||||
-- avoid striking underground
|
-- avoid striking underground
|
||||||
if pos.y < -20 then
|
if pos.y < -20 then
|
||||||
@ -67,8 +66,10 @@ local function choose_pos(pos)
|
|||||||
pos.x = math.floor(pos.x - (lightning.range_h / 2) + rng:next(1, lightning.range_h))
|
pos.x = math.floor(pos.x - (lightning.range_h / 2) + rng:next(1, lightning.range_h))
|
||||||
pos.y = pos.y + (lightning.range_v / 2)
|
pos.y = pos.y + (lightning.range_v / 2)
|
||||||
pos.z = math.floor(pos.z - (lightning.range_h / 2) + rng:next(1, lightning.range_h))
|
pos.z = math.floor(pos.z - (lightning.range_h / 2) + rng:next(1, lightning.range_h))
|
||||||
|
end
|
||||||
|
|
||||||
local b, pos2 = minetest.line_of_sight(pos, {x = pos.x, y = pos.y - lightning.range_v, z = pos.z}, 1)
|
local b, pos2 = minetest.line_of_sight(pos, {x = pos.x, y = pos.y - lightning.range_v, z = pos.z}, 1)
|
||||||
|
|
||||||
-- nothing but air found
|
-- nothing but air found
|
||||||
if b then
|
if b then
|
||||||
return nil, nil
|
return nil, nil
|
||||||
@ -91,12 +92,11 @@ lightning.strike = function(pos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local pos2
|
local pos2
|
||||||
if not pos then
|
pos, pos2 = choose_pos(pos)
|
||||||
pos, pos2 = choose_pos()
|
|
||||||
if not pos then
|
if not pos then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
minetest.add_particlespawner({
|
minetest.add_particlespawner({
|
||||||
amount = 1,
|
amount = 1,
|
||||||
|
Loading…
Reference in New Issue
Block a user