Added /tp /bring and /goto and some comments

This commit is contained in:
Cooldude2606
2019-03-05 20:34:17 +00:00
parent 08038272b6
commit 402548dded
12 changed files with 73 additions and 11 deletions

View File

@@ -2,7 +2,7 @@ local Commands = require 'expcore.commands'
require 'expcore.common_parse'
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()
:add_tag('admin_only',true)
:add_alias('ac')

View File

@@ -1,3 +1,5 @@
[exp-commands]
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.

View File

@@ -2,7 +2,7 @@ local Commands = require 'expcore.commands'
require 'expcore.common_parse'
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)
-- default is the player unless they are dead
if player.character and player.character.health > 0 then

View File

@@ -1,7 +1,7 @@
local Commands = require 'expcore.commands'
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()
:register(function(player,action,raw)
game.print(string.format('* %s %s *',player.name,action),player.chat_color)

View File

@@ -2,16 +2,16 @@ local Commands = require 'expcore.commands'
require 'expcore.common_parse'
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()
:register(function(player,tag,raw)
player.tag = ' - '..tag
end)
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)
return player
return player -- default is the user using the command
end}
:register(function(player,action_player,raw)
if action_player.index == player.index then

View 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)