3 local storage = minetest.get_mod_storage()
5 function warp.set(warp, pos)
6 if warp == "" or not pos then return false, "Missing parameter." end
7 local posstr = minetest.pos_to_string(pos)
8 storage:set_string(warp, posstr)
9 return true, "Warp " .. warp .. " set to " .. posstr .. "."
12 function warp.set_here(param)
13 local success, message = warp.set(param, vector.round(minetest.localplayer:get_pos()))
14 return success, message
17 function warp.get(param)
18 if param == "" then return false, "Missing parameter." end
19 local pos = storage:get_string(param)
20 if pos == "" then return false, "Warp " .. param .. " not set." end
21 return true, "Warp " .. param .. " is set to " .. pos .. ".", minetest.string_to_pos(pos)
24 function warp.delete(param)
25 if param == "" then return false, "Missing parameter." end
26 storage:set_string(param, "")
27 return true, "Deleted warp " .. param .. "."
30 minetest.register_chatcommand("setwarp", {
32 description = "Set a warp to your current position.",
36 minetest.register_chatcommand("readwarp", {
38 description = "Print the coordinates of a warp.",
42 minetest.register_chatcommand("deletewarp", {
44 description = "Delete a warp.",
48 local function do_warp(param)
49 if param == "" then return false, "Missing parameter." end
50 local success, pos = minetest.parse_pos(param)
53 success, msg, pos = warp.get(param)
58 minetest.localplayer:set_pos(pos)
59 return true, "Warped to " .. minetest.pos_to_string(pos)
62 minetest.register_chatcommand("warp", {
63 params = "<pos>|<warp>",
64 description = "Warp to a set warp or a position.",
68 minetest.register_chatcommand("warpandexit", {
69 params = "<pos>|<warp>",
70 description = "Warp to a set warp or a position and exit.",
71 func = function(param)
72 local s, m = do_warp(param)