Change mode every 10 minutes

master
LoneWolfHT 2019-06-05 16:04:52 -07:00
parent e9b502f019
commit 9705ff8309
2 changed files with 25 additions and 1 deletions

View File

@ -1,5 +1,6 @@
main = {
modes = {},
mode_interval = 60 * 10,
default_drops = {
default = "shooter_guns:ammo",
["shooter_guns:pistol_loaded"] = 20,

View File

@ -4,4 +4,27 @@ main.register_mode("default", {
drops = main.default_drops,
starter_items = main.default_starter_items,
drop_interval = main.default_drop_interval,
})
})
local function rand_mode()
local online = #minetest.get_connected_players()
local modes = {}
for name, def in pairs(main.modes) do
if online >= def.min_players then
table.insert(modes, name)
end
end
return(modes[math.random(1, #modes)])
end
local modestep = 0
minetest.register_globalstep(function(dtime)
if modestep < main.mode_interval then
modestep = modestep + dtime
else
modestep = 0
main.start_mode(rand_mode())
end
end)