From a5eef1c5de77fa7770877802e66c3e1c53f9a0da Mon Sep 17 00:00:00 2001 From: Vanessa Dannenberg Date: Wed, 24 Apr 2019 18:59:36 -0400 Subject: update castles, areas, homedecor, plantlife, gloopblocks, hotbar, inspector, maptools, mesecons, moreblocks, moreores, technic, teleport_request, and worldedit switched to caverealms_lite (with minor fixes by me) switched to CWz's fork of player_textures The homedecor update brings in the big split, and will require you to re-enable all modpack components in order to avoid loss of content. --- teleport_request/init.lua | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'teleport_request') diff --git a/teleport_request/init.lua b/teleport_request/init.lua index cf843b0..f51c555 100644 --- a/teleport_request/init.lua +++ b/teleport_request/init.lua @@ -10,6 +10,11 @@ local version = "1.5" local tpr_list = {} local tphr_list = {} +local map_size = 30912 +local function can_teleport(to) + return to.x < map_size and to.x > -map_size and to.y < map_size and to.y > -map_size and to.z < map_size and to.z > -map_size +end + minetest.register_privilege("tp_admin", { description = "Admin overrides for tps_teleport.", give_to_singleplayer=false @@ -121,14 +126,14 @@ local function tpc_send(player,coordinates) minetest.chat_send_player(player, "Usage: /tpc ") return nil end - - if posx > 32765 or posx < -32765 or posy > 32765 or posy < -32765 or posz > 32765 or posz < -32765 then - minetest.chat_send_player(player, "Error: Invalid coordinates.") - return nil - end local target_coords={x=posx, y=posy, z=posz} + if can_teleport(target_coords) == false then + minetest.chat_send_player("You cannot teleport to a location outside the map!") + return nil + end + -- If the area is protected, reject the user's request to teleport to these coordinates -- In future release we'll actually query the player who owns the area, if they're online, and ask for their permission. -- Admin user (priv "tp_admin") overrides all protection @@ -235,22 +240,21 @@ local function tpj(player,param) local target_coords = minetest.get_player_by_name(player):getpos() if args[1] == "x" then target_coords["x"] = target_coords["x"] + tonumber(args[2]) - pname:setpos(find_free_position_near(target_coords)) - minetest.sound_play("whoosh", {pos = target_coords, gain = 0.5, max_hear_distance = 10}) - --parti2(target_coords) elseif args[1] == "y" then target_coords["y"] = target_coords["y"] + tonumber(args[2]) - pname:setpos(find_free_position_near(target_coords)) - minetest.sound_play("whoosh", {pos = target_coords, gain = 0.5, max_hear_distance = 10}) - --parti2(target_coords) elseif args[1] == "z" then target_coords["z"] = target_coords["z"] + tonumber(args[2]) - pname:setpos(find_free_position_near(target_coords)) - minetest.sound_play("whoosh", {pos = target_coords, gain = 0.5, max_hear_distance = 10}) - --parti2(target_coords) else minetest.chat_send_player(player,"Not a valid axis. Valid options are X, Y or Z.") + return + end + if can_teleport(target_coords) == false then + minetest.chat_send_player(player, "You cannot teleport to a location outside the map!") + return end + pname:setpos(find_free_position_near(target_coords)) + minetest.sound_play("whoosh", {pos = target_coords, gain = 0.5, max_hear_distance = 10}) + --parti2(target_coords) end -- Evade -- cgit v1.2.3