commit e44a2b08c75b622a73678295f7d727600e1023a2 Author: Toby <69259430+BrownHedgehog78@users.noreply.github.com> Date: Thu Sep 30 18:21:07 2021 +0300 Add files via upload diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..7693f04 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 BlueR23 (BrownHedgehog78) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..8a4a214 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +# Death Position + +Minetest mod that adds a command to teleport to player's last death position + +### Usage + +Use ``/death_pos`` command to return back to the last death position. + +#### Settings +To disable message that sends a tip when player dies, add setting ``death_pos.send_tip_on_die`` in ``minetest.conf`` and set it to ``false``, it should be like this: ``death_pos.send_tip_on_die = false``. When player uses the `/death_pos` command it clears the death pos and the player can't teleport to the last death position again, but you can disable it, add this setting in ``minetest.conf``: ``death_pos.clear_pos = false``. \ No newline at end of file diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..e283b96 --- /dev/null +++ b/init.lua @@ -0,0 +1,27 @@ +local death_pos = {} + +minetest.register_on_dieplayer(function(player, reason) + local send_tip = minetest.settings:get("death_pos.send_tip_on_die") or true -- Sends tip to use 'death_pos' command when player dies (if true) + death_pos[player:get_player_name()] = player:get_pos() + if player and send_tip == true then + minetest.chat_send_player(player:get_player_name(), minetest.colorize("#60e645", "You died. You can return back to your last death position by using /death_pos command")) + end +end) + +minetest.register_chatcommand("death_pos", { + description = "Go to your last death position", + func = function(name) + local player = minetest.get_player_by_name(name) + local pos = death_pos[player:get_player_name()] + local clear_pos = minetest.settings:get("death_pos.clear_pos") or true -- Clears the death position when 'death_pos' command is used (if true) + if pos then + player:set_pos(pos) + if clear_pos == true then + death_pos[player:get_player_name()] = nil + end + return false, minetest.colorize("#60e645", "Teleported you back to your death position!") + else + return false, "You don't have a death position right now" + end + end +}) \ No newline at end of file diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..1725777 --- /dev/null +++ b/mod.conf @@ -0,0 +1,2 @@ +name = death_pos +description = Adds a command to return back to position where you died