mcl_devtest/biometp/init.lua

46 lines
1.1 KiB
Lua

local current = 0
local biomekeys = {}
local wait = 15
active = false
minetest.register_on_mods_loaded(function()
for k,_ in pairs(minetest.registered_biomes) do
table.insert(biomekeys,k)
end
end)
local function next_biome()
current = current + 1
if biomekeys[current] then
return minetest.registered_biomes[biomekeys[current]].name
else
current = 0
end
end
local function tp_step(n)
minetest.registered_chatcommands["findbiome"].func(n,next_biome())
minetest.chat_send_player(n,"Teleporting to "..minetest.registered_biomes[biomekeys[current]].name.." ("..current.."/"..#biomekeys..")")
if active then minetest.after(wait,tp_step,n) end
end
minetest.register_chatcommand("biometp",{
privs = {debug = true},
description = "Teleports to all biomes successively.",
params = "|<tp interval>",
func = function(n,p)
local pn = tonumber(p)
if pn and pn > 0 then
wait = pn
return true,"Biometp interval set to "..pn
end
if not active then
active = true
tp_step(n)
return true,"Biometp started ETA: "..#biomekeys * wait / 60 .."mins"
else
active = false
return true,"Biometp stopped"
end
end
})