added function to disable weather
This commit is contained in:
parent
4097350753
commit
3d9c292590
|
@ -1,13 +0,0 @@
|
||||||
name: tidy_luacheck
|
|
||||||
|
|
||||||
on: [push]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
lint:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2.0.0
|
|
||||||
- name: run luacheck
|
|
||||||
uses: Roang-zero1/factorio-mod-luacheck@master
|
|
||||||
with:
|
|
||||||
LUACHECKRC_URL: https://raw.githubusercontent.com/${{github.repository}}/${{github.sha}}/.luacheck_tidy
|
|
|
@ -1,9 +0,0 @@
|
||||||
allow_defined_top = true
|
|
||||||
|
|
||||||
read_globals = {
|
|
||||||
"minetest",
|
|
||||||
"dump2", "vector",
|
|
||||||
"VoxelManip", "VoxelArea",
|
|
||||||
table = { fields = { "copy" } },
|
|
||||||
"lightning",
|
|
||||||
}
|
|
31
.luacheckrc
31
.luacheckrc
|
@ -1,4 +1,4 @@
|
||||||
allow_defined_top = true
|
max_line_length = false
|
||||||
|
|
||||||
read_globals = {
|
read_globals = {
|
||||||
"dump2",
|
"dump2",
|
||||||
|
@ -9,15 +9,26 @@ read_globals = {
|
||||||
table = { fields = {
|
table = { fields = {
|
||||||
"copy"
|
"copy"
|
||||||
} },
|
} },
|
||||||
"lightning",
|
lightning = {
|
||||||
|
fields = {
|
||||||
|
auto = {
|
||||||
|
read_only = false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
other_fields = true
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
ignore = {
|
globals = {
|
||||||
"211",
|
"weather",
|
||||||
"212",
|
"weather_mod"
|
||||||
"213",
|
}
|
||||||
"611",
|
|
||||||
"612",
|
exclude_files = {"weather/development/"}
|
||||||
"621",
|
|
||||||
"631"
|
ignore = {
|
||||||
|
--unused variables
|
||||||
|
"21.",
|
||||||
|
--whitespace
|
||||||
|
"61.",
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,12 +53,14 @@ local default_downfall = {
|
||||||
damage_player=false,
|
damage_player=false,
|
||||||
--how much wind is needed to trigger the weather
|
--how much wind is needed to trigger the weather
|
||||||
min_wind = 0,
|
min_wind = 0,
|
||||||
|
--stops weather
|
||||||
|
disabled = false,
|
||||||
}
|
}
|
||||||
|
|
||||||
local default_damage = {
|
local default_damage = {
|
||||||
--how many half hearts
|
--how many half hearts
|
||||||
amount = 1,
|
amount = 1,
|
||||||
--chance to damage: .5 is 50% btw.
|
--chance to damage: .5 is 50%
|
||||||
chance = 1,
|
chance = 1,
|
||||||
--after how many steps to damage
|
--after how many steps to damage
|
||||||
time = 100
|
time = 100
|
||||||
|
@ -85,19 +87,24 @@ function weather_mod.register_downfall(id,def)
|
||||||
weather_mod.registered_downfalls[name]=ndef
|
weather_mod.registered_downfalls[name]=ndef
|
||||||
end
|
end
|
||||||
|
|
||||||
function weather_mod.unregister_downfall(id)
|
function weather_mod.disable_downfall(id,disable)
|
||||||
weather_mod.registered_downfalls[id] = nil
|
local state = disable
|
||||||
|
if disable == nil then
|
||||||
|
state = true
|
||||||
|
end
|
||||||
|
weather_mod.registered_downfalls[id].disabled = state
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("lightning") then
|
if minetest.get_modpath("lightning") then
|
||||||
--same as lightning.auto = false
|
lightning.auto = false
|
||||||
rawset(lightning,"auto",false)
|
--rawset(lightning,"auto",false)
|
||||||
end
|
end
|
||||||
|
|
||||||
function weather_mod.handle_lightning(current_weather)
|
function weather_mod.handle_lightning(current_weather)
|
||||||
if not minetest.get_modpath("lightning") then return end
|
if not minetest.get_modpath("lightning") then return end
|
||||||
if not current_weather then return end
|
if not current_weather then return end
|
||||||
rawset(lightning,"auto",current_weather.enable_lightning)
|
lightning.auto = current_weather.enable_lightning
|
||||||
|
--rawset(lightning,"auto",current_weather.enable_lightning)
|
||||||
if current_weather.enable_lightning and math.random(1,2) == 1 then
|
if current_weather.enable_lightning and math.random(1,2) == 1 then
|
||||||
local time = math.floor(math.random(lightning.interval_low/2,lightning.interval_low))
|
local time = math.floor(math.random(lightning.interval_low/2,lightning.interval_low))
|
||||||
minetest.after(time, lightning.strike)
|
minetest.after(time, lightning.strike)
|
||||||
|
@ -136,28 +143,7 @@ local function handle_damage(damage,player, downfall_origin)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_globalstep(function()
|
local function weather_step()
|
||||||
if math.random(1, 10000) == 1 then
|
|
||||||
weather.type = "none"
|
|
||||||
if minetest.get_modpath("lightning") then
|
|
||||||
rawset(lightning,"auto",false)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
for id,w in pairs(weather_mod.registered_downfalls) do
|
|
||||||
if math.random(1, 50000) == 1 then
|
|
||||||
weather.wind = {}
|
|
||||||
weather.wind.x = math.random(0,10)
|
|
||||||
weather.wind.y = 0
|
|
||||||
weather.wind.z = math.random(0,10)
|
|
||||||
if vector.length(weather.wind) >= w.min_wind then
|
|
||||||
weather.type = id
|
|
||||||
weather_mod.handle_lightning(w)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local current_downfall = weather_mod.registered_downfalls[weather.type]
|
local current_downfall = weather_mod.registered_downfalls[weather.type]
|
||||||
if current_downfall==nil then return end
|
if current_downfall==nil then return end
|
||||||
for _, player in ipairs(minetest.get_connected_players()) do
|
for _, player in ipairs(minetest.get_connected_players()) do
|
||||||
|
@ -190,4 +176,31 @@ minetest.register_globalstep(function()
|
||||||
local downfall_origin = vector.divide(vector.add(minp,maxp),2)
|
local downfall_origin = vector.divide(vector.add(minp,maxp),2)
|
||||||
handle_damage(current_downfall.damage_player,player,downfall_origin)
|
handle_damage(current_downfall.damage_player,player,downfall_origin)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_globalstep(function()
|
||||||
|
if math.random(1, 10000) == 1 then
|
||||||
|
weather.type = "none"
|
||||||
|
if minetest.get_modpath("lightning") then
|
||||||
|
lightning.auto = false
|
||||||
|
--rawset(lightning,"auto",false)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
for id,w in pairs(weather_mod.registered_downfalls) do
|
||||||
|
if math.random(1, 50000) == 1 then
|
||||||
|
weather.wind = {
|
||||||
|
x = math.random(0,10),
|
||||||
|
y = 0,
|
||||||
|
z = math.random(0,10)
|
||||||
|
}
|
||||||
|
if (not w.disabled) and vector.length(weather.wind) >= w.min_wind then
|
||||||
|
weather.type = id
|
||||||
|
weather_mod.handle_lightning(w)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
weather_step()
|
||||||
end)
|
end)
|
Loading…
Reference in New Issue