Replace deprecated functions with newer ones
Also replaces `depends.txt` and `description.txt` with `mod.conf`.
This commit is contained in:
parent
7d68beccdd
commit
a2d69ad699
@ -8,4 +8,5 @@ read_globals = {
|
|||||||
|
|
||||||
globals = {
|
globals = {
|
||||||
"default",
|
"default",
|
||||||
|
"player_api",
|
||||||
}
|
}
|
||||||
|
@ -1 +0,0 @@
|
|||||||
default
|
|
@ -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.
|
|
18
init.lua
18
init.lua
@ -19,7 +19,7 @@ local function unwatching(name)
|
|||||||
|
|
||||||
if watcher and default.player_attached[name] == true then
|
if watcher and default.player_attached[name] == true then
|
||||||
watcher:set_detach()
|
watcher:set_detach()
|
||||||
default.player_attached[name] = false
|
player_api.player_attached[name] = false
|
||||||
watcher:set_eye_offset(vector.new(), vector.new())
|
watcher:set_eye_offset(vector.new(), vector.new())
|
||||||
watcher:set_nametag_attributes({color = {a = 255, r = 255, g = 255, b = 255}})
|
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]
|
local pos = original_pos[watcher]
|
||||||
if pos then
|
if pos then
|
||||||
-- setpos seems to be very unreliable
|
-- set_pos seems to be very unreliable
|
||||||
-- this workaround helps though
|
-- this workaround helps though
|
||||||
minetest.after(0.1, function()
|
minetest.after(0.1, function()
|
||||||
watcher:setpos(pos)
|
watcher:set_pos(pos)
|
||||||
end)
|
end)
|
||||||
original_pos[watcher] = nil
|
original_pos[watcher] = nil
|
||||||
end
|
end
|
||||||
@ -50,7 +50,7 @@ end
|
|||||||
|
|
||||||
minetest.register_chatcommand("watch", {
|
minetest.register_chatcommand("watch", {
|
||||||
params = "<to_name>",
|
params = "<to_name>",
|
||||||
description = "watch a given player",
|
description = "Watch a given player",
|
||||||
privs = {watch = true},
|
privs = {watch = true},
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local watcher = minetest.get_player_by_name(name)
|
local watcher = minetest.get_player_by_name(name)
|
||||||
@ -58,13 +58,13 @@ minetest.register_chatcommand("watch", {
|
|||||||
local privs = minetest.get_player_privs(name)
|
local privs = minetest.get_player_privs(name)
|
||||||
|
|
||||||
if target and watcher ~= target then
|
if target and watcher ~= target then
|
||||||
if default.player_attached[name] == true then
|
if player_api.player_attached[name] == true then
|
||||||
unwatching(param)
|
unwatching(param)
|
||||||
else
|
else
|
||||||
original_pos[watcher] = watcher:getpos()
|
original_pos[watcher] = watcher:get_pos()
|
||||||
end
|
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_attach(target, "", vector.new(0, -5, -20), vector.new())
|
||||||
watcher:set_eye_offset(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}})
|
watcher:set_nametag_attributes({color = {a = 0}})
|
||||||
@ -81,7 +81,7 @@ minetest.register_chatcommand("watch", {
|
|||||||
minetest.set_player_privs(name, privs)
|
minetest.set_player_privs(name, privs)
|
||||||
|
|
||||||
return true, "Watching '" .. param .. "' at "..
|
return true, "Watching '" .. param .. "' at "..
|
||||||
minetest.pos_to_string(vector.round(target:getpos()))
|
minetest.pos_to_string(vector.round(target:get_pos()))
|
||||||
end
|
end
|
||||||
|
|
||||||
return false, "Invalid parameter ('" .. param .. "')."
|
return false, "Invalid parameter ('" .. param .. "')."
|
||||||
@ -89,7 +89,7 @@ minetest.register_chatcommand("watch", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_chatcommand("unwatch", {
|
minetest.register_chatcommand("unwatch", {
|
||||||
description = "unwatch a player",
|
description = "Unwatch a player",
|
||||||
privs = {watch=true},
|
privs = {watch=true},
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
unwatching(name)
|
unwatching(name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user