Add Command Description Locale (#323)

* Update admin-chat.lua

* Update admin-markers.lua

* Update artillery.lua

* Update bot-queue.lua

* Update cheat-mode.lua

* Update clear-inventory.lua

* Update connect.lua

* Update debug.lua

* Update enemy.lua

* Update find.lua

* Update friendly-fire.lua

* Update help.lua

* Update home.lua

* Update interface.lua

* Update jail.lua

* Update kill.lua

* Update last-location.lua

* Update me.lua

* Update pollution.lua

* Update protection.lua

* Update rainbow.lua

* Update ratio.lua

* Update repair.lua

* Update reports.lua

* Update research.lua

* Update roles.lua

* Update roles.lua

* Update search.lua

* Update spawn.lua

* Update spectate.lua

* Update speed.lua

* Update surface-clearing.lua

* Update teleport.lua

* Update train.lua

* Update vlayer.lua

* Update warnings.lua

* Update waterfill.lua

* Update gui.cfg

* Update gui.cfg

* Update gui.cfg

* Update commands.cfg

* Update commands.cfg

* Update commands.cfg

* Update connect.lua

* Update cheat-mode.lua

* Update commands.cfg

* Update commands.cfg

* Update commands.cfg

* Update commands.cfg

* Update commands.cfg

* Update commands.cfg

* Update admin-chat.lua

* Update admin-markers.lua

* Update vlayer.lua

* Update artillery.lua

* Update bot-queue.lua

* Update cheat-mode.lua

* Update clear-inventory.lua

* Update connect.lua

* Update debug.lua

* Update enemy.lua

* Update find.lua

* Update friendly-fire.lua

* Update help.lua

* Update home.lua

* Update interface.lua

* Update jail.lua

* Update kill.lua

* Update last-location.lua

* Update me.lua

* Update pollution.lua

* Update protection.lua

* Update rainbow.lua

* Update ratio.lua

* Update repair.lua

* Update reports.lua

* Update research.lua

* Update roles.lua

* Update search.lua

* Update spawn.lua

* Update spectate.lua

* Update speed.lua

* Update surface-clearing.lua

* Update teleport.lua

* Update train.lua

* Update warnings.lua

* Update waterfill.lua

* Update gui.cfg

* Update gui.cfg

* Update gui.cfg

* Update gui.cfg

* Update gui.cfg

* Update commands.cfg

* Update commands.cfg

* Update addons.cfg

* Update addons.cfg

* Update data.cfg

* Update data.cfg

* Update gui.cfg

* Update gui.cfg

* Update data.cfg

* Update data.cfg

* Update gui.cfg

* Update gui.cfg

* Update gui.cfg

* Update gui.cfg

* Update gui.cfg

* Update gui.cfg

* Update commands.lua

* Update admin-chat.lua

* Update admin-markers.lua

* Update artillery.lua

* Update bot-queue.lua

* Update cheat-mode.lua

* Update clear-inventory.lua

* Update connect.lua

* Update debug.lua

* Update enemy.lua

* Update find.lua

* Update help.lua

* Update interface.lua

* Update home.lua

* Update jail.lua

* Update kill.lua

* Update last-location.lua

* Update me.lua

* Update pollution.lua

* Update protection.lua

* Update rainbow.lua

* Update ratio.lua

* Update repair.lua

* Update reports.lua

* Update research.lua

* Update roles.lua

* Update search.lua

* Update spawn.lua

* Update spectate.lua

* Update speed.lua

* Update surface-clearing.lua

* Update teleport.lua

* Update train.lua

* Update vlayer.lua

* Update warnings.lua

* Update waterfill.lua

* Update commands.cfg

* Update commands.cfg

* Update enemy.lua

* Update friendly-fire.lua

* Update roles.lua

* Update spectate.lua

* Update spectate.lua
This commit is contained in:
2024-09-10 19:07:02 +09:00
committed by GitHub
parent 6491c57bff
commit 90faf2ff93
47 changed files with 848 additions and 535 deletions

View File

@@ -10,17 +10,18 @@ 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.')
Commands.new_command('admin-chat', {'expcom-admin-chat.description'}, '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)
local player_name_colour = format_chat_player_name(player)
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}
end
end
return Commands.success -- prevents command complete message from showing
end)
end)

View File

@@ -21,7 +21,7 @@ end)
--- Toggle admin marker mode, can only be applied to yourself
-- @command admin-marker
Commands.new_command('admin-marker', 'Toggles admin marker mode, new markers can only be edited by admins')
Commands.new_command('admin-marker', {'expcom-admin-marker.description'}, 'Toggles admin marker mode, new markers can only be edited by admins')
:set_flag('admin_only')
:add_alias('am', 'admin-markers')
:register(function(player)
@@ -85,4 +85,4 @@ local function maintain_tag(event)
end
Event.add(defines.events.on_chart_tag_modified, maintain_tag)
Event.add(defines.events.on_chart_tag_removed, maintain_tag)
Event.add(defines.events.on_chart_tag_removed, maintain_tag)

View File

@@ -72,7 +72,7 @@ Selection.on_selection(SelectionArtyArea, function(event)
end
end)
Commands.new_command('artillery-target-remote', 'Artillery Target Remote')
Commands.new_command('artillery-target-remote', {'expcom-artillery.description'}, 'Artillery Target Remote')
:register(function(player)
if Selection.is_selecting(player, SelectionArtyArea) then
Selection.stop(player)

View File

@@ -6,7 +6,7 @@
local Commands = require 'expcore.commands' --- @dep expcore.commands
require 'config.expcore.command_general_parse'
Commands.new_command('bot-queue-get', 'Get bot queue')
Commands.new_command('bot-queue-get', {'expcom-bot-queue.description-get'}, 'Get bot queue')
:set_flag('admin_only')
:register(function(player)
local s = player.force.max_successful_attempts_per_tick_per_construction_queue
@@ -14,7 +14,7 @@ Commands.new_command('bot-queue-get', 'Get bot queue')
return Commands.success{'expcom-bot-queue.result', player.name, s, f}
end)
Commands.new_command('bot-queue-set', 'Set bot queue')
Commands.new_command('bot-queue-set', {'expcom-bot-queue.description-set'}, 'Set bot queue')
:add_param('amount', 'integer-range', 1, 20)
:set_flag('admin_only')
:register(function(player, amount)

View File

@@ -9,7 +9,7 @@ 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.')
Commands.new_command('toggle-cheat-mode', {'expcom-cheat.description-cheat'}, '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
@@ -20,7 +20,7 @@ end}
return Commands.success
end)
Commands.new_command('research-all', 'Set all research for your force.')
Commands.new_command('research-all', {'expcom-cheat.description-res'}, 'Set all research for your force.')
:set_flag('admin_only')
:add_param('force', true, 'force')
:set_defaults{force=function(player)
@@ -32,7 +32,7 @@ end}
return Commands.success
end)
Commands.new_command('toggle-always-day', 'Toggles always day in surface')
Commands.new_command('toggle-always-day', {'expcom-cheat.description-day'}, 'Toggles always day in surface.')
:set_flag('admin_only')
:add_param('surface', true, 'surface')
:set_defaults{surface=function(player)

View File

@@ -10,7 +10,7 @@ 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')
Commands.new_command('clear-inventory', {'expcom-clr-inv.description'}, 'Clears a players inventory')
:add_param('player', false, 'player-role')
:add_alias('clear-inv', 'move-inventory', 'move-inv')
:register(function(_, player)

View File

@@ -51,7 +51,7 @@ end
-- @command connect
-- @tparam string server The address or name of the server to connect to
-- @tparam[opt=false] boolean is_address If an address was given for the server param
Commands.new_command('connect', 'Connect to another server')
Commands.new_command('connect', {'expcom-connect.description'}, 'Connect to another server')
:add_param('server')
:add_param('is_address', true, 'boolean')
:add_alias('join', 'server')
@@ -71,7 +71,7 @@ end)
-- @tparam string address The address or name of the server to connect to
-- @tparam LuaPlayer player The player to connect to a different server
-- @tparam[opt=false] boolean is_address If an address was given for the server param
Commands.new_command('connect-player', 'Send a player to a different server')
Commands.new_command('connect-player', {'expcom-connect.description-player'}, 'Send a player to a different server')
:add_param('player', 'player-role')
:add_param('server')
:add_param('is_address', true, 'boolean')
@@ -90,7 +90,7 @@ end)
-- @command connect-all
-- @tparam string address The address or name of the server to connect to
-- @tparam[opt=false] boolean is_address If an address was given for the server param
Commands.new_command('connect-all', 'Connect all players to another server')
Commands.new_command('connect-all', {'expcom-connect.description-all'}, 'Connect all players to another server')
:add_param('server')
:add_param('is_address', true, 'boolean')
:register(function(_, server, is_address)
@@ -104,4 +104,4 @@ Commands.new_command('connect-all', 'Connect all players to another server')
for _, player in pairs(game.connected_players) do
External.request_connection(player, server_id)
end
end)
end)

