mirror of
https://codeberg.org/tenplus1/teleport_potion.git
synced 2025-07-04 21:50:27 -04:00
add "teleport_potion_enable_protection" setting for protection checks.
This commit is contained in:
parent
37a84c6f71
commit
f2766f8bbc
3 changed files with 22 additions and 8 deletions
|
@ -7,7 +7,7 @@ https://forum.minetest.net/viewtopic.php?f=9&t=9234
|
||||||
|
|
||||||
Change log:
|
Change log:
|
||||||
|
|
||||||
- 1.5 - Use moveresult when throwing teleport potion, has switcharoo effect
|
- 1.5 - Use moveresult when throwing teleport potion, has switcharoo effect, add "teleport_potion_enable_protection" to enable protection checks.
|
||||||
- 1.4 - Change Pad texture so it's not as contrasting, check for attached player before tp.
|
- 1.4 - Change Pad texture so it's not as contrasting, check for attached player before tp.
|
||||||
- 1.3 - Added some formspec checks and switch to enable old teleport pad texture (thanks mazes 80)
|
- 1.3 - Added some formspec checks and switch to enable old teleport pad texture (thanks mazes 80)
|
||||||
- 1.2 - New teleport pad texture, code tweaks to work with minetest 5.x
|
- 1.2 - New teleport pad texture, code tweaks to work with minetest 5.x
|
||||||
|
|
25
init.lua
25
init.lua
|
@ -11,6 +11,7 @@
|
||||||
local S = core.get_translator("teleport_potion")
|
local S = core.get_translator("teleport_potion")
|
||||||
local mcl = core.get_modpath("mcl_core")
|
local mcl = core.get_modpath("mcl_core")
|
||||||
local dist = tonumber(core.settings:get("map_generation_limit") or 31000)
|
local dist = tonumber(core.settings:get("map_generation_limit") or 31000)
|
||||||
|
local use_protection = core.settings:get_bool("teleport_potion_enable_protection")
|
||||||
|
|
||||||
-- creative check
|
-- creative check
|
||||||
|
|
||||||
|
@ -85,6 +86,10 @@ local teleport_destinations = {}
|
||||||
|
|
||||||
local function set_teleport_destination(playername, dest)
|
local function set_teleport_destination(playername, dest)
|
||||||
|
|
||||||
|
if use_protection and core.is_protected(dest, playername) then
|
||||||
|
core.chat_send_player(playername, S("Destination protected!")) ; return
|
||||||
|
end
|
||||||
|
|
||||||
teleport_destinations[playername] = dest
|
teleport_destinations[playername] = dest
|
||||||
|
|
||||||
effect(dest, 20, "teleport_potion_particle.png", 0.5, 1.5, 1, 7, 15)
|
effect(dest, 20, "teleport_potion_particle.png", 0.5, 1.5, 1, 7, 15)
|
||||||
|
@ -185,7 +190,17 @@ potion_entity.on_step = function(self, dtime, moveresult)
|
||||||
local oldpos = self.player:get_pos()
|
local oldpos = self.player:get_pos()
|
||||||
|
|
||||||
-- if we hit a player or mob then switch positions
|
-- if we hit a player or mob then switch positions
|
||||||
local def = moveresult.collisions and moveresult.collisions[1]
|
local def = moveresult.collisions and moveresult.collisions[1] or {}
|
||||||
|
local playername = self.player:get_player_name() or ""
|
||||||
|
|
||||||
|
-- if protection enabled check if we can teleport or drop potion
|
||||||
|
if use_protection and core.is_protected(pos, playername) then
|
||||||
|
|
||||||
|
core.chat_send_player(playername, S("Destination protected!"))
|
||||||
|
core.add_item(pos, "teleport_potion:potion")
|
||||||
|
|
||||||
|
self.object:remove() ; return
|
||||||
|
end
|
||||||
|
|
||||||
if def.object then
|
if def.object then
|
||||||
def.object:set_pos(oldpos)
|
def.object:set_pos(oldpos)
|
||||||
|
@ -311,12 +326,8 @@ core.register_node("teleport_potion:pad", {
|
||||||
wield_image = teleport_pad_texture,
|
wield_image = teleport_pad_texture,
|
||||||
light_source = 5,
|
light_source = 5,
|
||||||
groups = {snappy = 3},
|
groups = {snappy = 3},
|
||||||
node_box = {
|
node_box = {type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, -6/16, 0.5}},
|
||||||
type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, -6/16, 0.5}
|
selection_box = {type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, -6/16, 0.5}},
|
||||||
},
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, -6/16, 0.5}
|
|
||||||
},
|
|
||||||
|
|
||||||
-- Save pointed nodes coordinates as destination for further portals
|
-- Save pointed nodes coordinates as destination for further portals
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
|
|
|
@ -1,2 +1,5 @@
|
||||||
# If enabled texture pad will use the old texture
|
# If enabled texture pad will use the old texture
|
||||||
teleport_potion_use_old_texture (Use old texture for teleport pad) bool false
|
teleport_potion_use_old_texture (Use old texture for teleport pad) bool false
|
||||||
|
|
||||||
|
# If enabled players cannot bookmark protected positions
|
||||||
|
teleport_potion_enable_protection (Cannot set teleport to protected areas) bool false
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue