simplification
This commit is contained in:
parent
bd6487a055
commit
1dc7aff26d
13
init.lua
13
init.lua
@ -7,18 +7,15 @@ minetest.register_chatcommand("watch", {
|
||||
description = "watch a given player",
|
||||
privs = {watch=true},
|
||||
func = function(name, param)
|
||||
local watcher, watched = nil, nil
|
||||
local watcher, target = nil, nil
|
||||
watcher = minetest.get_player_by_name(name)
|
||||
watched = param:match("^([^ ]+)$")
|
||||
local watched_player = minetest.get_player_by_name(watched)
|
||||
target = minetest.get_player_by_name(param:match("^([^ ]+)$"))
|
||||
original_pos[watcher] = watcher:getpos()
|
||||
local privs = minetest.get_player_privs(name)
|
||||
|
||||
if name ~= watched and watched and watched_player and watcher and
|
||||
default.player_attached[name] == false then
|
||||
|
||||
if target and watcher ~= target and default.player_attached[name] == false then
|
||||
default.player_attached[name] = true
|
||||
watcher:set_attach(watched_player, "", {x=0, y=5, z=-20}, {x=0, y=0, z=0})
|
||||
watcher:set_attach(target, "", {x=0, y=5, z=-20}, {x=0, y=0, z=0})
|
||||
watcher:set_eye_offset({x=0, y=5, z=-20},{x=0, y=0, z=0})
|
||||
watcher:set_nametag_attributes({color = {a=0}})
|
||||
|
||||
@ -38,7 +35,7 @@ minetest.register_chatcommand("watch", {
|
||||
privs.interact = nil
|
||||
minetest.set_player_privs(name, privs)
|
||||
|
||||
return true, "Watching '"..watched.."' at "..minetest.pos_to_string(vector.round(watched_player:getpos()))
|
||||
return true, "Watching '"..param.."' at "..minetest.pos_to_string(vector.round(target:getpos()))
|
||||
end
|
||||
|
||||
return false, "Invalid parameters ('"..param.."') or you're already watching a player."
|
||||
|
Loading…
x
Reference in New Issue
Block a user