Add files via upload

This commit is contained in:
Toby 2021-09-30 18:21:07 +03:00 committed by GitHub
commit e44a2b08c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 60 additions and 0 deletions

21
LICENSE Normal file

@ -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.

10
README.md Normal file

@ -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``.

27
init.lua Normal file

@ -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
})

2
mod.conf Normal file

@ -0,0 +1,2 @@
name = death_pos
description = Adds a command to return back to position where you died