1 Commits

Author SHA1 Message Date
d091bf8025 Ajoute message de chargement du mod dans le journal "action" 2018-12-26 20:23:26 +01:00
7 changed files with 18 additions and 61 deletions

View File

@ -1,19 +0,0 @@
globals = {
"lightning"
}
read_globals = {
-- Stdlib
string = {fields = {"split"}},
table = {fields = {"copy", "getn"}},
"PcgRandom",
-- Minetest
"minetest",
"vector", "ItemStack",
"dump",
-- mods
"default", "fire"
}

View File

@ -1,11 +0,0 @@
language: generic
addons:
apt:
packages:
- luarocks
before_install:
- luarocks install --local luacheck
script:
- $HOME/.luarocks/bin/luacheck ./
notifications:
email: false

2
depends.txt Normal file
View File

@ -0,0 +1,2 @@
default?
fire?

1
description.txt Normal file
View File

@ -0,0 +1 @@
A mod that adds thunder and lightning effects.

View File

@ -19,14 +19,9 @@ lightning.range_v = 50
lightning.size = 100 lightning.size = 100
-- disable this to stop lightning mod from striking -- disable this to stop lightning mod from striking
lightning.auto = true lightning.auto = true
-- range of the skybox highlight and sound effect
lightning.effect_range = 500
local random_fire = minetest.settings:get_bool("lightning_random_fire") ~= false
local rng = PcgRandom(32321123312123) local rng = PcgRandom(32321123312123)
-- table with playername as key and previous skybox as value
local ps = {} local ps = {}
local ttl = 1 local ttl = 1
@ -39,12 +34,9 @@ local revertsky = function()
return return
end end
for playername, sky in pairs(ps) do for key, entry in pairs(ps) do
local player = minetest.get_player_by_name(playername) local sky = entry.sky
-- check if the player is still online entry.p:set_sky(sky.bgcolor, sky.type, sky.textures)
if player then
player:set_sky(sky.bgcolor, sky.type, sky.textures)
end
end end
ps = {} ps = {}
@ -65,7 +57,7 @@ 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:get_pos() pos = randomplayer:getpos()
-- avoid striking underground -- avoid striking underground
if pos.y < -20 then if pos.y < -20 then
@ -131,7 +123,7 @@ lightning.strike = function(pos)
glow = 14, glow = 14,
}) })
minetest.sound_play({ pos = pos, name = "lightning_thunder", gain = 10, max_hear_distance = lightning.effect_range }) minetest.sound_play({ pos = pos, name = "lightning_thunder", gain = 10, max_hear_distance = 500 })
-- damage nearby objects, player or not -- damage nearby objects, player or not
for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 5)) do for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 5)) do
@ -142,18 +134,14 @@ lightning.strike = function(pos)
local playerlist = minetest.get_connected_players() local playerlist = minetest.get_connected_players()
for i = 1, #playerlist do for i = 1, #playerlist do
local player = playerlist[i] local player = playerlist[i]
local distance = vector.distance(player:get_pos(), pos) local sky = {}
-- only affect players inside effect_range sky.bgcolor, sky.type, sky.textures = player:get_sky()
if distance < lightning.effect_range then
local sky = {}
sky.bgcolor, sky.type, sky.textures = player:get_sky()
local name = player:get_player_name() local name = player:get_player_name()
if ps[name] == nil then if ps[name] == nil then
ps[name] = sky ps[name] = {p = player, sky = sky}
player:set_sky(0xffffff, "plain", {}) player:set_sky(0xffffff, "plain", {})
end
end end
end end
@ -169,7 +157,7 @@ lightning.strike = function(pos)
return return
end end
-- very rarely, potentially cause a fire -- very rarely, potentially cause a fire
if fire and random_fire and rng:next(1,1000) == 1 then if fire and rng:next(1,1000) == 1 then
minetest.set_node(pos2, {name = "fire:basic_flame"}) minetest.set_node(pos2, {name = "fire:basic_flame"})
else else
minetest.set_node(pos2, {name = "lightning:dying_flame"}) minetest.set_node(pos2, {name = "lightning:dying_flame"})
@ -229,9 +217,11 @@ minetest.register_node("lightning:dying_flame", {
}) })
-- if other mods disable auto lightning during initialization, don't trigger the first lightning. -- if other mods disable auto lightning during initialization, don't trigger the first lightning.
minetest.after(5, function() minetest.after(5, function(dtime)
if lightning.auto then if lightning.auto then
minetest.after(rng:next(lightning.interval_low, minetest.after(rng:next(lightning.interval_low,
lightning.interval_high), lightning.strike) lightning.interval_high), lightning.strike)
end end
end) end)
minetest.log("action", "[lightning] loaded.")

View File

@ -1,3 +1 @@
name = lightning name = lightning
optional_depends = default, fire
description = A mod that adds thunder and lightning effects.

View File

@ -1,4 +0,0 @@
# When fire is enabled, this setting specifies whether the lightnings
# have a small chance to start a fire.
# Value 'false' will disable fire caused by lightnings.
lightning_random_fire (Enable random fire) bool true