mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 12:31:41 +09:00
Added /tp /bring and /goto and some comments
This commit is contained in:
@@ -20,6 +20,7 @@ local files = {
|
|||||||
'modules.commands.kill',
|
'modules.commands.kill',
|
||||||
'modules.commands.admin-chat',
|
'modules.commands.admin-chat',
|
||||||
'modules.commands.tag',
|
'modules.commands.tag',
|
||||||
|
'modules.commands.teleport',
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Loads all files in array above and logs progress
|
-- Loads all files in array above and logs progress
|
||||||
|
|||||||
@@ -464,14 +464,14 @@ function Commands._prototype:register(callback)
|
|||||||
end
|
end
|
||||||
self.description = description
|
self.description = description
|
||||||
-- registers the command under its own name
|
-- registers the command under its own name
|
||||||
commands.add_command(self.name,description..' '..self.help,function(command_event)
|
commands.add_command(self.name,{'expcore-commands.command-help',description,self.help},function(command_event)
|
||||||
local success, err = pcall(Commands.run_command,command_event)
|
local success, err = pcall(Commands.run_command,command_event)
|
||||||
if not success then log('[ERROR] command/'..self.name..' :: '..err) end
|
if not success then log('[ERROR] command/'..self.name..' :: '..err) end
|
||||||
end)
|
end)
|
||||||
-- adds any aliases that it has
|
-- adds any aliases that it has
|
||||||
for _,alias in pairs(self.aliases) do
|
for _,alias in pairs(self.aliases) do
|
||||||
if not commands.commands[alias] and not commands.game_commands[alias] then
|
if not commands.commands[alias] and not commands.game_commands[alias] then
|
||||||
commands.add_command(alias,description..' '..self.help,function(command_event)
|
commands.add_command(alias,{'expcore-commands.command-help',description,self.help},function(command_event)
|
||||||
command_event.name = self.name
|
command_event.name = self.name
|
||||||
local success, err = pcall(Commands.run_command,command_event)
|
local success, err = pcall(Commands.run_command,command_event)
|
||||||
Commands.internal_error(success,self.name,err)
|
Commands.internal_error(success,self.name,err)
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ end)
|
|||||||
Commands.add_parse('player-alive',function(input,player,reject)
|
Commands.add_parse('player-alive',function(input,player,reject)
|
||||||
local input_player = Commands.parse('player-online',input,player,reject)
|
local input_player = Commands.parse('player-online',input,player,reject)
|
||||||
if not input_player then return end -- nil check
|
if not input_player then return end -- nil check
|
||||||
if not input_player.character or not input_player.character.health > 0 then
|
if not input_player.character or not input_player.character.health or input_player.character.health <= 0 then
|
||||||
return reject{'expcore-commands.reject-player-alive'}
|
return reject{'expcore-commands.reject-player-alive'}
|
||||||
else
|
else
|
||||||
return input_player
|
return input_player
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ reject-force=Invaild Force Name
|
|||||||
reject-surface=Invaild surface Name
|
reject-surface=Invaild surface Name
|
||||||
invalid-inputs=Invalid Input, /__1__ __2__
|
invalid-inputs=Invalid Input, /__1__ __2__
|
||||||
invalid-param=Invalid Param "__1__"; __2__
|
invalid-param=Invalid Param "__1__"; __2__
|
||||||
|
command-help=__1__ - __2__
|
||||||
command-ran=Command Complete
|
command-ran=Command Complete
|
||||||
command-fail=Command failed to run: __1__
|
command-fail=Command failed to run: __1__
|
||||||
command-error-log-format=[ERROR] command/__1__ :: __2__
|
command-error-log-format=[ERROR] command/__1__ :: __2__
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
[exp-commands]
|
[exp-commands]
|
||||||
kill-already-dead=You are already dead.
|
kill-already-dead=You are already dead.
|
||||||
admin-chat-format=[Admin Chat] [color=__3__]__1__: __2__
|
admin-chat-format=[Admin Chat] [color=__3__]__1__: __2__
|
||||||
|
tp-no-position-found=No position to teleport to was found, please try again later.
|
||||||
|
tp-to-self=Player can not be teleported to them selfs.
|
||||||
@@ -11,6 +11,7 @@ reject-force=Invaild Force Name
|
|||||||
reject-surface=Invaild surface Name
|
reject-surface=Invaild surface Name
|
||||||
invalid-inputs=Invalid Input, /__1__ __2__
|
invalid-inputs=Invalid Input, /__1__ __2__
|
||||||
invalid-param=Invalid Param "__1__"; __2__
|
invalid-param=Invalid Param "__1__"; __2__
|
||||||
|
command-help=__1__ - __2__
|
||||||
command-ran=Command Complete
|
command-ran=Command Complete
|
||||||
command-fail=Command failed to run: __1__
|
command-fail=Command failed to run: __1__
|
||||||
command-error-log-format=[ERROR] command/__1__ :: __2__
|
command-error-log-format=[ERROR] command/__1__ :: __2__
|
||||||
@@ -2,7 +2,7 @@ local Commands = require 'expcore.commands'
|
|||||||
require 'expcore.common_parse'
|
require 'expcore.common_parse'
|
||||||
|
|
||||||
Commands.new_command('admin-chat','Sends a message in chat that only admins can see.')
|
Commands.new_command('admin-chat','Sends a message in chat that only admins can see.')
|
||||||
:add_param('message',false)
|
:add_param('message',false) -- the message to send in the admin chat
|
||||||
:enable_auto_concat()
|
:enable_auto_concat()
|
||||||
:add_tag('admin_only',true)
|
:add_tag('admin_only',true)
|
||||||
:add_alias('ac')
|
:add_alias('ac')
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
[exp-commands]
|
[exp-commands]
|
||||||
kill-already-dead=You are already dead.
|
kill-already-dead=You are already dead.
|
||||||
admin-chat-format=[Admin Chat] [color=__3__]__1__: __2__
|
admin-chat-format=[Admin Chat] [color=__3__]__1__: __2__
|
||||||
|
tp-no-position-found=No position to teleport to was found, please try again later.
|
||||||
|
tp-to-self=Player can not be teleported to them selfs.
|
||||||
@@ -2,7 +2,7 @@ local Commands = require 'expcore.commands'
|
|||||||
require 'expcore.common_parse'
|
require 'expcore.common_parse'
|
||||||
|
|
||||||
Commands.new_command('kill','Kills yourself or another player.')
|
Commands.new_command('kill','Kills yourself or another player.')
|
||||||
:add_param('player',true,'player-alive')
|
:add_param('player',true,'player-alive') -- the player to kill, must be alive to be valid
|
||||||
:add_defaults{player=function(player)
|
:add_defaults{player=function(player)
|
||||||
-- default is the player unless they are dead
|
-- default is the player unless they are dead
|
||||||
if player.character and player.character.health > 0 then
|
if player.character and player.character.health > 0 then
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
local Commands = require 'expcore.commands'
|
local Commands = require 'expcore.commands'
|
||||||
|
|
||||||
Commands.new_command('me','Sends an action message in the chat')
|
Commands.new_command('me','Sends an action message in the chat')
|
||||||
:add_param('action',false)
|
:add_param('action',false) -- action that is done by the player, just text its meaningless
|
||||||
:enable_auto_concat()
|
:enable_auto_concat()
|
||||||
:register(function(player,action,raw)
|
:register(function(player,action,raw)
|
||||||
game.print(string.format('* %s %s *',player.name,action),player.chat_color)
|
game.print(string.format('* %s %s *',player.name,action),player.chat_color)
|
||||||
|
|||||||
@@ -2,16 +2,16 @@ local Commands = require 'expcore.commands'
|
|||||||
require 'expcore.common_parse'
|
require 'expcore.common_parse'
|
||||||
|
|
||||||
Commands.new_command('tag','Sets your player tag.')
|
Commands.new_command('tag','Sets your player tag.')
|
||||||
:add_param('tag',false,'string-max-length',20)
|
:add_param('tag',false,'string-max-length',20) -- new tag for your player max 20 char
|
||||||
:enable_auto_concat()
|
:enable_auto_concat()
|
||||||
:register(function(player,tag,raw)
|
:register(function(player,tag,raw)
|
||||||
player.tag = ' - '..tag
|
player.tag = ' - '..tag
|
||||||
end)
|
end)
|
||||||
|
|
||||||
Commands.new_command('tag-clear','Clears your tag. Or another player if you are admin.')
|
Commands.new_command('tag-clear','Clears your tag. Or another player if you are admin.')
|
||||||
:add_param('player',true,'player')
|
:add_param('player',true,'player') -- player to remove the tag of, nil to apply to self
|
||||||
:add_defaults{player=function(player)
|
:add_defaults{player=function(player)
|
||||||
return player
|
return player -- default is the user using the command
|
||||||
end}
|
end}
|
||||||
:register(function(player,action_player,raw)
|
:register(function(player,action_player,raw)
|
||||||
if action_player.index == player.index then
|
if action_player.index == player.index then
|
||||||
|
|||||||
55
modules/commands/teleport.lua
Normal file
55
modules/commands/teleport.lua
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
local Commands = require 'expcore.commands'
|
||||||
|
require 'expcore.common_parse'
|
||||||
|
|
||||||
|
local function teleport(from_player,to_player)
|
||||||
|
local surface = to_player.surface
|
||||||
|
local position = surface.find_non_colliding_position('player',to_player.position,32,1)
|
||||||
|
if not position then return false end -- return false if no new position
|
||||||
|
from_player.teleport(position,surface)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
Commands.new_command('teleport','Teleports a player to another player.')
|
||||||
|
:add_param('from_player',false,'player-alive') -- player that will be teleported, must be alive
|
||||||
|
:add_param('to_player',false,'player-online') -- player to teleport to, must be online (if dead goes to where they died)
|
||||||
|
:add_alias('tp')
|
||||||
|
:add_tag('admin_only',true)
|
||||||
|
:register(function(player,from_player,to_player,raw)
|
||||||
|
if from_player.index == to_player.index then
|
||||||
|
-- return if attempting to teleport to self
|
||||||
|
return Commands.error{'exp-commands.tp-to-self'}
|
||||||
|
end
|
||||||
|
if not teleport(from_player,to_player) then
|
||||||
|
-- return if the teleport failed
|
||||||
|
return Commands.error{'exp-commands.tp-no-position-found'}
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
Commands.new_command('bring','Teleports a player to you.')
|
||||||
|
:add_param('player',false,'player-alive') -- player that will be teleported, must be alive
|
||||||
|
:add_tag('admin_only',true)
|
||||||
|
:register(function(player,from_player,raw)
|
||||||
|
if from_player.index == player.index then
|
||||||
|
-- return if attempting to teleport to self
|
||||||
|
return Commands.error{'exp-commands.tp-to-self'}
|
||||||
|
end
|
||||||
|
if not teleport(from_player,player) then
|
||||||
|
-- return if the teleport failed
|
||||||
|
return Commands.error{'exp-commands.tp-no-position-found'}
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
Commands.new_command('goto','Teleports you to a player.')
|
||||||
|
:add_param('player',false,'player-online') -- player to teleport to, must be online (if dead goes to where they died)
|
||||||
|
:add_alias('tp-me','tpme')
|
||||||
|
:add_tag('admin_only',true)
|
||||||
|
:register(function(player,to_player,raw)
|
||||||
|
if to_player.index == player.index then
|
||||||
|
-- return if attempting to teleport to self
|
||||||
|
return Commands.error{'exp-commands.tp-to-self'}
|
||||||
|
end
|
||||||
|
if not teleport(player,to_player) then
|
||||||
|
-- return if the teleport failed
|
||||||
|
return Commands.error{'exp-commands.tp-no-position-found'}
|
||||||
|
end
|
||||||
|
end)
|
||||||
Reference in New Issue
Block a user