mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 12:31:41 +09:00
Added spectate commands
This commit is contained in:
@@ -29,6 +29,7 @@ return {
|
|||||||
'modules.commands.home',
|
'modules.commands.home',
|
||||||
'modules.commands.connect',
|
'modules.commands.connect',
|
||||||
'modules.commands.last-location',
|
'modules.commands.last-location',
|
||||||
|
'modules.commands.spectate',
|
||||||
|
|
||||||
--- Addons
|
--- Addons
|
||||||
'modules.addons.chat-popups',
|
'modules.addons.chat-popups',
|
||||||
|
|||||||
@@ -102,6 +102,8 @@ Roles.new_role('Trainee','TrMod')
|
|||||||
'command/unjail',
|
'command/unjail',
|
||||||
'command/kick',
|
'command/kick',
|
||||||
'command/ban',
|
'command/ban',
|
||||||
|
'command/spectate',
|
||||||
|
'command/follow',
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Trusted Roles
|
--- Trusted Roles
|
||||||
@@ -115,6 +117,8 @@ Roles.new_role('Board Member','Board')
|
|||||||
:allow{
|
:allow{
|
||||||
'command/goto',
|
'command/goto',
|
||||||
'command/repair',
|
'command/repair',
|
||||||
|
'command/spectate',
|
||||||
|
'command/follow',
|
||||||
}
|
}
|
||||||
|
|
||||||
Roles.new_role('Senior Backer','Backer')
|
Roles.new_role('Senior Backer','Backer')
|
||||||
|
|||||||
@@ -82,4 +82,7 @@ offline=You cannot connect as the server is currently offline: __1__
|
|||||||
none-matching=No servers were found with that name, if you used an address please append true to the end of your command.
|
none-matching=No servers were found with that name, if you used an address please append true to the end of your command.
|
||||||
|
|
||||||
[expcom-lastlocation]
|
[expcom-lastlocation]
|
||||||
response=Last location of __1__ was [gps=__2__,__3__]
|
response=Last location of __1__ was [gps=__2__,__3__]
|
||||||
|
|
||||||
|
[expcom-spectate]
|
||||||
|
follow-self=You can not follow your self
|
||||||
33
modules/commands/spectate.lua
Normal file
33
modules/commands/spectate.lua
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
--[[-- Commands Module - Spectate
|
||||||
|
- Adds a commands relating to spectate and follow
|
||||||
|
@commands Spectate
|
||||||
|
]]
|
||||||
|
|
||||||
|
local Spectate = require 'modules.control.spectate' --- @dep modules.control.spectate
|
||||||
|
local Commands = require 'expcore.commands' --- @dep expcore.commands
|
||||||
|
require 'config.expcore.command_general_parse'
|
||||||
|
|
||||||
|
--- Toggles spectator mode for the caller
|
||||||
|
-- @command spectate
|
||||||
|
Commands.new_command('spectate', 'Toggles spectator mode')
|
||||||
|
:register(function(player)
|
||||||
|
if Spectate.is_spectating(player) then
|
||||||
|
Spectate.stop_spectate(player)
|
||||||
|
else
|
||||||
|
Spectate.start_spectate(player)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
--- Enters follow mode for the caller, following the given player.
|
||||||
|
-- @command follow
|
||||||
|
-- @tparam LuaPlayer player The player that will be followed
|
||||||
|
Commands.new_command('follow', 'Start following a player in spectator')
|
||||||
|
:add_alias('f')
|
||||||
|
:add_param('player', false, 'player-online')
|
||||||
|
:register(function(player, action_player)
|
||||||
|
if player == action_player then
|
||||||
|
return Commands.error{'expcom-spectate.follow-self'}
|
||||||
|
else
|
||||||
|
Spectate.start_follow(player, action_player)
|
||||||
|
end
|
||||||
|
end)
|
||||||
@@ -20,6 +20,14 @@ end)
|
|||||||
|
|
||||||
----- Public Functions -----
|
----- Public Functions -----
|
||||||
|
|
||||||
|
--- Test if a player is in spectator mode
|
||||||
|
-- @tparam LuaPlayer player The player to test the controller type of
|
||||||
|
-- @treturn boolean True if the player is in spectator mode
|
||||||
|
function Public.is_spectating(player)
|
||||||
|
assert(player and player.valid, 'Invalid player given to follower')
|
||||||
|
return player.controller_type == defines.controllers.spectator
|
||||||
|
end
|
||||||
|
|
||||||
--- Puts a player into spectator while maintaining an association to their character
|
--- Puts a player into spectator while maintaining an association to their character
|
||||||
-- @tparam LuaPlayer player The player that will be placed into spectator
|
-- @tparam LuaPlayer player The player that will be placed into spectator
|
||||||
-- @treturn boolean Returns false if the player was already in spectator
|
-- @treturn boolean Returns false if the player was already in spectator
|
||||||
@@ -47,6 +55,14 @@ function Public.stop_spectate(player)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Test if a player is in follow mode
|
||||||
|
-- @tparam LuaPlayer player The player to test the follow mode of
|
||||||
|
-- @treturn boolean True if the player is in follow mode
|
||||||
|
function Public.is_following(player)
|
||||||
|
assert(player and player.valid, 'Invalid player given to follower')
|
||||||
|
return following[player.index] ~= nil
|
||||||
|
end
|
||||||
|
|
||||||
--- Puts a player into spectator and follows an entity as it moves
|
--- Puts a player into spectator and follows an entity as it moves
|
||||||
-- @tparam LuaPlayer player The player that will follow the entity
|
-- @tparam LuaPlayer player The player that will follow the entity
|
||||||
-- @tparam ?LuaPlayer|LuaEntity entity The player or entity that will be followed
|
-- @tparam ?LuaPlayer|LuaEntity entity The player or entity that will be followed
|
||||||
|
|||||||
Reference in New Issue
Block a user