View File

@@ -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', {'expcom-debug.description'}, 'Opens the debug pannel for viewing tables.')
:register(function(player)
DebugView.open_dubug(player)
end)
end)

View File

@@ -6,14 +6,14 @@
local Commands = require 'expcore.commands' --- @dep expcore.commands
require 'config.expcore.command_general_parse'
Commands.new_command('kill-biters', 'Kill all biters (only)')
Commands.new_command('kill-biters', {'expcom-enemy.description-kill'}, 'Kill all biters only')
:set_flag('admin_only')
:register(function(_, _)
game.forces['enemy'].kill_all_units()
return Commands.success
end)
Commands.new_command('remove-biters', 'Remove biters and prevent generation')
Commands.new_command('remove-biters', {'expcom-enemy.description-remove'}, 'Remove biters and prevent generation')
:set_flag('admin_only')
:add_param('surface', true, 'surface')
:set_defaults{surface=function(player)
@@ -27,4 +27,3 @@ end}
surface.map_gen_settings.autoplace_controls['enemy-base'].size = 'none'
return Commands.success
end)

View File

@@ -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.')
Commands.new_command('find-on-map', {'expcom-find.description'}, '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)
return Commands.success -- prevents command complete message from showing
end)
end)

View File

@@ -7,7 +7,7 @@ local Commands = require 'expcore.commands' --- @dep expcore.commands
require 'config.expcore.command_general_parse'
-- For Modded Server Use
Commands.new_command('toggle-friendly-fire', 'Toggle Friendly Fire')
Commands.new_command('toggle-friendly-fire', {'expcom-ff.description'}, 'Toggle friendly fire')
:add_param('force', true, 'force')
:set_defaults{force=function(player)
return player.force

View File

@@ -18,29 +18,34 @@ 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.')
Commands.new_command('search-help', {'expcom-chelp.description'}, '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
page = math.floor(tonumber(keyword))
keyword = ''
end
-- gets a value for pages, might have result in cache
local pages
local found = 0
if search_cache[player_index] and search_cache[player_index].keyword == keyword:lower() then
pages = search_cache[player_index].pages
found = search_cache[player_index].found
else
pages = {{}}
local current_page = 1
local page_count = 0
local commands = Commands.search(keyword, player)
-- loops other all commands returned by search, includes game commands
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
@@ -49,6 +54,7 @@ Commands.new_command('search-help', 'Searches for a keyword in all commands you
current_page = current_page + 1
table.insert(pages, {})
end
-- adds the new command to the page
page_count = page_count + 1
found = found + 1
@@ -61,6 +67,7 @@ Commands.new_command('search-help', 'Searches for a keyword in all commands you
alias_format
})
end
-- adds the result to the cache
search_cache[player_index] = {
keyword=keyword:lower(),
@@ -68,21 +75,26 @@ Commands.new_command('search-help', 'Searches for a keyword in all commands you
found=found
}
end
-- print the requested page
keyword = keyword == '' and '<all>' or keyword
Commands.print({'expcom-chelp.title', keyword}, 'cyan')
if pages[page] then
for _, command in pairs(pages[page]) do
Commands.print(command)
end
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}
end
-- blocks command complete message
return Commands.success
end)
-- way to access global
return search_cache
return search_cache

View File

@@ -30,7 +30,7 @@ end
--- Teleports you to your home location
-- @command home
Commands.new_command('home', 'Teleports you to your home location')
Commands.new_command('home', {'expcom-home.description-home'}, 'Teleports you to your home location')
:register(function(player)
local home = homes[player.index]
if not home or not home[1] then
@@ -44,7 +44,7 @@ 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')
Commands.new_command('home-set', {'expcom-home.description-home-set'}, 'Sets your home location to your current position')
:register(function(player)
local home = homes[player.index]
if not home then
@@ -58,7 +58,7 @@ end)
--- Returns your current home location
-- @command home-get
Commands.new_command('home-get', 'Returns your current home location')
Commands.new_command('home-get', {'expcom-home.description-home-get'}, 'Returns your current home location')
:register(function(player)
local home = homes[player.index]
if not home or not home[1] then
@@ -70,7 +70,7 @@ end)
--- Teleports you to previous location
-- @command return
Commands.new_command('return', 'Teleports you to previous location')
Commands.new_command('return', {'expcom-home.description-return'}, 'Teleports you to previous location')
:register(function(player)
local home = homes[player.index]
if not home or not home[2] then
@@ -80,4 +80,4 @@ Commands.new_command('return', 'Teleports you to previous location')
teleport(player, home[2])
home[2] = rtn
Commands.print{'expcom-home.return-set', rtn.x, rtn.y}
end)
end)

View File

@@ -62,7 +62,7 @@ end
--- Sends an invocation to be ran and returns the result.
-- @command interface
-- @tparam string invocation the command that will be run
Commands.new_command('interface', 'Sends an invocation to be ran and returns the result.')
Commands.new_command('interface', {'expcom-interface.description'}, 'Sends an invocation to be ran and returns the result.')
:add_param('invocation', false)
:enable_auto_concat()
:set_flag('admin_only')
@@ -113,4 +113,4 @@ return {
add_interface_callback = add_interface_callback,
interface_env = interface_env,
clean_stack_trace = function(str) return str:gsub('%.%.%..-/temp/currently%-playing', '') end
}
}

