Compare commits

...

5 Commits

Author SHA1 Message Date
Maksim f3aa266ecf Minor changes 2022-04-09 23:47:15 +02:00
MoNTE48 f96aecdef5 Minor mod update 2021-05-06 14:34:02 +02:00
MoNTE48 57f067f8c1 Add translation support 2021-03-03 22:43:48 +01:00
MoNTE48 1468528d85 Update README (add link on license) 2021-02-28 10:43:09 +01:00
MoNTE48 5e4867fa12 Add Github Actions 2021-02-28 10:28:21 +01:00
5 changed files with 50 additions and 14 deletions

11
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,11 @@
on: [push, pull_request]
name: build
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: lint
uses: Roang-zero1/factorio-mod-luacheck@master
with:
luacheckrc_url: https://raw.githubusercontent.com/MultiCraft/weather_lite/main/.luacheckrc

10
.luacheckrc Normal file
View File

@ -0,0 +1,10 @@
max_line_length = 90
read_globals = {
"minetest",
"sscsm",
"ItemStack",
"vector",
table = { fields = { "copy" } }
}

View File

@ -24,9 +24,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
http://www.gnu.org/licenses/lgpl-3.0.html
Authors of textures

View File

@ -1,7 +1,10 @@
if not minetest.settings:get_bool("enable_weather") then
if minetest.settings:get_bool("enable_weather") == false then
return
end
local translator = minetest.get_translator
local S = translator and translator("weather_lite") or function(s) return s end
local vadd, vmultiply, vround = vector.add, vector.multiply, vector.round
local random = math.random
local snow_covers = minetest.settings:get_bool("weather_snow_covers") ~= false
@ -44,6 +47,7 @@ end
-- Rain
weather.register("rain", {
desc = S("Rain"),
falling_speed = 5,
amount = 6,
size = 20,
@ -54,6 +58,7 @@ weather.register("rain", {
-- Snow
weather.register("snow", {
desc = S("Snow"),
falling_speed = 2,
amount = 5,
size = 35,
@ -79,11 +84,11 @@ function weather.set(weather_type, wind)
end
end
local function weather_change()
if weather.type == "none" then
for id, _ in pairs(weather.registered) do
local function weather_change(disable)
if weather.type == "none" and not disable then
for w in pairs(weather.registered) do
if random(3) == 1 then
weather.set(id, {
weather.set(w, {
x = random(0, 8),
y = 0,
z = random(0, 8)
@ -92,7 +97,7 @@ local function weather_change()
break
end
end
minetest.after(random(60, 300), weather_change)
minetest.after(random(60, 300), function() weather_change(true) end)
else
weather.set("none")
minetest.after(random(1800, 3600), weather_change)
@ -159,7 +164,7 @@ minetest.register_globalstep(function()
local current_downfall = weather.registered[weather.type]
if current_downfall == nil then return end
for _, player in pairs(minetest.get_connected_players()) do
for _, player in ipairs(minetest.get_connected_players()) do
process_player(player, current_downfall)
end
end)
@ -226,18 +231,23 @@ minetest.register_privilege("weather", {
minetest.register_chatcommand("weather", {
params = "<weather>",
description = "Set weather type",
description = S("Setting the weather type"),
privs = {weather = true},
func = function(name, param)
if param and (weather.registered[param] or param == "none") then
weather.set(param)
minetest.chat_send_player(name, "Set weather type: " .. param)
if param == "none" then
minetest.chat_send_player(name, S("Set clear weather."))
else
local setw = weather.registered[param].desc or param:gsub("^%l", string.upper)
minetest.chat_send_player(name, S("Set weather type: @1.", setw))
end
else
local types = "none"
for w, _ in pairs(weather.registered) do
for w in pairs(weather.registered) do
types = types .. ", " .. w
end
minetest.chat_send_player(name, "Avalible weather types: " .. types)
minetest.chat_send_player(name, S("Avalible weather types: @1.", types))
end
end
})

View File

@ -0,0 +1,7 @@
# textdomain: weather_lite
Setting the weather type=Установка типа погоды
Set weather type: @1.=Установлен тип погоды: @1.
Avalible weather types: @1.=Доступные типы погоды: @1.
Set clear weather.=Установлена ясная погода.
Rain=Дождь
Snow=Снег