Update spectator_mode mod to Git commit 3648371...

https://github.com/minetest-mods/spectator_mode/tree/3648371
This commit is contained in:
Jordan Irwin 2021-04-12 18:05:17 -07:00
parent fdbd4d4a70
commit 72ea07c9eb
8 changed files with 44 additions and 28 deletions

View File

@ -16,7 +16,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
* [override][] ([MIT][lic.override]) -- version: [0.2 (e6dda7a Git)][ver.override] *2017-08-30*
* [privilegeareas][] ([WTFPL][lic.privilegeareas] / [CC0][lic.cc0]) -- version: [15eae20 Git][ver.privilegeareas] *2018-11-16*
* [privs][] ([CC0][lic.cc0])
* [spectator_mode][] ([WTFPL][lic.spectator_mode]) -- version: [7d68bec Git][ver.spectator_mode] *2017-03-30*
* [spectator_mode][] ([WTFPL][lic.spectator_mode]) -- version: [3648371 Git][ver.spectator_mode] *2020-07-15*
* [whitelist][] ([CC0][lic.cc0]) -- version: [0.1 (b813b19 Git)][ver.whitelist] *2017-08-18*
* [awards][] ([MIT][lic.awards]) -- version: [3.4.0][ver.awards] *2021-01-10*
* [antum][] ([MIT][lic.antum]) -- version: [69b39a4 Git][ver.antum] *2017-08-30*
@ -470,7 +470,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
[ver.slingshot]: https://github.com/AntumMT/mod-slingshot/tree/bb77525
[ver.snowdrift]: https://github.com/paramat/snowdrift/tree/3342939
[ver.spawneggs]: https://github.com/thefamilygrog66/spawneggs/tree/4650370
[ver.spectator_mode]: https://github.com/minetest-mods/spectator_mode/tree/7d68bec
[ver.spectator_mode]: https://github.com/minetest-mods/spectator_mode/tree/3648371
[ver.technic]: https://github.com/minetest-mods/technic/tree/43acec2
[ver.technic_armor]: https://github.com/stujones11/technic_armor/tree/694642f
[ver.throwing]: https://github.com/PilzAdam/throwing/tree/90bcf43

View File

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

View File

@ -1,12 +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.
Can be useful for admins or moderators in their task of monitoring.
Requires the privilege "watch".
Commands :
/watch <player name>
/unwatch (get back to your initial position)

View File

@ -0,0 +1,21 @@
# Spectator Mode
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.
Can be useful for admins or moderators in their task of monitoring.
Requires the privilege `watch`.
## Dependencies
- `player_api` (included in [`minetest_game`](https://github.com/minetest/minetest_game))
- `default` (included in [`minetest_game`](https://github.com/minetest/minetest_game))
## Requirements
This mod requires MT 5.0.0 and above.
## Commands
`/watch <player name>`<br>
`/unwatch` (get back to your initial position)

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

@ -1,6 +1,10 @@
local original_pos = {}
minetest.register_privilege("watch", "Player can watch other players")
minetest.register_privilege("watch", {
description = "Player can watch other players",
give_to_singleplayer = false,
give_to_admin = true,
})
local function toggle_hud_flags(player, bool)
local flags = player:hud_get_flags()
@ -19,7 +23,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}})
@ -28,7 +32,7 @@ local function unwatching(name)
watcher:set_properties({
visual_size = {x = 1, y = 1},
makes_footstep_sound = true,
collisionbox = {-0.3, -1, -0.3, 0.3, 1, 0.3}
collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3}
})
if not privs.interact and privs.watch == true then
@ -38,10 +42,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 +54,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 +62,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 +85,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 +93,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.
"""