View File

@@ -12,7 +12,7 @@ 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.')
Commands.new_command('jail', {'expcom-jail.description-jail'}, 'Puts a player into jail and removes all other roles.')
:add_param('player', false, 'player-role')
:add_param('reason', true)
:enable_auto_concat()
@@ -31,7 +31,7 @@ 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.')
Commands.new_command('unjail', {'expcom-jail.description-unjail'}, 'Removes a player from jail.')
:add_param('player', false, 'player-role')
:add_alias('clear-jail', 'remove-jail')
:enable_auto_concat()

View File

@@ -11,7 +11,7 @@ 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.')
Commands.new_command('kill', {'expcom-kill.description'}, '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
@@ -26,9 +26,11 @@ end}
end
if player == action_player then
action_player.character.die()
elseif Roles.player_allowed(player, 'command/kill/always') then
action_player.character.die()
else
return Commands.error{'expcore-commands.unauthorized'}
end
end)
end)

View File

@@ -10,7 +10,7 @@ require 'config.expcore.command_general_parse'
--- Get the last location of a player.
-- @command last-location
-- @tparam LuaPlayer player the player that you want a location of
Commands.new_command('last-location', 'Sends you the last location of a player')
Commands.new_command('last-location', {'expcom-lastlocation.description'}, 'Sends you the last location of a player')
:add_alias('location')
:add_param('player', false, 'player')
:register(function(_, action_player)

View File

@@ -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')
Commands.new_command('me', {'expcom-me.description'}, 'Sends an action message in the chat')
:add_param('action', false)
:enable_auto_concat()
: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)
end)
end)

