forked from MineClone5/MineClone5
fix some code style issues in lightning
This commit is contained in:
parent
b8782d0af1
commit
3bedc81068
|
@ -363,6 +363,17 @@ if not time_to_live then
|
|||
time_to_live = 300
|
||||
end
|
||||
|
||||
local function cxcz(o, cw, one, zero)
|
||||
if cw < 0 then
|
||||
table.insert(o, { [one]=1, y=0, [zero]=0 })
|
||||
table.insert(o, { [one]=-1, y=0, [zero]=0 })
|
||||
else
|
||||
table.insert(o, { [one]=-1, y=0, [zero]=0 })
|
||||
table.insert(o, { [one]=1, y=0, [zero]=0 })
|
||||
end
|
||||
return o
|
||||
end
|
||||
|
||||
minetest.register_entity(":__builtin:item", {
|
||||
initial_properties = {
|
||||
hp_max = 1,
|
||||
|
@ -642,16 +653,6 @@ minetest.register_entity(":__builtin:item", {
|
|||
-- 1st: closest
|
||||
-- 2nd: other direction
|
||||
-- 3rd and 4th: other axis
|
||||
local cxcz = function(o, cw, one, zero)
|
||||
if cw < 0 then
|
||||
table.insert(o, { [one]=1, y=0, [zero]=0 })
|
||||
table.insert(o, { [one]=-1, y=0, [zero]=0 })
|
||||
else
|
||||
table.insert(o, { [one]=-1, y=0, [zero]=0 })
|
||||
table.insert(o, { [one]=1, y=0, [zero]=0 })
|
||||
end
|
||||
return o
|
||||
end
|
||||
if math.abs(cx) < math.abs(cz) then
|
||||
order = cxcz(order, cx, "x", "z")
|
||||
order = cxcz(order, cz, "z", "x")
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
--[[
|
||||
|
||||
Copyright (C) 2016 - Auke Kok <sofar@foo-projects.org>
|
||||
Adapted by MineClone2 contributors
|
||||
|
||||
"lightning" is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
|
@ -9,7 +10,7 @@ of the license, or (at your option) any later version.
|
|||
|
||||
--]]
|
||||
|
||||
local S = minetest.get_translator("lightning")
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
local get_connected_players = minetest.get_connected_players
|
||||
local line_of_sight = minetest.line_of_sight
|
||||
|
@ -22,22 +23,22 @@ local add_entity = minetest.add_entity
|
|||
local get_objects_inside_radius = minetest.get_objects_inside_radius
|
||||
local get_item_group = minetest.get_item_group
|
||||
|
||||
lightning = {}
|
||||
|
||||
lightning.interval_low = 17
|
||||
lightning.interval_high = 503
|
||||
lightning.range_h = 100
|
||||
lightning.range_v = 50
|
||||
lightning.size = 100
|
||||
-- disable this to stop lightning mod from striking
|
||||
lightning.auto = true
|
||||
lightning = {
|
||||
interval_low = 17,
|
||||
interval_high = 503,
|
||||
range_h = 100,
|
||||
range_v = 50,
|
||||
size = 100,
|
||||
-- disable this to stop lightning mod from striking
|
||||
auto = true,
|
||||
}
|
||||
|
||||
local rng = PcgRandom(32321123312123)
|
||||
|
||||
local ps = {}
|
||||
local ttl = -1
|
||||
|
||||
local revertsky = function(dtime)
|
||||
local function revertsky(dtime)
|
||||
if ttl == 0 then
|
||||
return
|
||||
end
|
||||
|
@ -96,7 +97,7 @@ end
|
|||
-- lightning strike API
|
||||
-- * pos: optional, if not given a random pos will be chosen
|
||||
-- * returns: bool - success if a strike happened
|
||||
lightning.strike = function(pos)
|
||||
function lightning.strike(pos)
|
||||
if lightning.auto then
|
||||
after(rng:next(lightning.interval_low, lightning.interval_high), lightning.strike)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue