mirror of
https://github.com/BrownHedgehog78/death_pos.git
synced 2024-11-23 15:43:46 +01:00
Improve the mod a bit
This commit is contained in:
commit
5af7b5e450
21
LICENSE
Normal file
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
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``.
|
46
init.lua
Normal file
46
init.lua
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
local death_pos = {}
|
||||||
|
local was_killed = {}
|
||||||
|
local tip_sent = {}
|
||||||
|
|
||||||
|
minetest.register_on_dieplayer(function(player, reason)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
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[name] = player:get_pos()
|
||||||
|
if reason.type == "punch" and reason.object:is_player() then
|
||||||
|
if reason.object:get_player_name() ~= name then
|
||||||
|
was_killed[name] = true
|
||||||
|
minetest.after(30, function()
|
||||||
|
was_killed[name] = nil
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if player and send_tip == true and not tip_sent[name] then
|
||||||
|
minetest.chat_send_player(name, minetest.colorize("#60e645", "You died. You can return back to your last death position by using /death_pos command"))
|
||||||
|
tip_sent[name] = true
|
||||||
|
minetest.after(10, function()
|
||||||
|
tip_sent[name] = nil
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_chatcommand("death_pos", {
|
||||||
|
description = "Go to your last death position",
|
||||||
|
privs = {interact = true},
|
||||||
|
func = function(name)
|
||||||
|
local player = minetest.get_player_by_name(name)
|
||||||
|
local pos = death_pos[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 was_killed[name] then
|
||||||
|
return false, "You were killed by a player, you cannot teleport to your death position right now"
|
||||||
|
end
|
||||||
|
if pos then
|
||||||
|
player:set_pos(pos)
|
||||||
|
if clear_pos == true then
|
||||||
|
death_pos[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
|
||||||
|
})
|
5
mod.conf
Normal file
5
mod.conf
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
name = death_pos
|
||||||
|
description = Adds a command to return back to position where you died
|
||||||
|
release = 9430
|
||||||
|
title = Death Position
|
||||||
|
author = BlueR23
|
Loading…
Reference in New Issue
Block a user