View File

@@ -6,7 +6,7 @@
local Commands = require 'expcore.commands' --- @dep expcore.commands
require 'config.expcore.command_general_parse'
Commands.new_command('pollution-clear', 'Clear pollution')
Commands.new_command('pollution-clear', {'expcom-pol.description-clr'}, 'Clear pollution')
:set_flag('admin_only')
:add_alias('pol-clr')
:add_param('surface', true, 'surface')
@@ -19,7 +19,7 @@ end}
return Commands.success
end)
Commands.new_command('pollution-off', 'Disable pollution')
Commands.new_command('pollution-off', {'expcom-pol.description-off'}, 'Disable pollution')
:set_flag('admin_only')
:add_alias('pol-off')
:register(function(player)

View File

@@ -96,7 +96,7 @@ end
--- Toggles entity protection selection
-- @command protect-entity
Commands.new_command('protect-entity', 'Toggles entity protection selection, hold shift to remove protection')
Commands.new_command('protect-entity', {'expcom-protection.description-pe'}, 'Toggles entity protection selection, hold shift to remove protection')
:add_alias('pe')
:register(function(player)
if Selection.is_selecting(player, SelectionProtectEntity) then
@@ -109,7 +109,7 @@ end)
--- Toggles area protection selection
-- @command protect-area
Commands.new_command('protect-area', 'Toggles area protection selection, hold shift to remove protection')
Commands.new_command('protect-area', {'expcom-protection.description-pa'}, 'Toggles area protection selection, hold shift to remove protection')
:add_alias('pa')
:register(function(player)
if Selection.is_selecting(player, SelectionProtectArea) then
@@ -212,4 +212,4 @@ end)
Event.add(EntityProtection.events.on_repeat_violation, function(event)
local player_name = format_chat_player_name(event.player_index)
Roles.print_to_roles_higher('Regular', {'expcom-protection.repeat-offence', player_name, event.entity.localised_name, event.entity.position.x, event.entity.position.y})
end)
end)

View File

@@ -43,7 +43,7 @@ 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')
Commands.new_command('rainbow', {'expcom-rainbow.description'}, 'Sends an rainbow message in the chat')
:add_param('message', false)
:enable_auto_concat()
:register(function(player, message)
@@ -59,4 +59,4 @@ Commands.new_command('rainbow', 'Sends an rainbow message in the chat')
return rtn
end)
game.print(output)
end)
end)

View File

@@ -17,66 +17,70 @@ local function AmountOfMachines(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'}
Commands.new_command('ratio', {'expcom-ratio.description'}, '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 recipe = machine.get_recipe() -- recipe
if not recipe then --nil check
return Commands.error{'expcom-ratio.notSelecting'}
end
local items = recipe.ingredients -- items in that recipe
local products = recipe.products -- output items
local amountOfMachines
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/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
end
----------------------------items----------------------------
for i, item in ipairs(items) do
local sprite -- string to make the icon work either fluid ore item
if item.type == "item" then
sprite = 'expcom-ratio.item-in'
else
sprite = 'expcom-ratio.fluid-in'
end
if machine.type ~= "assembling-machine" and machine.type ~= "furnace" then
return Commands.error{'expcom-ratio.notSelecting'}
end
local recipe = machine.get_recipe() -- recipe
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
if not recipe then --nil check
return Commands.error{'expcom-ratio.notSelecting'}
----------------------------products----------------------------
for i, product in ipairs(products) do
local sprite -- string to make the icon work either fluid ore item
if product.type == "item" then
sprite = 'expcom-ratio.item-out'
else
sprite = 'expcom-ratio.fluid-out'
end
local items = recipe.ingredients -- items in that recipe
local products = recipe.products -- output items
local amountOfMachines
local moduleInventory = machine.get_module_inventory()--the module Inventory of the machine
local multi = Modules(moduleInventory) --function for the productively modals
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
if itemsPerSecond then
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
end
----------------------------items----------------------------
for i, item in ipairs(items) do
local sprite -- string to make the icon work either fluid ore item
end
if item.type == "item" then
sprite = 'expcom-ratio.item-in'
else
sprite = 'expcom-ratio.fluid-in'
end
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(products) do
local sprite -- string to make the icon work either fluid ore item
if product.type == "item" then
sprite = 'expcom-ratio.item-out'
else
sprite = 'expcom-ratio.fluid-out'
end
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}
end
end)
if amountOfMachines ~= 1 then
Commands.print{'expcom-ratio.machines', amountOfMachines}
end
end)

View File

@@ -11,7 +11,7 @@ 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')
Commands.new_command('repair', {'expcom-repair.description'}, '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
@@ -49,4 +49,4 @@ Commands.new_command('repair', 'Repairs entities on your force around you')
end
end
return Commands.success{'expcom-repair.result', revive_count, heal_count}
end)
end)

View File

@@ -22,7 +22,7 @@ end
-- @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')
Commands.new_command('report', {'expcom-report.description-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
@@ -51,7 +51,7 @@ 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.')
Commands.new_command('get-reports', {'expcom-report.description-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)
@@ -78,7 +78,7 @@ 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.')
Commands.new_command('clear-reports', {'expcom-report.description-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)
@@ -94,4 +94,4 @@ Commands.new_command('clear-reports', 'Clears all reports from a player or just
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}
end)
end)

View File

@@ -22,7 +22,7 @@ local function res_queue(force, res, by_script)
end
end
Commands.new_command('auto-research', 'Automatically queue up research')
Commands.new_command('auto-research', {'expcom-res.description-ares'}, 'Automatically queue up research')
:add_alias('ares')
:register(function(player)
research.res_queue_enable = not research.res_queue_enable

View File

@@ -12,15 +12,17 @@ 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')
Commands.new_command('assign-role', {'expcom-roles.description-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)
local player_highest = Roles.get_player_highest_role(player)
if player_highest.index < role.index then
Roles.assign_player(action_player, role, player.name)
else
return Commands.error{'expcom-roles.higher-role'}
end
@@ -30,15 +32,17 @@ 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')
Commands.new_command('unassign-role', {'expcom-roles.description-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)
local player_highest = Roles.get_player_highest_role(player)
if player_highest.index < role.index then
Roles.unassign_player(action_player, role, player.name)
else
return Commands.error{'expcom-roles.higher-role'}
end
@@ -47,28 +51,33 @@ 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')
Commands.new_command('list-roles', {'expcom-roles.description-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 player then
roles = Roles.get_player_roles(player)
end
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)
if index == 1 then
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}
end
end
return Commands.success(message)
end)
end)

View File

@@ -103,7 +103,7 @@ end
--- Get a list of players sorted by the quantity of an item in their inventory
-- @command search-amount
-- @tparam LuaItemPrototype item The item to search for in players inventories
Commands.new_command('search-amount', 'Display players sorted by the quantity of an item held')
Commands.new_command('search-amount', {'expcom-inv-search.description-ia'}, 'Display players sorted by the quantity of an item held')
:add_alias('ia')
:add_param('item', false, item_parse)
:enable_auto_concat()
@@ -122,7 +122,7 @@ end
--- Get a list of players who have the given item, sorted by how recently they joined
-- @command search-recent
-- @tparam LuaItemPrototype item The item to search for in players inventories
Commands.new_command('search-recent', 'Display players who hold an item sorted by join time')
Commands.new_command('search-recent', {'expcom-inv-search.description-ir'}, 'Display players who hold an item sorted by join time')
:add_alias('ir')
:add_param('item', false, item_parse)
:enable_auto_concat()
@@ -141,7 +141,7 @@ end
--- Get a list of players sorted by quantity held and play time
-- @command search
-- @tparam LuaItemPrototype item The item to search for in players inventories
Commands.new_command('search', 'Display players sorted by the quantity of an item held and playtime')
Commands.new_command('search', {'expcom-inv-search.description-i'}, 'Display players sorted by the quantity of an item held and playtime')
:add_alias('i')
:add_param('item', false, item_parse)
:enable_auto_concat()
@@ -155,7 +155,7 @@ end)
--- Get a list of online players sorted by quantity held and play time
-- @command search-online
-- @tparam LuaItemPrototype item The item to search for in players inventories
Commands.new_command('search-online', 'Display online players sorted by the quantity of an item held and playtime')
Commands.new_command('search-online', {'expcom-inv-search.description-io'}, 'Display online players sorted by the quantity of an item held and playtime')
:add_alias('io')
:add_param('item', false, item_parse)
:enable_auto_concat()
@@ -164,4 +164,4 @@ Commands.new_command('search-online', 'Display online players sorted by the quan
if #players == 0 then return {'expcom-inv-search.results-none', item.name} end
local top_players = sort_players(players, combined_sort)
display_players(player, top_players, item)
end)
end)

View File

@@ -39,7 +39,7 @@ 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')
Commands.new_command('go-to-spawn', {'expcom-spawn.description'}, 'Teleport to spawn')
:add_param('player', true, 'player-role-alive')
:set_defaults{
player=function(player)
@@ -52,15 +52,18 @@ Commands.new_command('go-to-spawn', 'Teleport to 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
if not teleport(action_player) then
return Commands.error{'expcom-spawn.unavailable'}
end
else
return Commands.error{'expcore-commands.unauthorized'}
end
end)
end)

View File

@@ -9,10 +9,11 @@ require 'config.expcore.command_general_parse'
--- Toggles spectator mode for the caller
-- @command spectate
Commands.new_command('spectate', 'Toggles spectator mode')
Commands.new_command('spectate', {'expcom-spectate.description-spectate'}, 'Toggles spectator mode')
:register(function(player)
if Spectate.is_spectating(player) then
Spectate.stop_spectate(player)
else
Spectate.start_spectate(player)
end
@@ -21,13 +22,14 @@ 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')
Commands.new_command('follow', {'expcom-spectate.description-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)
end)

View File

@@ -6,7 +6,7 @@
local Commands = require 'expcore.commands' --- @dep expcore.commands
require 'config.expcore.command_general_parse'
Commands.new_command('game-speed', 'Set game speed')
Commands.new_command('game-speed', {'expcom-speed.description'}, 'Set game speed')
:add_param('amount', 'number-range', 0.2, 8)
:set_flag('admin_only')
:register(function(player, amount)

View File

@@ -7,7 +7,7 @@ local copy_items_stack = _C.copy_items_stack --- @dep expcore.common
local Commands = require 'expcore.commands' --- @dep expcore.commands
require 'config.expcore.command_general_parse'
Commands.new_command('clear-item-on-ground', 'Clear Item On Ground')
Commands.new_command('clear-item-on-ground', {'expcom-surface-clearing.description-ci'}, 'Clear Item On Ground')
:add_param('range', false, 'integer-range', 1, 1000)
:register(function(player, range)
for _, e in pairs(player.surface.find_entities_filtered{position=player.position, radius=range, name='item-on-ground'}) do
@@ -22,7 +22,7 @@ Commands.new_command('clear-item-on-ground', 'Clear Item On Ground')
return Commands.success
end)
Commands.new_command('clear-blueprint', 'Clear Blueprint')
Commands.new_command('clear-blueprint', {'expcom-surface-clearing.description-cb'}, 'Clear Blueprint')
:add_param('range', false, 'integer-range', 1, 1000)
:register(function(player, range)
for _, e in pairs(player.surface.find_entities_filtered{position=player.position, radius=range, type='entity-ghost'}) do
@@ -30,4 +30,4 @@ Commands.new_command('clear-blueprint', 'Clear Blueprint')
end
return Commands.success
end)
end)

View File

@@ -41,7 +41,7 @@ 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.')
Commands.new_command('teleport', {'expcom-tp.description-tp'}, 'Teleports a player to another player.')
:add_param('from_player', false, 'player-alive')
:add_param('to_player', false, 'player-online')
:add_alias('tp')
@@ -60,7 +60,7 @@ 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.')
Commands.new_command('bring', {'expcom-tp.description-bring'}, 'Teleports a player to you.')
:add_param('player', false, 'player-alive')
:set_flag('admin_only')
:register(function(player, from_player)
@@ -78,7 +78,7 @@ 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.')
Commands.new_command('goto', {'expcom-tp.description-goto'}, 'Teleports you to a player.')
:add_param('player', false, 'player-online')
:add_alias('tp-me', 'tpme')
:register(function(player, to_player)

View File

@@ -7,7 +7,7 @@ local Commands = require 'expcore.commands' --- @dep expcore.commands
require 'config.expcore.command_general_parse'
local format_number = require('util').format_number
Commands.new_command('set-trains-to-automatic', 'Set All Trains to Automatic')
Commands.new_command('set-trains-to-automatic', {'expcom-train.description'}, 'Set All Trains to Automatic')
:register(function(player)
local count = 0

View File

@@ -5,11 +5,11 @@ local Commands = require 'expcore.commands' --- @dep expcore.commands
require 'config.expcore.command_general_parse'
local vlayer = require 'modules.control.vlayer'
Commands.new_command('personal-battery-recharge', 'Recharge Player Battery upto a portion with vlayer')
Commands.new_command('personal-battery-recharge', {'vlayer.description-pbr'}, 'Recharge Player Battery upto a portion with vlayer')
:add_param('amount', 'number-range', 0.2, 1)
:register(function(player, amount)
if vlayer.get_statistics()['energy_sustained'] == 0 then
return Commands.error('vlayer need to be running to get this command work')
return Commands.error({'vlayer.pbr-not-running'})
end
local armor = player.get_inventory(defines.inventory.character_armor)[1].grid
@@ -27,7 +27,7 @@ Commands.new_command('personal-battery-recharge', 'Recharge Player Battery upto
return Commands.success
end)
Commands.new_command('vlayer-info', 'Vlayer Info')
Commands.new_command('vlayer-info', {'vlayer.description-vi'}, 'Vlayer Info')
:register(function(_)
local c = vlayer.get_circuits()

View File

@@ -13,7 +13,7 @@ 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.')
Commands.new_command('give-warning', {'expcom-warnings.description-give'}, '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')
@@ -28,7 +28,7 @@ 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.')
Commands.new_command('get-warnings', {'expcom-warnings.description-get'}, '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)
@@ -63,7 +63,7 @@ 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')
Commands.new_command('clear-warnings', {'expcom-warnings.description-clear'}, '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)
@@ -71,4 +71,4 @@ Commands.new_command('clear-warnings', 'Clears all warnings (and script warnings
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}
end)
end)

View File

@@ -4,7 +4,7 @@
local Commands = require 'expcore.commands' --- @dep expcore.commands
require 'config.expcore.command_general_parse'
local Selection = require 'modules.control.selection' --- @dep modules.control.selection
local SelectionConvertArea = 'ConvertArea'
local SelectionConvertArea = 'WaterfillConvertArea'
--- Align an aabb to the grid by expanding it
local function aabb_align_expand(aabb)
@@ -14,7 +14,7 @@ local function aabb_align_expand(aabb)
}
end
Commands.new_command('waterfill', 'Change tile to water')
Commands.new_command('waterfill', {'expcom-waterfill.description'}, 'Change tile to water')
:register(function(player)
local inv = player.get_main_inventory()
@@ -37,6 +37,10 @@ Selection.on_selection(SelectionConvertArea, function(event)
local area = aabb_align_expand(event.area)
local player = game.get_player(event.player_index)
if not player then
return
end
local entities = player.surface.find_entities_filtered{area=area, name='steel-chest'}
if #entities == 0 then
@@ -46,6 +50,11 @@ Selection.on_selection(SelectionConvertArea, function(event)
local tiles_to_make = {}
local inv = player.get_main_inventory()
if not inv then
return
end
local clf_exp = inv.get_item_count('cliff-explosives')
for _, entity in pairs(entities) do