minetest_mod_weather/weather/init.lua

35 lines
842 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-04-29 17:22:05 +02:00
weather_mod={
modpath=minetest.get_modpath("weather"),
}
2013-03-24 14:40:18 +01:00
save_weather = function ()
local file = io.open(minetest.get_worldpath().."/weather", "w+")
2018-04-11 17:55:27 +02:00
file:write(minetest.serialize(weather))
2013-03-24 14:40:18 +01:00
file:close()
end
read_weather = function ()
local file = io.open(minetest.get_worldpath().."/weather", "r")
2018-04-11 17:55:27 +02:00
if not file then return {type = "none", wind = 0} end
local readweather = minetest.deserialize(file:read())
2013-03-24 14:40:18 +01:00
file:close()
2018-04-11 17:55:27 +02:00
if type(readweather)~="table" then
return {type = "none", wind = 0}
end
2013-03-24 14:40:18 +01:00
return readweather
end
weather = read_weather()
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")