From 57aeecc76edddc8c6cfa9614df8e12272a65313c Mon Sep 17 00:00:00 2001 From: cora Date: Sat, 25 Jun 2022 03:19:23 +0200 Subject: [PATCH] Add biometp --- biometp/init.lua | 45 +++++++++++++++++++++++++++++++++++++++++++++ biometp/mod.conf | 3 +++ 2 files changed, 48 insertions(+) create mode 100644 biometp/init.lua create mode 100644 biometp/mod.conf diff --git a/biometp/init.lua b/biometp/init.lua new file mode 100644 index 0000000..3c22efe --- /dev/null +++ b/biometp/init.lua @@ -0,0 +1,45 @@ +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(5,tp_step,n) end +end + +minetest.register_chatcommand("biometp",{ + privs = {debug = true}, + description = "Teleports to all biomes successively.", + params = "|", + 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 +}) diff --git a/biometp/mod.conf b/biometp/mod.conf new file mode 100644 index 0000000..664f751 --- /dev/null +++ b/biometp/mod.conf @@ -0,0 +1,3 @@ +name = biometp +author = cora +description = Adds the /biometp debug command that teleports to all biomes successively waiting a set interval