biometp: clean up
This commit is contained in:
parent
49e3497738
commit
44befb2ead
|
@ -1,6 +1,8 @@
|
||||||
local current = 0
|
local current = 0
|
||||||
local biomekeys = {}
|
local biomekeys = {}
|
||||||
local wait = 15
|
local wait = 15
|
||||||
|
local old_damage = minetest.settings:get_bool("enable_damage")
|
||||||
|
local stay_near = nil
|
||||||
active = false
|
active = false
|
||||||
minetest.register_on_mods_loaded(function()
|
minetest.register_on_mods_loaded(function()
|
||||||
for k,_ in pairs(minetest.registered_biomes) do
|
for k,_ in pairs(minetest.registered_biomes) do
|
||||||
|
@ -10,36 +12,57 @@ end)
|
||||||
|
|
||||||
local function next_biome()
|
local function next_biome()
|
||||||
current = current + 1
|
current = current + 1
|
||||||
if biomekeys[current] then
|
if biomekeys[current] and minetest.registered_biomes[biomekeys[current]] then
|
||||||
return minetest.registered_biomes[biomekeys[current]].name
|
return minetest.registered_biomes[biomekeys[current]].name
|
||||||
else
|
|
||||||
current = 0
|
|
||||||
end
|
end
|
||||||
|
current = 0
|
||||||
|
active = false
|
||||||
end
|
end
|
||||||
|
|
||||||
local function tp_step(n)
|
local function tp_step(n)
|
||||||
minetest.registered_chatcommands["findbiome"].func(n,next_biome())
|
local b = next_biome()
|
||||||
minetest.chat_send_player(n,"Teleporting to "..minetest.registered_biomes[biomekeys[current]].name.." ("..current.."/"..#biomekeys..")")
|
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)
|
||||||
|
minetest.log("action","[mcl_structures] BIOME: "..name)
|
||||||
if active then minetest.after(wait,tp_step,n) end
|
if active then minetest.after(wait,tp_step,n) end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_chatcommand("biometp",{
|
minetest.register_chatcommand("biometp",{
|
||||||
privs = {debug = true},
|
privs = {debug = true},
|
||||||
description = "Teleports to all biomes successively.",
|
description = "Teleports to all biomes successively.",
|
||||||
params = "|<tp interval>",
|
params = "|<tp interval>|<stay>|<roam>",
|
||||||
func = function(n,p)
|
func = function(n,p)
|
||||||
local pn = tonumber(p)
|
local pn = tonumber(p)
|
||||||
if pn and pn > 0 then
|
if pn and pn > 0 then
|
||||||
wait = pn
|
wait = pn
|
||||||
return true,"Biometp interval set to "..pn
|
return true,"Biometp interval set to "..pn
|
||||||
end
|
end
|
||||||
|
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
|
||||||
if not active then
|
if not active then
|
||||||
active = true
|
active = true
|
||||||
tp_step(n)
|
old_damage = minetest.settings:get_bool("enable_damage")
|
||||||
|
minetest.settings:set_bool("enable_damage",false)
|
||||||
|
minetest.after(wait,tp_step,n)
|
||||||
|
if stay_near then minetest.get_player_by_name(n):set_pos(stay_near) end
|
||||||
return true,"Biometp started ETA: "..#biomekeys * wait / 60 .."mins"
|
return true,"Biometp started ETA: "..#biomekeys * wait / 60 .."mins"
|
||||||
else
|
end
|
||||||
active = false
|
active = false
|
||||||
|
minetest.settings:set_bool("enable_damage",old_damage)
|
||||||
return true,"Biometp stopped"
|
return true,"Biometp stopped"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue