minetest_mod_weather/weather/init.lua

38 lines
924 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
assert(minetest.add_particlespawner, "I told you to run the latest GitHub!")
2018-05-17 16:37:30 +02:00
rawset(_G,"weather_mod",{})
2018-05-17 16:33:50 +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()