2022-06-25 03:19:23 +02:00
|
|
|
local current = 0
|
|
|
|
local biomekeys = {}
|
|
|
|
local wait = 15
|
2022-06-25 06:18:26 +02:00
|
|
|
local old_damage = minetest.settings:get_bool("enable_damage")
|
|
|
|
local stay_near = nil
|
2022-06-25 03:19:23 +02:00
|
|
|
active = false
|
|
|
|
minetest.register_on_mods_loaded(function()
|
|
|
|
for k,_ in pairs(minetest.registered_biomes) do
|
|
|
|
table.insert(biomekeys,k)
|
|
|
|
end
|
2022-07-31 06:17:09 +02:00
|
|
|
table.shuffle(biomekeys)
|
2022-06-25 03:19:23 +02:00
|
|
|
end)
|
|
|
|
|
|
|
|
local function next_biome()
|
|
|
|
current = current + 1
|
2022-06-25 06:18:26 +02:00
|
|
|
if biomekeys[current] and minetest.registered_biomes[biomekeys[current]] then
|
2022-06-25 03:19:23 +02:00
|
|
|
return minetest.registered_biomes[biomekeys[current]].name
|
|
|
|
end
|
2022-06-25 06:18:26 +02:00
|
|
|
current = 0
|
|
|
|
active = false
|
2022-06-25 03:19:23 +02:00
|
|
|
end
|
|
|
|
|
2022-07-31 06:17:09 +02:00
|
|
|
local function tp_biome(n)
|
2022-06-25 06:18:26 +02:00
|
|
|
local b = next_biome()
|
|
|
|
if not b then
|
|
|
|
minetest.chat_send_player(n,"Done! "..tostring(#biomekeys).." biomes visited.")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
if stay_near then
|
|
|
|
minetest.get_player_by_name(n):set_pos(stay_near)
|
|
|
|
end
|
|
|
|
minetest.registered_chatcommands["findbiome"].func(n,b)
|
|
|
|
local name = minetest.registered_biomes[biomekeys[current]].name
|
|
|
|
minetest.chat_send_player(n,"("..current.."/"..#biomekeys.."): "..name)
|
2022-07-31 06:17:09 +02:00
|
|
|
--minetest.log("action","[mcl_structures] BIOME: "..name)
|
|
|
|
if active then minetest.after(wait,tp_biome,n) end
|
2022-06-25 03:19:23 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_chatcommand("biometp",{
|
|
|
|
privs = {debug = true},
|
|
|
|
description = "Teleports to all biomes successively.",
|
2022-06-25 06:18:26 +02:00
|
|
|
params = "|<tp interval>|<stay>|<roam>",
|
2022-06-25 03:19:23 +02:00
|
|
|
func = function(n,p)
|
|
|
|
local pn = tonumber(p)
|
|
|
|
if pn and pn > 0 then
|
|
|
|
wait = pn
|
|
|
|
return true,"Biometp interval set to "..pn
|
|
|
|
end
|
2022-06-25 06:18:26 +02:00
|
|
|
if p == "stay" then
|
|
|
|
stay_near = vector.round(minetest.get_player_by_name(n):get_pos())
|
|
|
|
return true,"Staying around "..minetest.pos_to_string(stay_near)
|
|
|
|
end
|
|
|
|
if p == "roam" then
|
|
|
|
stay_near = nil
|
|
|
|
return true,"Roaming around freely"
|
|
|
|
end
|
2022-06-25 03:19:23 +02:00
|
|
|
if not active then
|
|
|
|
active = true
|
2022-06-25 06:18:26 +02:00
|
|
|
old_damage = minetest.settings:get_bool("enable_damage")
|
|
|
|
minetest.settings:set_bool("enable_damage",false)
|
2022-07-31 06:17:09 +02:00
|
|
|
minetest.after(wait,tp_biome,n)
|
2022-06-25 06:18:26 +02:00
|
|
|
if stay_near then minetest.get_player_by_name(n):set_pos(stay_near) end
|
2022-07-31 06:17:09 +02:00
|
|
|
return true,"Biometp started ETA: "..tostring(math.ceil(#biomekeys * wait / 60)) .."mins"
|
2022-06-25 03:19:23 +02:00
|
|
|
end
|
2022-06-25 06:18:26 +02:00
|
|
|
active = false
|
|
|
|
minetest.settings:set_bool("enable_damage",old_damage)
|
|
|
|
return true,"Biometp stopped"
|
2022-06-25 03:19:23 +02:00
|
|
|
end
|
|
|
|
})
|