mcl_devtest/biometp/init.lua

46 lines
1.1 KiB
Lua
Raw Normal View History

2022-06-25 03:19:23 +02:00
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..")")
2022-06-25 03:29:27 +02:00
if active then minetest.after(wait,tp_step,n) end
2022-06-25 03:19:23 +02:00
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
})