add simple weather particlespawner manager

This commit is contained in:
cora 2022-01-30 20:09:38 +01:00
parent d968ceb209
commit cbe9f72526
1 changed files with 23 additions and 0 deletions

View File

@ -47,6 +47,29 @@ local function save_weather()
end
minetest.register_on_shutdown(save_weather)
local particlespawners={}
function mcl_weather.add_spawner_player(pl,id,ps)
local name=pl:get_player_name()
if not particlespawners[name] then
particlespawners[name] = {}
end
if not particlespawners[name][id] then
ps.playername =name
ps.attached = pl
particlespawners[name][id]=minetest.add_particlespawner(ps)
return particlespawners[name][id]
end
end
function mcl_weather.remove_spawners_player(pl)
local name=pl:get_player_name()
if not particlespawners[name] then return end
for k,v in pairs(particlespawners[name]) do
minetest.delete_particlespawner(v)
end
particlespawners[name] = nil
return true
end
function mcl_weather.get_rand_end_time(min_duration, max_duration)
local r
if min_duration and max_duration then