Replace deprecated functions with newer ones

Also replaces `depends.txt` and `description.txt` with `mod.conf`.
This commit is contained in:
Panquesito7 2020-04-30 17:28:00 -05:00 committed by SmallJoker
parent 7d68beccdd
commit a2d69ad699
5 changed files with 15 additions and 12 deletions

View File

@ -8,4 +8,5 @@ read_globals = {
globals = {
"default",
"player_api",
}

View File

@ -1 +0,0 @@
default

View File

@ -1,2 +0,0 @@
A mod for Minetest allowing you to watch other players in their 3rd person view.
You're invisible and undetectable for the players when you're in this mode.

View File

@ -19,7 +19,7 @@ local function unwatching(name)
if watcher and default.player_attached[name] == true then
watcher:set_detach()
default.player_attached[name] = false
player_api.player_attached[name] = false
watcher:set_eye_offset(vector.new(), vector.new())
watcher:set_nametag_attributes({color = {a = 255, r = 255, g = 255, b = 255}})
@ -38,10 +38,10 @@ local function unwatching(name)
local pos = original_pos[watcher]
if pos then
-- setpos seems to be very unreliable
-- set_pos seems to be very unreliable
-- this workaround helps though
minetest.after(0.1, function()
watcher:setpos(pos)
watcher:set_pos(pos)
end)
original_pos[watcher] = nil
end
@ -50,7 +50,7 @@ end
minetest.register_chatcommand("watch", {
params = "<to_name>",
description = "watch a given player",
description = "Watch a given player",
privs = {watch = true},
func = function(name, param)
local watcher = minetest.get_player_by_name(name)
@ -58,13 +58,13 @@ minetest.register_chatcommand("watch", {
local privs = minetest.get_player_privs(name)
if target and watcher ~= target then
if default.player_attached[name] == true then
if player_api.player_attached[name] == true then
unwatching(param)
else
original_pos[watcher] = watcher:getpos()
original_pos[watcher] = watcher:get_pos()
end
default.player_attached[name] = true
player_api.player_attached[name] = true
watcher:set_attach(target, "", vector.new(0, -5, -20), vector.new())
watcher:set_eye_offset(vector.new(0, -5, -20), vector.new())
watcher:set_nametag_attributes({color = {a = 0}})
@ -81,7 +81,7 @@ minetest.register_chatcommand("watch", {
minetest.set_player_privs(name, privs)
return true, "Watching '" .. param .. "' at "..
minetest.pos_to_string(vector.round(target:getpos()))
minetest.pos_to_string(vector.round(target:get_pos()))
end
return false, "Invalid parameter ('" .. param .. "')."
@ -89,7 +89,7 @@ minetest.register_chatcommand("watch", {
})
minetest.register_chatcommand("unwatch", {
description = "unwatch a player",
description = "Unwatch a player",
privs = {watch=true},
func = function(name, param)
unwatching(name)

View File

@ -1 +1,6 @@
name = spectator_mode
depends = default, player_api
description = """
A mod for Minetest allowing you to watch other players in their 3rd person view.
You're invisible and undetectable for the players when you're in this mode.
"""