mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 12:31:41 +09:00
Fixed Existing Lua Check Errors
This commit is contained in:
@@ -10,16 +10,16 @@ require 'config.expcore.command_general_parse'
|
||||
--- Sends a message in chat that only admins can see
|
||||
-- @command admin-chat
|
||||
-- @tparam string message the message to send in the admin chat
|
||||
Commands.new_command('admin-chat','Sends a message in chat that only admins can see.')
|
||||
:add_param('message',false)
|
||||
Commands.new_command('admin-chat', 'Sends a message in chat that only admins can see.')
|
||||
:add_param('message', false)
|
||||
:enable_auto_concat()
|
||||
:set_flag('admin_only')
|
||||
:add_alias('ac')
|
||||
:register(function(player,message,raw)
|
||||
:register(function(player, message)
|
||||
local player_name_colour = format_chat_player_name(player)
|
||||
for _,return_player in pairs(game.connected_players) do
|
||||
for _, return_player in pairs(game.connected_players) do
|
||||
if return_player.admin then
|
||||
return_player.print{'expcom-admin-chat.format',player_name_colour,message}
|
||||
return_player.print{'expcom-admin-chat.format', player_name_colour, message}
|
||||
end
|
||||
end
|
||||
return Commands.success -- prevents command complete message from showing
|
||||
|
||||
@@ -17,9 +17,9 @@ local bonus_store = Store.register(function(player)
|
||||
end)
|
||||
|
||||
-- Apply a bonus amount to a player
|
||||
local function apply_bonus(player,amount)
|
||||
local function apply_bonus(player, amount)
|
||||
if not amount then return end
|
||||
for bonus,min_max in pairs(config) do
|
||||
for bonus, min_max in pairs(config) do
|
||||
local increase = min_max[2]*amount
|
||||
player[bonus] = min_max[1]+increase
|
||||
end
|
||||
@@ -28,32 +28,32 @@ end
|
||||
--- Changes the amount of bonus you receive
|
||||
-- @command bonus
|
||||
-- @tparam number amount range 0-50 the percent increase for your bonus
|
||||
Commands.new_command('bonus','Changes the amount of bonus you receive')
|
||||
:add_param('amount','integer-range',0,50)
|
||||
:register(function(player,amount)
|
||||
Commands.new_command('bonus', 'Changes the amount of bonus you receive')
|
||||
:add_param('amount', 'integer-range', 0,50)
|
||||
:register(function(player, amount)
|
||||
local percent = amount/100
|
||||
Store.set(bonus_store,player,percent)
|
||||
Commands.print{'expcom-bonus.set',amount}
|
||||
Commands.print({'expcom-bonus.wip'},'orange')
|
||||
Store.set(bonus_store, player, percent)
|
||||
Commands.print{'expcom-bonus.set', amount}
|
||||
Commands.print({'expcom-bonus.wip'}, 'orange')
|
||||
end)
|
||||
|
||||
-- When store is updated apply new bonus to the player
|
||||
Store.watch(bonus_store,function(value,category)
|
||||
Store.watch(bonus_store, function(value, category)
|
||||
local player = Game.get_player_from_any(category)
|
||||
apply_bonus(player,value)
|
||||
apply_bonus(player, value)
|
||||
end)
|
||||
|
||||
-- When a player respawns re-apply bonus
|
||||
Event.add(defines.events.on_player_respawned,function(event)
|
||||
Event.add(defines.events.on_player_respawned, function(event)
|
||||
local player = Game.get_player_by_index(event.player_index)
|
||||
local value = Store.get(bonus_store,player)
|
||||
apply_bonus(player,value)
|
||||
local value = Store.get(bonus_store, player)
|
||||
apply_bonus(player, value)
|
||||
end)
|
||||
|
||||
-- When a player dies allow them to have instant respawn
|
||||
Event.add(defines.events.on_player_died,function(event)
|
||||
Event.add(defines.events.on_player_died, function(event)
|
||||
local player = Game.get_player_by_index(event.player_index)
|
||||
if Roles.player_has_flag(player,'instance-respawn') then
|
||||
if Roles.player_has_flag(player, 'instance-respawn') then
|
||||
player.ticks_to_respawn = 120
|
||||
end
|
||||
end)
|
||||
@@ -61,12 +61,12 @@ end)
|
||||
-- Remove bonus if a player no longer has access to the command
|
||||
local function role_update(event)
|
||||
local player = Game.get_player_by_index(event.player_index)
|
||||
if not Roles.player_allowed(player,'command/bonus') then
|
||||
Store.clear(bonus_store,player)
|
||||
if not Roles.player_allowed(player, 'command/bonus') then
|
||||
Store.clear(bonus_store, player)
|
||||
end
|
||||
end
|
||||
|
||||
Event.add(Roles.events.on_role_assigned,role_update)
|
||||
Event.add(Roles.events.on_role_unassigned,role_update)
|
||||
Event.add(Roles.events.on_role_assigned, role_update)
|
||||
Event.add(Roles.events.on_role_unassigned, role_update)
|
||||
|
||||
return bonus_store
|
||||
@@ -9,12 +9,12 @@ require 'config.expcore.command_general_parse'
|
||||
--- Toggles cheat mode for your player, or another player.
|
||||
-- @command toggle-cheat-mode
|
||||
-- @tparam[opt=self] LuaPlayer player player to toggle chest mode of, can be nil for self
|
||||
Commands.new_command('toggle-cheat-mode','Toggles cheat mode for your player, or another player.')
|
||||
:add_param('player',true,'player')
|
||||
Commands.new_command('toggle-cheat-mode', 'Toggles cheat mode for your player, or another player.')
|
||||
:add_param('player', true, 'player')
|
||||
:set_defaults{player=function(player)
|
||||
return player -- default is the user using the command
|
||||
end}
|
||||
:set_flag('admin_only')
|
||||
:register(function(player,action_player,raw)
|
||||
action_player.cheat_mode = not action_player.cheat_mode
|
||||
:register(function(_, player)
|
||||
player.cheat_mode = not player.cheat_mode
|
||||
end)
|
||||
@@ -10,11 +10,11 @@ require 'config.expcore.command_role_parse'
|
||||
--- Clears a players inventory
|
||||
-- @command clear-inventory
|
||||
-- @tparam LuaPlayer player the player to clear the inventory of
|
||||
Commands.new_command('clear-inventory','Clears a players inventory')
|
||||
:add_param('player',false,'player-role-alive')
|
||||
:add_alias('clear-inv','move-inventory','move-inv')
|
||||
:register(function(player,action_player)
|
||||
local inv = action_player.get_main_inventory()
|
||||
Commands.new_command('clear-inventory', 'Clears a players inventory')
|
||||
:add_param('player', false, 'player-role-alive')
|
||||
:add_alias('clear-inv', 'move-inventory', 'move-inv')
|
||||
:register(function(_, player)
|
||||
local inv = player.get_main_inventory()
|
||||
move_items(inv.get_contents())
|
||||
inv.clear()
|
||||
end)
|
||||
@@ -8,7 +8,7 @@ local Commands = require 'expcore.commands' --- @dep expcore.commands
|
||||
|
||||
--- Opens the debug pannel for viewing tables.
|
||||
-- @command debug
|
||||
Commands.new_command('debug','Opens the debug pannel for viewing tables.')
|
||||
Commands.new_command('debug', 'Opens the debug pannel for viewing tables.')
|
||||
:register(function(player)
|
||||
DebugView.open_dubug(player)
|
||||
end)
|
||||
@@ -9,11 +9,11 @@ require 'config.expcore.command_general_parse'
|
||||
--- Find a player on your map.
|
||||
-- @command find-on-map
|
||||
-- @tparam LuaPlayer the player to find on the map
|
||||
Commands.new_command('find-on-map','Find a player on your map.')
|
||||
:add_param('player',false,'player-online')
|
||||
:add_alias('find','zoom-to')
|
||||
:register(function(player,action_player,raw)
|
||||
Commands.new_command('find-on-map', 'Find a player on your map.')
|
||||
:add_param('player', false, 'player-online')
|
||||
:add_alias('find', 'zoom-to')
|
||||
:register(function(player, action_player)
|
||||
local position = action_player.position
|
||||
player.zoom_to_world(position,1.75)
|
||||
player.zoom_to_world(position, 1.75)
|
||||
return Commands.success -- prevents command complete message from showing
|
||||
end)
|
||||
@@ -10,7 +10,7 @@ require 'config.expcore.command_general_parse'
|
||||
local results_per_page = 5
|
||||
|
||||
local search_cache = {}
|
||||
Global.register(search_cache,function(tbl)
|
||||
Global.register(search_cache, function(tbl)
|
||||
search_cache = tbl
|
||||
end)
|
||||
|
||||
@@ -18,12 +18,12 @@ end)
|
||||
-- @command chelp
|
||||
-- @tparam string keyword the keyword that will be looked for
|
||||
-- @tparam number page the page of help to view, must be in range of pages
|
||||
Commands.new_command('search-help','Searches for a keyword in all commands you are allowed to use.')
|
||||
:add_alias('chelp','shelp','commands')
|
||||
:add_param('keyword',true)
|
||||
:add_param('page',true,'integer')
|
||||
:set_defaults{keyword='',page=1}
|
||||
:register(function(player,keyword,page,raw)
|
||||
Commands.new_command('search-help', 'Searches for a keyword in all commands you are allowed to use.')
|
||||
:add_alias('chelp', 'shelp', 'commands')
|
||||
:add_param('keyword', true)
|
||||
:add_param('page', true, 'integer')
|
||||
:set_defaults{keyword='', page=1}
|
||||
:register(function(player, keyword, page)
|
||||
local player_index = player and player.index or 0
|
||||
-- if keyword is a number then treat it as page number
|
||||
if tonumber(keyword) then
|
||||
@@ -40,20 +40,20 @@ Commands.new_command('search-help','Searches for a keyword in all commands you a
|
||||
pages = {{}}
|
||||
local current_page = 1
|
||||
local page_count = 0
|
||||
local commands = Commands.search(keyword,player)
|
||||
local commands = Commands.search(keyword, player)
|
||||
-- loops other all commands returned by search, includes game commands
|
||||
for _,command_data in pairs(commands) do
|
||||
for _, command_data in pairs(commands) do
|
||||
-- if the number of results if greater than the number already added then it moves onto a new page
|
||||
if page_count >= results_per_page then
|
||||
page_count = 0
|
||||
current_page = current_page + 1
|
||||
table.insert(pages,{})
|
||||
table.insert(pages, {})
|
||||
end
|
||||
-- adds the new command to the page
|
||||
page_count = page_count + 1
|
||||
found = found + 1
|
||||
local alias_format = #command_data.aliases > 0 and {'expcom-chelp.alias',table.concat(command_data.aliases,', ')} or ''
|
||||
table.insert(pages[current_page],{
|
||||
local alias_format = #command_data.aliases > 0 and {'expcom-chelp.alias', table.concat(command_data.aliases, ', ')} or ''
|
||||
table.insert(pages[current_page], {
|
||||
'expcom-chelp.format',
|
||||
command_data.name,
|
||||
command_data.description,
|
||||
@@ -70,15 +70,15 @@ Commands.new_command('search-help','Searches for a keyword in all commands you a
|
||||
end
|
||||
-- print the requested page
|
||||
keyword = keyword == '' and '<all>' or keyword
|
||||
Commands.print({'expcom-chelp.title',keyword},'cyan')
|
||||
Commands.print({'expcom-chelp.title', keyword}, 'cyan')
|
||||
if pages[page] then
|
||||
for _,command in pairs(pages[page]) do
|
||||
for _, command in pairs(pages[page]) do
|
||||
Commands.print(command)
|
||||
end
|
||||
Commands.print({'expcom-chelp.footer',found,page,#pages},'cyan')
|
||||
Commands.print({'expcom-chelp.footer', found, page, #pages}, 'cyan')
|
||||
else
|
||||
Commands.print({'expcom-chelp.footer',found,page,#pages},'cyan')
|
||||
return Commands.error{'expcom-chelp.out-of-range',page}
|
||||
Commands.print({'expcom-chelp.footer', found, page, #pages}, 'cyan')
|
||||
return Commands.error{'expcom-chelp.out-of-range', page}
|
||||
end
|
||||
-- blocks command complete message
|
||||
return Commands.success
|
||||
|
||||
@@ -8,16 +8,16 @@ local Global = require 'utils.global' --- @dep utils.global
|
||||
require 'config.expcore.command_general_parse'
|
||||
|
||||
local homes = {}
|
||||
Global.register(homes,function(tbl)
|
||||
Global.register(homes, function(tbl)
|
||||
homes = tbl
|
||||
end)
|
||||
|
||||
local function teleport(player,position)
|
||||
local function teleport(player, position)
|
||||
local surface = player.surface
|
||||
local pos = surface.find_non_colliding_position('character',position,32,1)
|
||||
local pos = surface.find_non_colliding_position('character', position, 32, 1)
|
||||
if not position then return false end
|
||||
if player.driving then player.driving = false end -- kicks a player out a vehicle if in one
|
||||
player.teleport(pos,surface)
|
||||
player.teleport(pos, surface)
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -30,22 +30,22 @@ end
|
||||
|
||||
--- Teleports you to your home location
|
||||
-- @command home
|
||||
Commands.new_command('home','Teleports you to your home location')
|
||||
:register(function(player,raw)
|
||||
Commands.new_command('home', 'Teleports you to your home location')
|
||||
:register(function(player)
|
||||
local home = homes[player.index]
|
||||
if not home or not home[1] then
|
||||
return Commands.error{'expcom-home.no-home'}
|
||||
end
|
||||
local rtn = floor_pos(player.position)
|
||||
teleport(player,home[1])
|
||||
teleport(player, home[1])
|
||||
home[2] = rtn
|
||||
Commands.print{'expcom-home.return-set',rtn.x,rtn.y}
|
||||
Commands.print{'expcom-home.return-set', rtn.x, rtn.y}
|
||||
end)
|
||||
|
||||
--- Sets your home location to your current position
|
||||
-- @command home-set
|
||||
Commands.new_command('home-set','Sets your home location to your current position')
|
||||
:register(function(player,raw)
|
||||
Commands.new_command('home-set', 'Sets your home location to your current position')
|
||||
:register(function(player)
|
||||
local home = homes[player.index]
|
||||
if not home then
|
||||
home = {}
|
||||
@@ -53,31 +53,31 @@ Commands.new_command('home-set','Sets your home location to your current positio
|
||||
end
|
||||
local pos = floor_pos(player.position)
|
||||
home[1] = pos
|
||||
Commands.print{'expcom-home.home-set',pos.x,pos.y}
|
||||
Commands.print{'expcom-home.home-set', pos.x, pos.y}
|
||||
end)
|
||||
|
||||
--- Returns your current home location
|
||||
-- @command home-get
|
||||
Commands.new_command('home-get','Returns your current home location')
|
||||
:register(function(player,raw)
|
||||
Commands.new_command('home-get', 'Returns your current home location')
|
||||
:register(function(player)
|
||||
local home = homes[player.index]
|
||||
if not home or not home[1] then
|
||||
return Commands.error{'expcom-home.no-home'}
|
||||
end
|
||||
local pos = home[1]
|
||||
Commands.print{'expcom-home.home-get',pos.x,pos.y}
|
||||
Commands.print{'expcom-home.home-get', pos.x, pos.y}
|
||||
end)
|
||||
|
||||
--- Teleports you to previous location
|
||||
-- @command return
|
||||
Commands.new_command('return','Teleports you to previous location')
|
||||
:register(function(player,raw)
|
||||
Commands.new_command('return', 'Teleports you to previous location')
|
||||
:register(function(player)
|
||||
local home = homes[player.index]
|
||||
if not home or not home[2] then
|
||||
return Commands.error{'expcom-home.no-return'}
|
||||
end
|
||||
local rtn = floor_pos(player.position)
|
||||
teleport(player,home[2])
|
||||
teleport(player, home[2])
|
||||
home[2] = rtn
|
||||
Commands.print{'expcom-home.return-set',rtn.x,rtn.y}
|
||||
Commands.print{'expcom-home.return-set', rtn.x, rtn.y}
|
||||
end)
|
||||
@@ -21,7 +21,7 @@ local interface_modules = {
|
||||
}
|
||||
|
||||
-- loads all the modules given in the above table
|
||||
for key,value in pairs(interface_modules) do
|
||||
for key, value in pairs(interface_modules) do
|
||||
if type(value) == 'string' then
|
||||
interface_modules[key] = Common.opt_require(value)
|
||||
end
|
||||
@@ -29,7 +29,7 @@ end
|
||||
|
||||
local interface_env = {} -- used as a persistent sandbox for interface commands
|
||||
local interface_callbacks = {} -- saves callbacks which can load new values per use
|
||||
Global.register(interface_env,function(tbl)
|
||||
Global.register(interface_env, function(tbl)
|
||||
interface_env = tbl
|
||||
end)
|
||||
|
||||
@@ -38,14 +38,14 @@ end)
|
||||
-- @tparam string name the name that the value is loaded under, cant use upvalues
|
||||
-- @tparam function callback the function that will run whent he command is used
|
||||
-- callback param - player: LuaPlayer - the player who used the command
|
||||
local function add_interface_callback(name,callback)
|
||||
local function add_interface_callback(name, callback)
|
||||
if type(callback) == 'function' then
|
||||
interface_callbacks[name] = callback
|
||||
end
|
||||
end
|
||||
|
||||
-- this is a meta function for __index when self[key] is nil
|
||||
local function get_index(self,key)
|
||||
local function get_index(_, key)
|
||||
if interface_env[key] then
|
||||
return interface_env[key]
|
||||
elseif interface_modules[key] then
|
||||
@@ -56,36 +56,36 @@ end
|
||||
--- Sends an innovation to be ran and returns the result.
|
||||
-- @command interface
|
||||
-- @tparam string innovation the command that will be run
|
||||
Commands.new_command('interface','Sends an innovation to be ran and returns the result.')
|
||||
:add_param('innovation',false)
|
||||
Commands.new_command('interface', 'Sends an innovation to be ran and returns the result.')
|
||||
:add_param('innovation', false)
|
||||
:enable_auto_concat()
|
||||
:set_flag('admin_only')
|
||||
:register(function(player,innovation,raw)
|
||||
:register(function(player, innovation)
|
||||
if not innovation:find('%s') and not innovation:find('return') then
|
||||
-- if there are no spaces and return is not present then return is appended to the start
|
||||
innovation='return '..innovation
|
||||
end
|
||||
-- temp_env will index to interface_env and interface_modules if value not found
|
||||
local temp_env = setmetatable({},{__index=get_index})
|
||||
local temp_env = setmetatable({}, {__index=get_index})
|
||||
if player then -- player can be nil when it is the server
|
||||
for name,callback in pairs(interface_callbacks) do
|
||||
for name, callback in pairs(interface_callbacks) do
|
||||
-- loops over callbacks and loads the values returned
|
||||
local success, rtn = pcall(callback,player)
|
||||
local _, rtn = pcall(callback, player)
|
||||
temp_env[name]=rtn
|
||||
end
|
||||
end
|
||||
-- sets the global metatable to prevent new values being made
|
||||
-- global will index to temp_env and new indexs saved to interface_sandbox
|
||||
-- global will index to temp_env and new indexes saved to interface_sandbox
|
||||
local old_mt = getmetatable(_G)
|
||||
setmetatable(_G,{__index=temp_env,__newindex=interface_env})
|
||||
setmetatable(_G, {__index=temp_env, __newindex=interface_env})
|
||||
-- runs the innovation and returns values to the player
|
||||
innovation = loadstring(innovation)
|
||||
local success, rtn = pcall(innovation)
|
||||
setmetatable(_G,old_mt)
|
||||
setmetatable(_G, old_mt)
|
||||
if not success then
|
||||
if type(rtn) == 'string' then
|
||||
-- there may be stack trace that must be removed to avoid desyncs
|
||||
rtn = rtn:gsub('%.%.%..-/temp/currently%-playing','')
|
||||
rtn = rtn:gsub('%.%.%..-/temp/currently%-playing', '')
|
||||
end
|
||||
return Commands.error(rtn)
|
||||
else
|
||||
@@ -94,16 +94,16 @@ Commands.new_command('interface','Sends an innovation to be ran and returns the
|
||||
end)
|
||||
|
||||
-- adds some basic callbacks for the interface
|
||||
add_interface_callback('player',function(player) return player end)
|
||||
add_interface_callback('surface',function(player) return player.surface end)
|
||||
add_interface_callback('force',function(player) return player.force end)
|
||||
add_interface_callback('position',function(player) return player.position end)
|
||||
add_interface_callback('entity',function(player) return player.selected end)
|
||||
add_interface_callback('tile',function(player) return player.surface.get_tile(player.position) end)
|
||||
add_interface_callback('player', function(player) return player end)
|
||||
add_interface_callback('surface', function(player) return player.surface end)
|
||||
add_interface_callback('force', function(player) return player.force end)
|
||||
add_interface_callback('position', function(player) return player.position end)
|
||||
add_interface_callback('entity', function(player) return player.selected end)
|
||||
add_interface_callback('tile', function(player) return player.surface.get_tile(player.position) end)
|
||||
|
||||
return {
|
||||
add_interface_callback=add_interface_callback,
|
||||
interface_env=interface_env,
|
||||
interface_callbacks=interface_callbacks,
|
||||
clean_stack_trace=function(str) return str:gsub('%.%.%..-/temp/currently%-playing','') end
|
||||
clean_stack_trace=function(str) return str:gsub('%.%.%..-/temp/currently%-playing', '') end
|
||||
}
|
||||
@@ -12,37 +12,37 @@ require 'config.expcore.command_role_parse'
|
||||
-- @command jail
|
||||
-- @tparam LuaPlayer player the player that will be jailed
|
||||
-- @tparam[opt] string reason the reason why the player is being jailed
|
||||
Commands.new_command('jail','Puts a player into jail and removes all other roles.')
|
||||
:add_param('player',false,'player-role')
|
||||
:add_param('reason',true)
|
||||
Commands.new_command('jail', 'Puts a player into jail and removes all other roles.')
|
||||
:add_param('player', false, 'player-role')
|
||||
:add_param('reason', true)
|
||||
:enable_auto_concat()
|
||||
:register(function(player,action_player,reason,raw)
|
||||
:register(function(player, action_player, reason)
|
||||
reason = reason or 'Non Given.'
|
||||
local action_player_name_color = format_chat_player_name(action_player)
|
||||
local by_player_name_color = format_chat_player_name(player)
|
||||
local player_name = player and player.name or '<server>'
|
||||
if Jail.jail_player(action_player, player_name, reason) then
|
||||
game.print{'expcom-jail.give',action_player_name_color,by_player_name_color,reason}
|
||||
game.print{'expcom-jail.give', action_player_name_color, by_player_name_color, reason}
|
||||
else
|
||||
return Commands.error{'expcom-jail.already-jailed',action_player_name_color}
|
||||
return Commands.error{'expcom-jail.already-jailed', action_player_name_color}
|
||||
end
|
||||
end)
|
||||
|
||||
--- Removes a player from jail.
|
||||
-- @command unjail
|
||||
-- @tparam LuaPlayer the player that will be unjailed
|
||||
Commands.new_command('unjail','Removes a player from jail.')
|
||||
:add_param('player',false,'player-role')
|
||||
:add_alias('clear-jail','remove-jail')
|
||||
Commands.new_command('unjail', 'Removes a player from jail.')
|
||||
:add_param('player', false, 'player-role')
|
||||
:add_alias('clear-jail', 'remove-jail')
|
||||
:enable_auto_concat()
|
||||
:register(function(player,action_player,raw)
|
||||
:register(function(player, action_player)
|
||||
local action_player_name_color = format_chat_player_name(action_player)
|
||||
local by_player_name_color = format_chat_player_name(player)
|
||||
local player_name = player and player.name or '<server>'
|
||||
if Jail.unjail_player(action_player, player_name) then
|
||||
game.print{'expcom-jail.remove',action_player_name_color,by_player_name_color}
|
||||
game.print{'expcom-jail.remove', action_player_name_color, by_player_name_color}
|
||||
else
|
||||
return Commands.error{'expcom-jail.not-jailed',action_player_name_color}
|
||||
return Commands.error{'expcom-jail.not-jailed', action_player_name_color}
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -50,33 +50,33 @@ end)
|
||||
-- @command temp-ban
|
||||
-- @tparam LuaPlayer player the player that will be temp banned
|
||||
-- @tparam string reason the reason that the player is being temp banned
|
||||
Commands.new_command('temp-ban','Temp bans a player until the next reset; this requires a reason; this will clear the players inventory.')
|
||||
:add_param('player',false,'player-role')
|
||||
:add_param('reason',false)
|
||||
Commands.new_command('temp-ban', 'Temp bans a player until the next reset; this requires a reason; this will clear the players inventory.')
|
||||
:add_param('player', false, 'player-role')
|
||||
:add_param('reason', false)
|
||||
:enable_auto_concat()
|
||||
:register(function(player,action_player,reason,raw)
|
||||
:register(function(player, action_player, reason)
|
||||
local action_player_name_color = format_chat_player_name(action_player)
|
||||
local by_player_name_color = format_chat_player_name(player)
|
||||
if Jail.temp_ban_player(action_player,player.name,reason) then
|
||||
game.print{'expcom-jail.temp-ban',action_player_name_color,by_player_name_color,reason}
|
||||
if Jail.temp_ban_player(action_player, player.name, reason) then
|
||||
game.print{'expcom-jail.temp-ban', action_player_name_color, by_player_name_color, reason}
|
||||
else
|
||||
return Commands.error{'expcom-jail.already-banned',action_player_name_color}
|
||||
return Commands.error{'expcom-jail.already-banned', action_player_name_color}
|
||||
end
|
||||
end)
|
||||
|
||||
--- Removes temp ban from a player; this will not restore their items.
|
||||
-- @command clear-temp-ban
|
||||
-- @tparam LuaPlayer player the player to revoke the temp ban from
|
||||
Commands.new_command('clear-temp-ban','Removes temp ban from a player; this will not restore their items.')
|
||||
:add_param('player',false,'player-role')
|
||||
:add_alias('untemp-ban','remove-temp-ban')
|
||||
Commands.new_command('clear-temp-ban', 'Removes temp ban from a player; this will not restore their items.')
|
||||
:add_param('player', false, 'player-role')
|
||||
:add_alias('untemp-ban', 'remove-temp-ban')
|
||||
:enable_auto_concat()
|
||||
:register(function(player,action_player,raw)
|
||||
:register(function(player, action_player)
|
||||
local action_player_name_color = format_chat_player_name(action_player)
|
||||
local by_player_name_color = format_chat_player_name(player)
|
||||
if Jail.untemp_ban_player(action_player,player.name) then
|
||||
game.print{'expcom-jail.temp-ban-clear',action_player_name_color,by_player_name_color}
|
||||
if Jail.untemp_ban_player(action_player, player.name) then
|
||||
game.print{'expcom-jail.temp-ban-clear', action_player_name_color, by_player_name_color}
|
||||
else
|
||||
return Commands.error{'expcom-jail.not-temp-banned',action_player_name_color}
|
||||
return Commands.error{'expcom-jail.not-temp-banned', action_player_name_color}
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -11,22 +11,22 @@ require 'config.expcore.command_role_parse'
|
||||
--- Kills yourself or another player.
|
||||
-- @command kill
|
||||
-- @tparam[opt=self] LuaPlayer player the player to kill, must be alive to be valid
|
||||
Commands.new_command('kill','Kills yourself or another player.')
|
||||
:add_param('player',true,'player-role-alive')
|
||||
Commands.new_command('kill', 'Kills yourself or another player.')
|
||||
:add_param('player', true, 'player-role-alive')
|
||||
:set_defaults{player=function(player)
|
||||
-- default is the player unless they are dead
|
||||
if player.character and player.character.health > 0 then
|
||||
return player
|
||||
end
|
||||
end}
|
||||
:register(function(player,action_player,raw)
|
||||
:register(function(player, action_player)
|
||||
if not action_player then
|
||||
-- can only be nil if no player given and the user is dead
|
||||
return Commands.error{'expcom-kill.already-dead'}
|
||||
end
|
||||
if player == action_player then
|
||||
action_player.character.die()
|
||||
elseif Roles.player_allowed(player,'command/kill/always') then
|
||||
elseif Roles.player_allowed(player, 'command/kill/always') then
|
||||
action_player.character.die()
|
||||
else
|
||||
return Commands.error{'expcore-commands.unauthorized'}
|
||||
|
||||
@@ -8,10 +8,10 @@ local Commands = require 'expcore.commands' --- @dep expcore.commands
|
||||
--- Sends an action message in the chat
|
||||
-- @command me
|
||||
-- @tparam string action the action that follows your name in chat
|
||||
Commands.new_command('me','Sends an action message in the chat')
|
||||
:add_param('action',false)
|
||||
Commands.new_command('me', 'Sends an action message in the chat')
|
||||
:add_param('action', false)
|
||||
:enable_auto_concat()
|
||||
:register(function(player,action,raw)
|
||||
:register(function(player, action)
|
||||
local player_name = player and player.name or '<Server>'
|
||||
game.print(string.format('* %s %s *',player_name,action),player.chat_color)
|
||||
game.print(string.format('* %s %s *', player_name, action), player.chat_color)
|
||||
end)
|
||||
@@ -4,14 +4,11 @@
|
||||
]]
|
||||
|
||||
local Commands = require 'expcore.commands' --- @dep expcore.commands
|
||||
local Roles = require 'expcore.roles' --- @dep expcore.roles
|
||||
local Game = require 'utils.game' --- @dep utils.game
|
||||
local config = require 'config.preset_player_quickbar' --- @dep config.preset_player_quickbar
|
||||
|
||||
|
||||
--- Loads your quickbar preset
|
||||
-- @command load-quickbar
|
||||
Commands.new_command('load-quickbar','Loads your preset Quickbar items')
|
||||
Commands.new_command('load-quickbar', 'Loads your preset Quickbar items')
|
||||
:add_alias('load-toolbar')
|
||||
:register(function(player)
|
||||
if config[player.name] then
|
||||
@@ -28,7 +25,7 @@ end)
|
||||
|
||||
--- Saves your quickbar preset to the script-output folder
|
||||
-- @command save-quickbar
|
||||
Commands.new_command('save-quickbar','Saves your Quickbar preset items to file')
|
||||
Commands.new_command('save-quickbar', 'Saves your Quickbar preset items to file')
|
||||
:add_alias('save-toolbar')
|
||||
:register(function(player)
|
||||
local quickbar_names = {}
|
||||
|
||||
@@ -6,27 +6,27 @@
|
||||
local Commands = require 'expcore.commands' --- @dep expcore.commands
|
||||
local format_chat_colour = _C.format_chat_colour --- @dep expcore.common
|
||||
|
||||
local function step_component(c1,c2)
|
||||
local function step_component(c1, c2)
|
||||
if c1 < 0 then
|
||||
return 0,c2+c1
|
||||
return 0, c2+c1
|
||||
elseif c1 > 1 then
|
||||
return 1,c2-c1+1
|
||||
return 1, c2-c1+1
|
||||
else
|
||||
return c1,c2
|
||||
return c1, c2
|
||||
end
|
||||
end
|
||||
|
||||
local function step_color(color)
|
||||
color.r,color.g = step_component(color.r,color.g)
|
||||
color.g,color.b = step_component(color.g,color.b)
|
||||
color.b,color.r = step_component(color.b,color.r)
|
||||
color.r = step_component(color.r,0)
|
||||
color.r, color.g = step_component(color.r, color.g)
|
||||
color.g, color.b = step_component(color.g, color.b)
|
||||
color.b, color.r = step_component(color.b, color.r)
|
||||
color.r = step_component(color.r, 0)
|
||||
return color
|
||||
end
|
||||
|
||||
local function next_color(color,step)
|
||||
local function next_color(color, step)
|
||||
step = step or 0.1
|
||||
local new_color = {r=0,g=0,b=0}
|
||||
local new_color = {r=0, g=0, b=0}
|
||||
if color.b == 0 and color.r ~= 0 then
|
||||
new_color.r = color.r-step
|
||||
new_color.g = color.g+step
|
||||
@@ -43,19 +43,19 @@ end
|
||||
--- Sends an rainbow message in the chat
|
||||
-- @command rainbow
|
||||
-- @tparam string message the message that will be printed in chat
|
||||
Commands.new_command('rainbow','Sends an rainbow message in the chat')
|
||||
:add_param('message',false)
|
||||
Commands.new_command('rainbow', 'Sends an rainbow message in the chat')
|
||||
:add_param('message', false)
|
||||
:enable_auto_concat()
|
||||
:register(function(player,message,raw)
|
||||
:register(function(player, message)
|
||||
local player_name = player and player.name or '<Server>'
|
||||
local player_color = player and player.color or nil
|
||||
local color_step = 3/message:len()
|
||||
if color_step > 1 then color_step = 1 end
|
||||
local current_color = {r=1,g=0,b=0}
|
||||
local output = format_chat_colour(player_name..': ',player_color)
|
||||
output = output..message:gsub('%S',function(letter)
|
||||
local rtn = format_chat_colour(letter,current_color)
|
||||
current_color = next_color(current_color,color_step)
|
||||
local current_color = {r=1, g=0, b=0}
|
||||
local output = format_chat_colour(player_name..': ', player_color)
|
||||
output = output..message:gsub('%S', function(letter)
|
||||
local rtn = format_chat_colour(letter, current_color)
|
||||
current_color = next_color(current_color, color_step)
|
||||
return rtn
|
||||
end)
|
||||
game.print(output)
|
||||
|
||||
@@ -2,33 +2,46 @@
|
||||
|
||||
local Commands = require 'expcore.commands'
|
||||
|
||||
local function Modules(moduleInventory) -- returns the multiplier of the modules
|
||||
local effect1 = moduleInventory.get_item_count("productivity-module") -- type 1
|
||||
local effect2 = moduleInventory.get_item_count("productivity-module-2")-- type 2
|
||||
local effect3 = moduleInventory.get_item_count("productivity-module-3") -- type 3
|
||||
|
||||
Commands.new_command('ratio','This command will give the input and ouput ratios of the selected machine. Use the parameter for calcualting the machines needed for that amount of items per second.')
|
||||
:add_param('itemsPerSecond',true,'number')
|
||||
:register(function(player,itemsPerSecond,raw)
|
||||
|
||||
local multi = effect1*4+effect2*6+effect3*10
|
||||
return multi/100+1
|
||||
end
|
||||
|
||||
local function AmountOfMachines(itemsPerSecond, output)
|
||||
if(itemsPerSecond) then
|
||||
return itemsPerSecond/output
|
||||
end
|
||||
end
|
||||
|
||||
Commands.new_command('ratio', 'This command will give the input and output ratios of the selected machine. Use the parameter for calculating the machines needed for that amount of items per second.')
|
||||
:add_param('itemsPerSecond', true, 'number')
|
||||
:register(function(player, itemsPerSecond)
|
||||
local machine = player.selected -- selected machine
|
||||
if not machine then --nil check
|
||||
return Commands.error{'expcom-ratio.notSelecting'}
|
||||
end
|
||||
|
||||
|
||||
if machine.type ~= "assembling-machine" and machine.type ~= "furnace" then
|
||||
return Commands.error{'expcom-ratio.notSelecting'}
|
||||
end
|
||||
local recpie = machine.get_recipe() -- recpie
|
||||
local recipe = machine.get_recipe() -- recipe
|
||||
|
||||
if not recpie then --nil check
|
||||
if not recipe then --nil check
|
||||
return Commands.error{'expcom-ratio.notSelecting'}
|
||||
end
|
||||
|
||||
local items = recpie.ingredients -- items in that recpie
|
||||
local product = recpie.products -- output items
|
||||
local items = recipe.ingredients -- items in that recipe
|
||||
local products = recipe.products -- output items
|
||||
local amountOfMachines
|
||||
local moduleInvetory = machine.get_module_inventory()--the module Invetory of the machine
|
||||
local mult = Modules(moduleInvetory) --function for the productivety moduals
|
||||
local moduleInventory = machine.get_module_inventory()--the module Inventory of the machine
|
||||
local multi = Modules(moduleInventory) --function for the productively modals
|
||||
|
||||
if itemsPerSecond then
|
||||
amountOfMachines = math.ceil( AmountOfMachines(itemsPerSecond,1/recpie.energy*machine.crafting_speed*product[1].amount*mult)) -- amount of machines
|
||||
amountOfMachines = math.ceil( AmountOfMachines(itemsPerSecond, 1/recipe.energy*machine.crafting_speed*products[1].amount*multi)) -- amount of machines
|
||||
end
|
||||
if not amountOfMachines then
|
||||
amountOfMachines = 1 --set to 1 to make it not nil
|
||||
@@ -42,14 +55,13 @@ Commands.new_command('ratio','This command will give the input and ouput ratios
|
||||
else
|
||||
sprite = 'expcom-ratio.fluid-in'
|
||||
end
|
||||
|
||||
|
||||
local ips = item.amount/recpie.energy*machine.crafting_speed*amountOfMachines --math on the items/fluids per second
|
||||
Commands.print {sprite,math.round(ips,3),item.name}-- full string
|
||||
|
||||
local ips = item.amount/recipe.energy*machine.crafting_speed*amountOfMachines --math on the items/fluids per second
|
||||
Commands.print {sprite, math.round(ips, 3), item.name}-- full string
|
||||
end
|
||||
----------------------------products----------------------------
|
||||
|
||||
for i, product in ipairs(product) do
|
||||
|
||||
for i, product in ipairs(products) do
|
||||
local sprite -- string to make the icon work either fluid ore item
|
||||
|
||||
if product.type == "item" then
|
||||
@@ -58,28 +70,13 @@ Commands.new_command('ratio','This command will give the input and ouput ratios
|
||||
sprite = 'expcom-ratio.fluid-out'
|
||||
end
|
||||
|
||||
local output = 1/recpie.energy*machine.crafting_speed*product.amount*mult --math on the outputs per second
|
||||
Commands.print {sprite,math.round(output*amountOfMachines,3),product.name} -- full string
|
||||
local output = 1/recipe.energy*machine.crafting_speed*product.amount*multi --math on the outputs per second
|
||||
Commands.print {sprite, math.round(output*amountOfMachines, 3), product.name} -- full string
|
||||
|
||||
end
|
||||
|
||||
if amountOfMachines ~= 1 then
|
||||
Commands.print{'expcom-ratio.machines',amountOfMachines}
|
||||
Commands.print{'expcom-ratio.machines', amountOfMachines}
|
||||
end
|
||||
|
||||
end)
|
||||
function Modules(moduleInvetory) -- returns the multeplier of the modules
|
||||
local effect1 = moduleInvetory.get_item_count("productivity-module") -- type 1
|
||||
local effect2 = moduleInvetory.get_item_count("productivity-module-2")-- type 2
|
||||
local effect3 = moduleInvetory.get_item_count("productivity-module-3") -- type 3
|
||||
|
||||
local mult = effect1*4+effect2*6+effect3*10
|
||||
return mult/100+1
|
||||
end
|
||||
|
||||
function AmountOfMachines(itemsPerSecond,output)
|
||||
if(itemsPerSecond) then
|
||||
return itemsPerSecond/output
|
||||
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -11,18 +11,18 @@ local max_time_to_live = 4294967295 -- unit32 max
|
||||
--- Repairs entities on your force around you
|
||||
-- @command repair
|
||||
-- @tparam number range the range to repair stuff in, there is a max limit to this
|
||||
Commands.new_command('repair','Repairs entities on your force around you')
|
||||
:add_param('range',false,'integer-range',1,config.max_range)
|
||||
:register(function(player,range,raw)
|
||||
Commands.new_command('repair', 'Repairs entities on your force around you')
|
||||
:add_param('range', false, 'integer-range', 1,config.max_range)
|
||||
:register(function(player, range)
|
||||
local revive_count = 0
|
||||
local heal_count = 0
|
||||
local range2 = range^2
|
||||
local surface = player.surface
|
||||
local center = player.position
|
||||
local area = {{x=center.x-range,y=center.y-range},{x=center.x+range,y=center.y+range}}
|
||||
local area = {{x=center.x-range, y=center.y-range}, {x=center.x+range, y=center.y+range}}
|
||||
if config.allow_ghost_revive then
|
||||
local ghosts = surface.find_entities_filtered({area=area,type='entity-ghost',force=player.force})
|
||||
for _,ghost in pairs(ghosts) do
|
||||
local ghosts = surface.find_entities_filtered({area=area, type='entity-ghost', force=player.force})
|
||||
for _, ghost in pairs(ghosts) do
|
||||
if ghost.valid then
|
||||
local x = ghost.position.x-center.x
|
||||
local y = ghost.position.y-center.y
|
||||
@@ -36,8 +36,8 @@ Commands.new_command('repair','Repairs entities on your force around you')
|
||||
end
|
||||
end
|
||||
if config.allow_heal_entities then
|
||||
local entities = surface.find_entities_filtered({area=area,force=player.force})
|
||||
for _,entity in pairs(entities) do
|
||||
local entities = surface.find_entities_filtered({area=area, force=player.force})
|
||||
for _, entity in pairs(entities) do
|
||||
if entity.valid then
|
||||
local x = entity.position.x-center.x
|
||||
local y = entity.position.y-center.y
|
||||
@@ -48,5 +48,5 @@ Commands.new_command('repair','Repairs entities on your force around you')
|
||||
end
|
||||
end
|
||||
end
|
||||
return Commands.success{'expcom-repair.result',revive_count,heal_count}
|
||||
return Commands.success{'expcom-repair.result', revive_count, heal_count}
|
||||
end)
|
||||
@@ -13,25 +13,25 @@ require 'config.expcore.command_general_parse'
|
||||
-- @command report
|
||||
-- @tparam LuaPlayer player the player to report, some players are immune
|
||||
-- @tparam string reason the reason the player is being reported
|
||||
Commands.new_command('report','Reports a player and notifies moderators')
|
||||
:add_param('player',false,function(input,player,reject)
|
||||
input = Commands.parse('player',input,player,reject)
|
||||
Commands.new_command('report', 'Reports a player and notifies moderators')
|
||||
:add_param('player', false, function(input, player, reject)
|
||||
input = Commands.parse('player', input, player, reject)
|
||||
if not input then return end
|
||||
if Roles.player_has_flag(input,'report-immune') then
|
||||
if Roles.player_has_flag(input, 'report-immune') then
|
||||
return reject{'expcom-report.player-immune'}
|
||||
else
|
||||
return input
|
||||
end
|
||||
end)
|
||||
:add_param('reason',false)
|
||||
:add_param('reason', false)
|
||||
:add_alias('report-player')
|
||||
:enable_auto_concat()
|
||||
:register(function(player,action_player,reason,raw)
|
||||
:register(function(player, action_player, reason)
|
||||
local action_player_name_color = format_chat_player_name(action_player)
|
||||
local by_player_name_color = format_chat_player_name(player)
|
||||
if Reports.report_player(action_player,player.name,reason) then
|
||||
game.print{'expcom-report.non-admin',action_player_name_color,reason}
|
||||
Roles.print_to_roles_higher('Trainee',{'expcom-report.admin',action_player_name_color,by_player_name_color,reason})
|
||||
if Reports.report_player(action_player, player.name, reason) then
|
||||
game.print{'expcom-report.non-admin', action_player_name_color, reason}
|
||||
Roles.print_to_roles_higher('Trainee', {'expcom-report.admin', action_player_name_color, by_player_name_color, reason})
|
||||
else
|
||||
return Commands.error{'expcom-report.already-reported'}
|
||||
end
|
||||
@@ -40,25 +40,25 @@ end)
|
||||
--- Gets a list of all reports that a player has on them. If no player then lists all players and the number of reports on them.
|
||||
-- @command get-reports
|
||||
-- @tparam LuaPlayer player the player to get the report for
|
||||
Commands.new_command('get-reports','Gets a list of all reports that a player has on them. If no player then lists all players and the number of reports on them.')
|
||||
:add_param('player',true,'player')
|
||||
:add_alias('reports','list-reports')
|
||||
:register(function(player,action_player,raw)
|
||||
if action_player then
|
||||
local reports = Reports.get_reports(action_player)
|
||||
local action_player_name_color = format_chat_player_name(action_player)
|
||||
Commands.print{'expcom-report.player-report-title',action_player_name_color}
|
||||
for player_name,reason in pairs(reports) do
|
||||
Commands.new_command('get-reports', 'Gets a list of all reports that a player has on them. If no player then lists all players and the number of reports on them.')
|
||||
:add_param('player', true, 'player')
|
||||
:add_alias('reports', 'list-reports')
|
||||
:register(function(_, player)
|
||||
if player then
|
||||
local reports = Reports.get_reports(player)
|
||||
local player_name_color = format_chat_player_name(player)
|
||||
Commands.print{'expcom-report.player-report-title', player_name_color}
|
||||
for player_name, reason in pairs(reports) do
|
||||
local by_player_name_color = format_chat_player_name(player_name)
|
||||
Commands.print{'expcom-report.list',by_player_name_color,reason}
|
||||
Commands.print{'expcom-report.list', by_player_name_color, reason}
|
||||
end
|
||||
else
|
||||
local user_reports = Reports.user_reports
|
||||
Commands.print{'expcom-report.player-count-title'}
|
||||
for player_name,reports in pairs(user_reports) do
|
||||
for player_name in pairs(user_reports) do
|
||||
local player_name_color = format_chat_player_name(player_name)
|
||||
local report_count = Reports.count_reports(player_name)
|
||||
Commands.print{'expcom-report.list',player_name_color,report_count}
|
||||
Commands.print{'expcom-report.list', player_name_color, report_count}
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -67,20 +67,20 @@ end)
|
||||
-- @command clear-reports
|
||||
-- @tparam LuaPlayer player the player to clear the report(s) from
|
||||
-- @tparam[opt=all] LuaPlayer from-player remove only the report made by this player
|
||||
Commands.new_command('clear-reports','Clears all reports from a player or just the report from one player.')
|
||||
:add_param('player',false,'player')
|
||||
:add_param('from-player',true,'player')
|
||||
:register(function(player,action_player,from_player,raw)
|
||||
Commands.new_command('clear-reports', 'Clears all reports from a player or just the report from one player.')
|
||||
:add_param('player', false, 'player')
|
||||
:add_param('from-player', true, 'player')
|
||||
:register(function(player, action_player, from_player)
|
||||
if from_player then
|
||||
if not Reports.remove_report(action_player,from_player.name,player.name) then
|
||||
if not Reports.remove_report(action_player, from_player.name, player.name) then
|
||||
return Commands.error{'expcom-report.not-reported'}
|
||||
end
|
||||
else
|
||||
if not Reports.remove_all(action_player,player.name) then
|
||||
if not Reports.remove_all(action_player, player.name) then
|
||||
return Commands.error{'expcom-report.not-reported'}
|
||||
end
|
||||
end
|
||||
local action_player_name_color = format_chat_player_name(action_player)
|
||||
local by_player_name_color = format_chat_player_name(player)
|
||||
game.print{'expcom-report.removed',action_player_name_color,by_player_name_color}
|
||||
game.print{'expcom-report.removed', action_player_name_color, by_player_name_color}
|
||||
end)
|
||||
@@ -12,15 +12,15 @@ local format_chat_player_name, format_chat_colour_localized = _C.format_chat_pla
|
||||
-- @command assign-role
|
||||
-- @tparam LuaPlayer player the player to assign the role to
|
||||
-- @tparam string role the name of the role to assign to the player, supports auto complete after enter
|
||||
Commands.new_command('assign-role','Assigns a role to a player')
|
||||
:add_param('player',false,'player-role')
|
||||
:add_param('role',false,'role')
|
||||
Commands.new_command('assign-role', 'Assigns a role to a player')
|
||||
:add_param('player', false, 'player-role')
|
||||
:add_param('role', false, 'role')
|
||||
:set_flag('admin-only')
|
||||
:add_alias('rpromote','assign','role','add-role')
|
||||
:register(function(player,action_player,role,raw)
|
||||
:add_alias('rpromote', 'assign', 'role', 'add-role')
|
||||
:register(function(player, action_player, role)
|
||||
local player_highest = Roles.get_player_highest_role(player)
|
||||
if player_highest.index < role.index then
|
||||
Roles.assign_player(action_player,role,player.name)
|
||||
Roles.assign_player(action_player, role, player.name)
|
||||
else
|
||||
return Commands.error{'expcom-roles.higher-role'}
|
||||
end
|
||||
@@ -30,15 +30,15 @@ end)
|
||||
-- @command unassign-role
|
||||
-- @tparam LuaPlayer player the player to unassign the role from
|
||||
-- @tparam string role the name of the role to unassign from the player, supports auto complete after enter
|
||||
Commands.new_command('unassign-role','Unassigns a role from a player')
|
||||
:add_param('player',false,'player-role')
|
||||
:add_param('role',false,'role')
|
||||
Commands.new_command('unassign-role', 'Unassigns a role from a player')
|
||||
:add_param('player', false, 'player-role')
|
||||
:add_param('role', false, 'role')
|
||||
:set_flag('admin-only')
|
||||
:add_alias('rdemote','unassign','rerole','remove-role')
|
||||
:register(function(player,action_player,role,raw)
|
||||
:add_alias('rdemote', 'unassign', 'rerole', 'remove-role')
|
||||
:register(function(player, action_player, role)
|
||||
local player_highest = Roles.get_player_highest_role(player)
|
||||
if player_highest.index < role.index then
|
||||
Roles.unassign_player(action_player,role,player.name)
|
||||
Roles.unassign_player(action_player, role, player.name)
|
||||
else
|
||||
return Commands.error{'expcom-roles.higher-role'}
|
||||
end
|
||||
@@ -47,27 +47,27 @@ end)
|
||||
--- Lists all roles in they correct order
|
||||
-- @command list-roles
|
||||
-- @tparam[opt=all] LuaPlayer player list only the roles which this player has
|
||||
Commands.new_command('list-roles','Lists all roles in they correct order')
|
||||
:add_param('player',true,'player')
|
||||
:add_alias('lsroles','roles')
|
||||
:register(function(player,action_player,raw)
|
||||
Commands.new_command('list-roles', 'Lists all roles in they correct order')
|
||||
:add_param('player', true, 'player')
|
||||
:add_alias('lsroles', 'roles')
|
||||
:register(function(_, player)
|
||||
local roles = Roles.config.order
|
||||
local message = {'expcom-roles.list'}
|
||||
if action_player then
|
||||
roles = Roles.get_player_roles(action_player)
|
||||
if player then
|
||||
roles = Roles.get_player_roles(player)
|
||||
end
|
||||
for index,role in pairs(roles) do
|
||||
for index, role in pairs(roles) do
|
||||
role = Roles.get_role_from_any(role)
|
||||
local colour = role.custom_color or Colours.white
|
||||
local role_name = format_chat_colour_localized(role.name,colour)
|
||||
local role_name = format_chat_colour_localized(role.name, colour)
|
||||
if index == 1 then
|
||||
message = {'expcom-roles.list',role_name}
|
||||
if action_player then
|
||||
local player_name_colour = format_chat_player_name(action_player)
|
||||
message = {'expcom-roles.list-player',player_name_colour,role_name}
|
||||
message = {'expcom-roles.list', role_name}
|
||||
if player then
|
||||
local player_name_colour = format_chat_player_name(player)
|
||||
message = {'expcom-roles.list-player', player_name_colour, role_name}
|
||||
end
|
||||
else
|
||||
message = {'expcom-roles.list-element',message,role_name}
|
||||
message = {'expcom-roles.list-element', message, role_name}
|
||||
end
|
||||
end
|
||||
return Commands.success(message)
|
||||
|
||||
@@ -9,18 +9,18 @@ local Roles = require 'expcore.roles' --- @dep expcore.roles
|
||||
local function teleport(player)
|
||||
local surface = player.surface
|
||||
local spawn = player.force.get_spawn_position(surface)
|
||||
local position = surface.find_non_colliding_position('character',spawn,32,1)
|
||||
local position = surface.find_non_colliding_position('character', spawn, 32, 1)
|
||||
if not position then return false end
|
||||
if player.driving then player.driving = false end -- kicks a player out a vehicle if in one
|
||||
player.teleport(position,surface)
|
||||
player.teleport(position, surface)
|
||||
return true
|
||||
end
|
||||
|
||||
--- Teleport to spawn
|
||||
-- @command go-to-spawn
|
||||
-- @tparam[opt=self] LuaPlayer player the player to teleport to their spawn point
|
||||
Commands.new_command('go-to-spawn','Teleport to spawn')
|
||||
:add_param('player',true,'player-role-alive')
|
||||
Commands.new_command('go-to-spawn', 'Teleport to spawn')
|
||||
:add_param('player', true, 'player-role-alive')
|
||||
:set_defaults{
|
||||
player=function(player)
|
||||
if player.connected and player.character and player.character.health > 0 then
|
||||
@@ -28,15 +28,15 @@ Commands.new_command('go-to-spawn','Teleport to spawn')
|
||||
end
|
||||
end
|
||||
}
|
||||
:add_alias('spawn','tp-spawn')
|
||||
:register(function(player,action_player)
|
||||
if not action_player then
|
||||
:add_alias('spawn', 'tp-spawn')
|
||||
:register(function(player, action_player)
|
||||
if not action_player then
|
||||
return Commands.error{'expcom-spawn.unavailable'}
|
||||
elseif action_player == player then
|
||||
if not teleport(player) then
|
||||
return Commands.error{'expcom-spawn.unavailable'}
|
||||
end
|
||||
elseif Roles.player_allowed(player,'command/go-to-spawn/always') then
|
||||
elseif Roles.player_allowed(player, 'command/go-to-spawn/always') then
|
||||
if not teleport(action_player) then
|
||||
return Commands.error{'expcom-spawn.unavailable'}
|
||||
end
|
||||
|
||||
@@ -11,26 +11,26 @@ require 'config.expcore.command_role_parse'
|
||||
--- Sets your player tag.
|
||||
-- @command tag
|
||||
-- @tparam string tag the tag that will be after the name, there is a max length
|
||||
Commands.new_command('tag','Sets your player tag.')
|
||||
:add_param('tag',false,'string-max-length',20)
|
||||
Commands.new_command('tag', 'Sets your player tag.')
|
||||
:add_param('tag', false, 'string-max-length', 20)
|
||||
:enable_auto_concat()
|
||||
:register(function(player,tag,raw)
|
||||
:register(function(player, tag)
|
||||
player.tag = '- '..tag
|
||||
end)
|
||||
|
||||
--- Clears your tag. Or another player if you are admin.
|
||||
-- @command tag-clear
|
||||
-- @tparam[opt=self] LuaPlayer player the player to remove the tag from, nil will apply to self
|
||||
Commands.new_command('tag-clear','Clears your tag. Or another player if you are admin.')
|
||||
:add_param('player',true,'player-role')
|
||||
Commands.new_command('tag-clear', 'Clears your tag. Or another player if you are admin.')
|
||||
:add_param('player', true, 'player-role')
|
||||
:set_defaults{player=function(player)
|
||||
return player -- default is the user using the command
|
||||
end}
|
||||
:register(function(player,action_player,raw)
|
||||
:register(function(player, action_player)
|
||||
if action_player.index == player.index then
|
||||
-- no player given so removes your tag
|
||||
action_player.tag = ''
|
||||
elseif Roles.player_allowed(player,'command/clear-tag/always') then
|
||||
elseif Roles.player_allowed(player, 'command/clear-tag/always') then
|
||||
-- player given and user is admin so clears that player's tag
|
||||
action_player.tag = ''
|
||||
else
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
local Commands = require 'expcore.commands' --- @dep expcore.commands
|
||||
require 'config.expcore.command_general_parse'
|
||||
|
||||
local function teleport(from_player,to_player)
|
||||
local function teleport(from_player, to_player)
|
||||
local surface = to_player.surface
|
||||
local position = surface.find_non_colliding_position('character',to_player.position,32,1)
|
||||
local position = surface.find_non_colliding_position('character', to_player.position, 32, 1)
|
||||
if not position then return false end -- return false if no new position
|
||||
if from_player.driving then from_player.driving = false end -- kicks a player out a vehicle if in one
|
||||
from_player.teleport(position,surface)
|
||||
from_player.teleport(position, surface)
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -19,17 +19,17 @@ end
|
||||
-- @command teleport
|
||||
-- @tparam LuaPlayer from_player the player that will be teleported, must be alive
|
||||
-- @tparam LuaPlayer to_player the player to teleport to, must be online (if dead goes to where they died)
|
||||
Commands.new_command('teleport','Teleports a player to another player.')
|
||||
:add_param('from_player',false,'player-alive')
|
||||
:add_param('to_player',false,'player-online')
|
||||
Commands.new_command('teleport', 'Teleports a player to another player.')
|
||||
:add_param('from_player', false, 'player-alive')
|
||||
:add_param('to_player', false, 'player-online')
|
||||
:add_alias('tp')
|
||||
:set_flag('admin_only')
|
||||
:register(function(player,from_player,to_player,raw)
|
||||
:register(function(_, from_player, to_player)
|
||||
if from_player.index == to_player.index then
|
||||
-- return if attempting to teleport to self
|
||||
return Commands.error{'expcom-tp.to-self'}
|
||||
end
|
||||
if not teleport(from_player,to_player) then
|
||||
if not teleport(from_player, to_player) then
|
||||
-- return if the teleport failed
|
||||
return Commands.error{'expcom-tp.no-position-found'}
|
||||
end
|
||||
@@ -38,15 +38,15 @@ end)
|
||||
--- Teleports a player to you.
|
||||
-- @command bring
|
||||
-- @tparam LuaPlayer player the player that will be teleported, must be alive
|
||||
Commands.new_command('bring','Teleports a player to you.')
|
||||
:add_param('player',false,'player-alive')
|
||||
Commands.new_command('bring', 'Teleports a player to you.')
|
||||
:add_param('player', false, 'player-alive')
|
||||
:set_flag('admin_only')
|
||||
:register(function(player,from_player,raw)
|
||||
:register(function(player, from_player)
|
||||
if from_player.index == player.index then
|
||||
-- return if attempting to teleport to self
|
||||
return Commands.error{'expcom-tp.to-self'}
|
||||
end
|
||||
if not teleport(from_player,player) then
|
||||
if not teleport(from_player, player) then
|
||||
-- return if the teleport failed
|
||||
return Commands.error{'expcom-tp.no-position-found'}
|
||||
end
|
||||
@@ -55,16 +55,16 @@ end)
|
||||
--- Teleports you to a player.
|
||||
-- @command goto
|
||||
-- @tparam LuaPlayer player the player to teleport to, must be online (if dead goes to where they died)
|
||||
Commands.new_command('goto','Teleports you to a player.')
|
||||
:add_param('player',false,'player-online')
|
||||
:add_alias('tp-me','tpme')
|
||||
Commands.new_command('goto', 'Teleports you to a player.')
|
||||
:add_param('player', false, 'player-online')
|
||||
:add_alias('tp-me', 'tpme')
|
||||
:set_flag('admin_only')
|
||||
:register(function(player,to_player,raw)
|
||||
:register(function(player, to_player)
|
||||
if to_player.index == player.index then
|
||||
-- return if attempting to teleport to self
|
||||
return Commands.error{'expcom-tp.to-self'}
|
||||
end
|
||||
if not teleport(player,to_player) then
|
||||
if not teleport(player, to_player) then
|
||||
-- return if the teleport failed
|
||||
return Commands.error{'expcom-tp.no-position-found'}
|
||||
end
|
||||
|
||||
@@ -13,47 +13,47 @@ require 'config.expcore.command_role_parse'
|
||||
-- @command give-warning
|
||||
-- @tparam LuaPlayer player the player the will recive a warning
|
||||
-- @tparam string reason the reason the player is being given a warning
|
||||
Commands.new_command('give-warning','Gives a warning to a player; may lead to automatic script action.')
|
||||
:add_param('player',false,'player-role')
|
||||
:add_param('reason',false)
|
||||
Commands.new_command('give-warning', 'Gives a warning to a player; may lead to automatic script action.')
|
||||
:add_param('player', false, 'player-role')
|
||||
:add_param('reason', false)
|
||||
:add_alias('warn')
|
||||
:enable_auto_concat()
|
||||
:register(function(player,action_player,reason,raw)
|
||||
Warnings.add_warning(action_player,player.name,reason)
|
||||
:register(function(player, action_player, reason)
|
||||
Warnings.add_warning(action_player, player.name, reason)
|
||||
local action_player_name_color = format_chat_player_name(action_player)
|
||||
local by_player_name_color = format_chat_player_name(player)
|
||||
game.print{'expcom-warnings.received',action_player_name_color,by_player_name_color,reason}
|
||||
game.print{'expcom-warnings.received', action_player_name_color, by_player_name_color, reason}
|
||||
end)
|
||||
|
||||
--- Gets the number of warnings a player has. If no player then lists all players and the number of warnings they have.
|
||||
-- @command get-warnings
|
||||
-- @tparam[opt=list] LuaPlayer player the player to get the warning for, if nil all players are listed
|
||||
Commands.new_command('get-warnings','Gets the number of warnings a player has. If no player then lists all players and the number of warnings they have.')
|
||||
:add_param('player',true,'player')
|
||||
:add_alias('warnings','list-warnings')
|
||||
:register(function(player,action_player,raw)
|
||||
if action_player then
|
||||
local warnings = Warnings.get_warnings(action_player)
|
||||
local script_warnings = Warnings.get_script_warnings(action_player)
|
||||
local action_player_name_color = format_chat_player_name(action_player)
|
||||
Commands.print{'expcom-warnings.player',action_player_name_color,warnings,script_warnings,config.temp_warning_limit}
|
||||
Commands.new_command('get-warnings', 'Gets the number of warnings a player has. If no player then lists all players and the number of warnings they have.')
|
||||
:add_param('player', true, 'player')
|
||||
:add_alias('warnings', 'list-warnings')
|
||||
:register(function(_, player)
|
||||
if player then
|
||||
local warnings = Warnings.get_warnings(player)
|
||||
local script_warnings = Warnings.get_script_warnings(player)
|
||||
local player_name_color = format_chat_player_name(player)
|
||||
Commands.print{'expcom-warnings.player', player_name_color, warnings, script_warnings, config.temp_warning_limit}
|
||||
else
|
||||
local rtn = {}
|
||||
local user_warnings = Warnings.user_warnings
|
||||
local user_script_warnings = Warnings.user_script_warnings
|
||||
for player_name,warnings in pairs(user_warnings) do
|
||||
rtn[player_name] = {#warnings,0}
|
||||
for player_name, warnings in pairs(user_warnings) do
|
||||
rtn[player_name] = {#warnings, 0}
|
||||
end
|
||||
for player_name,warnings in pairs(user_script_warnings) do
|
||||
for player_name, warnings in pairs(user_script_warnings) do
|
||||
if not rtn[player_name] then
|
||||
rtn[player_name] = {0,0}
|
||||
rtn[player_name] = {0, 0}
|
||||
end
|
||||
rtn[player_name][2] = #warnings
|
||||
end
|
||||
Commands.print{'expcom-warnings.list-tilte'}
|
||||
for player_name,warnings in pairs(rtn) do
|
||||
for player_name, warnings in pairs(rtn) do
|
||||
local player_name_color = format_chat_player_name(player_name)
|
||||
Commands.print{'expcom-warnings.list',player_name_color,warnings[1],warnings[2],config.temp_warning_limit}
|
||||
Commands.print{'expcom-warnings.list', player_name_color, warnings[1], warnings[2], config.temp_warning_limit}
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -61,12 +61,12 @@ end)
|
||||
--- Clears all warnings (and script warnings) from a player
|
||||
-- @command clear-warnings
|
||||
-- @tparam LuaPlayer player the player to clear the warnings from
|
||||
Commands.new_command('clear-warnings','Clears all warnings (and script warnings) from a player')
|
||||
:add_param('player',false,'player')
|
||||
:register(function(player,action_player,raw)
|
||||
Warnings.clear_warnings(action_player,player.name)
|
||||
Warnings.clear_script_warnings(action_player,player.name)
|
||||
Commands.new_command('clear-warnings', 'Clears all warnings (and script warnings) from a player')
|
||||
:add_param('player', false, 'player')
|
||||
:register(function(player, action_player)
|
||||
Warnings.clear_warnings(action_player, player.name)
|
||||
Warnings.clear_script_warnings(action_player, player.name)
|
||||
local action_player_name_color = format_chat_player_name(action_player)
|
||||
local by_player_name_color = format_chat_player_name(player)
|
||||
game.print{'expcom-warnings.cleared',action_player_name_color,by_player_name_color}
|
||||
game.print{'expcom-warnings.cleared', action_player_name_color, by_player_name_color}
|
||||
end)
|
||||
Reference in New Issue
Block a user