From 111b4e368611f5c58add8d51022aa9f9d9b9b092 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 21 Oct 2020 18:56:51 +0200 Subject: [PATCH 1/1] Initital Commit --- README | 1 + init.lua | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ mod.conf | 3 ++ 3 files changed, 98 insertions(+) create mode 100644 README create mode 100644 init.lua create mode 100644 mod.conf diff --git a/README b/README new file mode 100644 index 0000000..5a635ee --- /dev/null +++ b/README @@ -0,0 +1 @@ +A dragonfire CSM to set warps in the world and use the teleport exploit. diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..9eca734 --- /dev/null +++ b/init.lua @@ -0,0 +1,94 @@ +warp = {} + +local storage = minetest.get_mod_storage() + +function warp.set(warp, pos) + if warp == "" or not pos then return false, "Missing parameter." end + local posstr = minetest.pos_to_string(pos) + storage:set_string(warp, posstr) + return true, "Warp " .. warp .. " set to " .. posstr .. "." +end + +function warp.set_here(param) + local success, message = warp.set(param, vector.round(minetest.localplayer:get_pos())) + return success, message +end + +function warp.get(param) + if param == "" then return false, "Missing parameter." end + local pos = storage:get_string(param) + if pos == "" then return false, "Warp " .. param .. " not set." end + return true, "Warp " .. param .. " is set to " .. pos .. ".", minetest.string_to_pos(pos) +end + +function warp.delete(param) + if param == "" then return false, "Missing parameter." end + storage:set_string(param, "") + return true, "Deleted warp " .. param .. "." +end + +minetest.register_chatcommand("setwarp", { + params = "", + description = "Set a warp to your current position.", + func = warp.set_here, +}) + +minetest.register_chatcommand("readwarp", { + params = "", + description = "Print the coordinates of a warp.", + func = warp.get, +}) + +minetest.register_chatcommand("deletewarp", { + params = "", + description = "Delete a warp.", + func = warp.delete, +}) + +minetest.register_chatcommand("listwarps", { + description = "List all warps.", + func = function() + local warps = storage:to_table().fields + local warplist = {} + for warp in pairs(warps) do + table.insert(warplist, warp) + end + if #warplist > 0 then + return true, table.concat(warplist, ", ") + else + return false, "No warps set." + end + end, +}) + +local function do_warp(param) + if param == "" then return false, "Missing parameter." end + local success, pos = minetest.parse_pos(param) + if not success then + local msg + success, msg, pos = warp.get(param) + if not success then + return false, msg + end + end + minetest.localplayer:set_pos(pos) + return true, "Warped to " .. minetest.pos_to_string(pos) +end + +minetest.register_chatcommand("warp", { + params = "|", + description = "Warp to a set warp or a position.", + func = do_warp +}) + +minetest.register_chatcommand("warpandexit", { + params = "|", + description = "Warp to a set warp or a position and exit.", + func = function(param) + local s, m = do_warp(param) + if s then + minetest.disconnect() + end + return s,m + end +}) diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..d014d75 --- /dev/null +++ b/mod.conf @@ -0,0 +1,3 @@ +name = warp +author = Fleckenstein +description = Set custom warps and use the teleport exploit -- 2.44.0