minetest_mod_weather/weather/init.lua

39 lines
902 B
Lua
Raw Normal View History

2013-03-24 14:40:18 +01:00
-- Weather:
-- * rain
-- * snow
2018-04-11 17:55:27 +02:00
-- * wind
2013-03-24 14:40:18 +01:00
2019-09-16 09:01:07 +02:00
assert(minetest.add_particlespawner, "You have some really old minetest...")
2013-03-24 14:40:18 +01:00
2018-05-17 17:07:41 +02:00
weather_mod={
modpath=minetest.get_modpath("weather"),
}
2018-04-29 17:22:05 +02:00
2018-04-29 17:25:20 +02:00
weather = (function()
local file_name = minetest.get_worldpath() .. "/weather"
2013-03-24 14:40:18 +01:00
2018-04-29 17:25:20 +02:00
minetest.register_on_shutdown(function()
local file = io.open(file_name, "w")
file:write(minetest.serialize(weather))
file:close()
end)
2013-03-24 14:40:18 +01:00
2018-04-29 17:25:20 +02:00
local file = io.open(file_name, "r")
if file ~= nil then
local readweather = minetest.deserialize(file:read("*a"))
file:close()
if type(readweather)~="table" then
return {type = "none", wind = 0}
end
return readweather
end
return {type = "none", wind = vector.new(0,0,0)}
end) ()
2013-03-24 14:40:18 +01:00
2018-04-29 17:22:05 +02:00
dofile(weather_mod.modpath.."/api.lua")
dofile(weather_mod.modpath.."/rain.lua")
dofile(weather_mod.modpath.."/snow.lua")
dofile(weather_mod.modpath.."/command.lua")
2018-05-08 15:24:38 +02:00
weather_mod.handle_lightning()