Fix start, join, formatting, and locale issues

This commit is contained in:
Cooldude2606
2024-11-14 23:59:22 +00:00
parent 48f55b0547
commit 9aee1c425f
29 changed files with 168 additions and 135 deletions

View File

@@ -13,11 +13,19 @@ local authorities = {}
--- If a command has the flag "character_only" then the command can only be used outside of remote view
authorities.exp_permission =
add(function(player, command)
if not player_allowed(player, command.flags.exp_permission or ("command/" .. command)) then
if not player_allowed(player, command.flags.exp_permission or ("command/" .. command.name)) then
return deny{ "exp-commands-authorities_role.deny" }
else
return allow()
end
end)
Roles.define_flag_trigger("is_system", function(player, state)
if state then
Commands.unlock_system_commands(player.name)
else
Commands.lock_system_commands(player.name)
end
end)
return authorities

View File

@@ -5,8 +5,9 @@ Adds a command that allows viewing and changing the construction queue limits
local Commands = require("modules/exp_commands")
--- Get / Set the current values for the bot queue
Commands.new("bot-queue", { "exp-commands_bot-queue.description" })
Commands.new("set-bot-queue", { "exp-commands_bot-queue.description" })
:optional("amount", { "exp-commands_bot-queue.arg-amount" }, Commands.types.integer_range(1, 20))
:add_aliases{ "bot-queue" }
:add_flags{ "admin_only" }
:register(function(player, amount)
if amount then

View File

@@ -52,7 +52,7 @@ end
--- Connect to a different server
Commands.new("connect", { "exp-commands_connect.description" })
:argument("server", { "exp-commands_connect.arg-server" }, Commands.types.string)
:optional("is-address", { "exp-commands_connect.is-address" }, Commands.types.boolean)
:optional("is-address", { "exp-commands_connect.arg-is-address" }, Commands.types.boolean)
:add_aliases{ "join" }
:register(function(player, server, is_address)
--- @cast server string
@@ -72,7 +72,7 @@ Commands.new("connect", { "exp-commands_connect.description" })
Commands.new("connect-player", { "exp-commands_connect.description-player" })
:argument("player", { "exp-commands_connect.arg-player" }, Commands.types.player_online)
:argument("server", { "exp-commands_connect.arg-server" }, Commands.types.string)
:optional("is-address", { "exp-commands_connect.is-address" }, Commands.types.boolean)
:optional("is-address", { "exp-commands_connect.arg-is-address" }, Commands.types.boolean)
:add_flags{ "admin_only" }
:register(function(player, other_player, server, is_address)
--- @cast other_player LuaPlayer
@@ -92,7 +92,7 @@ Commands.new("connect-player", { "exp-commands_connect.description-player" })
--- Connect all players to a different server
Commands.new("connect-all", { "exp-commands_connect.description-all" })
:argument("server", { "exp-commands_connect.arg-server" }, Commands.types.string)
:optional("is-address", { "exp-commands_connect.is-address" }, Commands.types.boolean)
:optional("is-address", { "exp-commands_connect.arg-is-address" }, Commands.types.boolean)
:add_flags{ "admin_only" }
:register(function(player, server, is_address)
--- @cast server string

View File

@@ -92,28 +92,28 @@ local function remove_render(player, key)
end
--- Toggles entity protection selection
Commands.new("protect-entity", { "exp-commands_protection.description-entity" })
Commands.new("protect-entity", { "exp-commands_entity-protection.description-entity" })
:add_aliases{ "pe" }
:register(function(player)
if Selection.is_selecting(player, SelectionNameEntity) then
Selection.stop(player)
return Commands.status.success{ "exp-commands_protection.exit-entity" }
return Commands.status.success{ "exp-commands_entity-protection.exit-entity" }
else
Selection.start(player, SelectionNameEntity)
return Commands.status.success{ "exp-commands_protection.enter-entity" }
return Commands.status.success{ "exp-commands_entity-protection.enter-entity" }
end
end)
--- Toggles area protection selection
Commands.new("protect-area", { "exp-commands_protection.description-area" })
Commands.new("protect-area", { "exp-commands_entity-protection.description-area" })
:add_aliases{ "pa" }
:register(function(player)
if Selection.is_selecting(player, SelectionNameEntity) then
Selection.stop(player)
return Commands.status.success{ "exp-commands_protection.exit-area" }
return Commands.status.success{ "exp-commands_entity-protection.exit-area" }
else
Selection.start(player, SelectionNameEntity)
return Commands.status.success{ "exp-commands_protection.enter-area" }
return Commands.status.success{ "exp-commands_entity-protection.enter-area" }
end
end)
@@ -126,7 +126,7 @@ Selection.on_selection(SelectionNameEntity, function(event)
show_protected_entity(player, entity)
end
player.print({ "exp-commands_protection.protected-entities", #event.entities }, Commands.print_settings.default)
player.print({ "exp-commands_entity-protection.protected-entities", #event.entities }, Commands.print_settings.default)
end)
--- When an area is selected to remove protection from entities
@@ -138,7 +138,7 @@ Selection.on_alt_selection(SelectionNameEntity, function(event)
remove_render(player, get_entity_key(entity))
end
player.print({ "exp-commands_protection.unprotected-entities", #event.entities }, Commands.print_settings.default)
player.print({ "exp-commands_entity-protection.unprotected-entities", #event.entities }, Commands.print_settings.default)
end)
--- When an area is selected to add protection to the area
@@ -150,13 +150,13 @@ Selection.on_selection(SelectionNameArea, function(event)
local player = game.players[event.player_index]
for _, next_area in pairs(areas) do
if contains_area(next_area, area) then
return player.print({ "exp-commands_protection.already-protected" }, Commands.print_settings.error)
return player.print({ "exp-commands_entity-protection.already-protected" }, Commands.print_settings.error)
end
end
EntityProtection.add_area(surface, area)
show_protected_area(player, surface, area)
player.print({ "exp-commands_protection.protected-area" }, Commands.print_settings.default)
player.print({ "exp-commands_entity-protection.protected-area" }, Commands.print_settings.default)
end)
--- When an area is selected to remove protection from the area
@@ -169,7 +169,7 @@ Selection.on_alt_selection(SelectionNameArea, function(event)
for _, next_area in pairs(areas) do
if contains_area(area, next_area) then
EntityProtection.remove_area(surface, next_area)
player.print({ "exp-commands_protection.unprotected-area" }, Commands.print_settings.default)
player.print({ "exp-commands_entity-protection.unprotected-area" }, Commands.print_settings.default)
remove_render(player, get_area_key(next_area))
end
end
@@ -222,7 +222,7 @@ end
--- When there is a repeat offence print it in chat
local function on_repeat_violation(event)
Roles.print_to_roles_higher("Regular", {
"exp-commands_protection.repeat-offence",
"exp-commands_entity-protection.repeat-offence",
format_player_name(event.player_index),
event.entity.localised_name,
event.entity.position.x,

View File

@@ -18,17 +18,17 @@ Storage.register({
end)
--- Toggle admin marker mode, can only be applied to yourself
local cmd_protected_tag =
Commands.new("protected-tag", { "exp-commands_protected-tags.description" })
local cmd_protect_tag =
Commands.new("protect-tag", { "exp-commands_tag-protection.description" })
:add_aliases{ "ptag" }
:add_flags{ "admin_only" }
:register(function(player)
if active_players[player.index] then
active_players[player.index] = nil
return Commands.status.success{ "exp-commands_protected-tags.exit" }
return Commands.status.success{ "exp-commands_tag-protection.exit" }
else
active_players[player.index] = true
return Commands.status.success{ "exp-commands_protected-tags.enter" }
return Commands.status.success{ "exp-commands_tag-protection.enter" }
end
end)
@@ -47,7 +47,7 @@ local function on_chart_tag_added(event)
local tag = event.tag
local player = game.players[event.player_index]
map_tags[tag.force.name .. tag.tag_number] = true
player.print{ "exp-commands_protected-tags.create" }
player.print{ "exp-commands_tag-protection.create" }
end
--- Stop a tag from being edited or removed
@@ -60,7 +60,7 @@ local function on_chart_tag_removed_or_modified(event)
-- Check if the player is in protected mode, and inform them that it was protected
if active_players[event.player_index] then
player.print{ "exp-commands_protected-tags.edit" }
player.print{ "exp-commands_tag-protection.edit" }
return
end
@@ -92,12 +92,12 @@ local function on_chart_tag_removed_or_modified(event)
map_tags[new_tag.force.name .. new_tag.tag_number] = true
end
if Commands.player_has_permission(player, cmd_protected_tag) then
if Commands.player_has_permission(player, cmd_protect_tag) then
-- Player is not in protected mode, but has access to the command
player.print({ "exp-commands_protected-tags.revert-has-access", cmd_protected_tag.name }, Commands.print_settings.error)
player.print({ "exp-commands_tag-protection.revert-has-access", cmd_protect_tag.name }, Commands.print_settings.error)
else
--- Player does not have access to protected mode
player.print({ "exp-commands_protected-tags.revert-no-access" }, Commands.print_settings.error)
player.print({ "exp-commands_tag-protection.revert-no-access" }, Commands.print_settings.error)
end
end

View File

@@ -52,7 +52,7 @@ local function next_color(color, step)
end
--- Sends an rainbow message in the chat
Commands.new("rainbow", { "exp-commands_rainbow" })
Commands.new("rainbow", { "exp-commands_rainbow.description" })
:argument("message", { "exp-commands_rainbow.arg-message" }, Commands.types.string)
:enable_auto_concatenation()
:register(function(player, message)

View File

@@ -4,23 +4,23 @@ Adds a command to calculate the number of machines needed to fulfil a desired pr
local Commands = require("modules/exp_commands")
Commands.new("ratio", { "exp-command_ratio.description" })
:optional("items-per-second", { "exp-command_ratio.arg-items-per-second" }, Commands.types.number)
Commands.new("ratio", { "exp-commands_ratio.description" })
:optional("items-per-second", { "exp-commands_ratio.arg-items-per-second" }, Commands.types.number)
:register(function(player, items_per_second)
--- @cast items_per_second number?
local machine = player.selected
if not machine then
return Commands.status.error{ "exp-command_ratio.not-selecting" }
return Commands.status.error{ "exp-commands_ratio.not-selecting" }
end
if machine.type ~= "assembling-machine" and machine.type ~= "furnace" then
return Commands.status.error{ "exp-command_ratio.not-selecting" }
return Commands.status.error{ "exp-commands_ratio.not-selecting" }
end
local recipe = machine.get_recipe()
if not recipe then
return Commands.status.error{ "exp-command_ratio.not-selecting" }
return Commands.status.error{ "exp-commands_ratio.not-selecting" }
end
local products = recipe.products
@@ -34,7 +34,7 @@ Commands.new("ratio", { "exp-command_ratio.description" })
for _, ingredient in ipairs(ingredients) do
Commands.print{
ingredient.type == "item" and "exp-command_ratio.item-out" or "exp-command_ratio.fluid-out",
ingredient.type == "item" and "exp-commands_ratio.item-out" or "exp-commands_ratio.fluid-out",
math.round(ingredient.amount * crafts_per_second, 3),
ingredient.name
}
@@ -42,13 +42,13 @@ Commands.new("ratio", { "exp-command_ratio.description" })
for i, product in ipairs(products) do
Commands.print{
product.type == "item" and "exp-command_ratio.item-out" or "exp-command_ratio.fluid-out",
product.type == "item" and "exp-commands_ratio.item-out" or "exp-commands_ratio.fluid-out",
math.round(product.amount * crafts_per_second, 3),
product.name
}
end
if amount_of_machines ~= 1 then
Commands.print{ "exp-command_ratio.machine-count", amount_of_machines }
Commands.print{ "exp-commands_ratio.machine-count", amount_of_machines }
end
end)

View File

@@ -125,7 +125,7 @@ end
Commands.new("search", { "exp-commands_search.description-search" })
:argument("item", { "exp-commands_search.arg-item" }, parse_item)
:enable_auto_concatenation()
:add_aliases{ "s" }
:add_aliases{ "si" } -- cant use /s
:register(function(player, item)
--- @cast item LuaItemPrototype
local results = search_players(game.players, item)
@@ -172,7 +172,7 @@ end
Commands.new("search-recent", { "exp-commands_search.description-recent" })
:argument("item", { "exp-commands_search.arg-item" }, parse_item)
:enable_auto_concatenation()
:add_aliases{ "sr" } -- cant use /sc
:add_aliases{ "sr" }
:register(function(player, item)
--- @cast item LuaItemPrototype
local results = search_players(game.players, item)

View File

@@ -17,12 +17,12 @@ Commands.new("spectate", { "exp-commands_spectate.description-spectate" })
--- Enters follow mode for the caller, following the given player.
Commands.new("follow", { "exp-commands_spectate.description-follow" })
:argument("player", { "exp-command_spectate.arg-player" }, Commands.types.player_online)
:argument("player", { "exp-commands_spectate.arg-player" }, Commands.types.player_online)
:add_aliases{ "f" }
:register(function(player, other_player)
--- @cast other_player LuaPlayer
if player == other_player then
return Commands.status.invalid_input{ "exp-command_spectate.follow-self" }
return Commands.status.invalid_input{ "exp-commands_spectate.follow-self" }
else
Spectate.start_follow(player, other_player)
end

View File

@@ -71,7 +71,7 @@ Commands.new("clear-blueprints", { "exp-commands_surface.description-blueprints"
--- Clear all blueprints in a radius around you
Commands.new("clear-blueprints-radius", { "exp-commands_surface.description-radius" })
:argument("radius", { "exp-commands_surface.arg-radius" }, Commands.types.number_range(1, 1000))
:argument("radius", { "exp-commands_surface.arg-radius" }, Commands.types.number_range(1, 100))
:register(function(player, radius)
--- @cast radius number
local player_name = format_player_name(player)

View File

@@ -59,7 +59,7 @@ Commands.new("goto", { "exp-commands_teleport.description-goto" })
--- Teleport to spawn
Commands.new("spawn", { "exp-commands_teleport.description-spawn" })
:optional("player", { "exp-commands_teleport.arg-player-spawn" }, Commands.types.player_alive)
:optional("player", { "exp-commands_teleport.arg-player-from" }, Commands.types.player_alive)
:defaults{
player = function(player)
if player.character and player.character.health > 0 then

View File

@@ -4,9 +4,9 @@ local event_handler = require("event_handler")
local add = event_handler.add_lib
--- Command Extensions
require("modules.exp_scenario/commands/_authorities")
require("modules.exp_scenario/commands/_rcon")
require("modules.exp_scenario/commands/_types")
require("modules/exp_scenario/commands/_authorities")
require("modules/exp_scenario/commands/_rcon")
require("modules/exp_scenario/commands/_types")
--- Commands with events
add(require("modules/exp_scenario/commands/protected_entities"))
@@ -16,7 +16,7 @@ add(require("modules/exp_scenario/commands/research"))
--- Commands
require("modules/exp_scenario/commands/admin_chat")
require("modules/exp_scenario/commands/artillery")
require("modules/exp_scenario/commands/bot_queues")
require("modules/exp_scenario/commands/bot_queue")
require("modules/exp_scenario/commands/cheat")
require("modules/exp_scenario/commands/clear_inventory")
require("modules/exp_scenario/commands/connect")

View File

@@ -17,7 +17,7 @@ enter=Entered artillery selection mode.
exit=Existed artillery selection mode.
[exp-commands_bot-queue]
description-get=Get / Set the construction bot queue limits.
description=Get / Set the construction bot queue limits.
arg-amount=Multiple of default value to set the queues to.
get=Bot queue is __1__ successful attempts and __2__ failed attempts.
set=__1__ set the bot queue to __2__ successful attempts and __3__ failed attempts.
@@ -29,7 +29,7 @@ description-friendly-fire=Set friendly fire for your force, or another force.
description-research-all=Research all technology for your force, or another force.
description-clear-pollution=Clear pollution from your current surface, or another surface.
description-pollution-enabled=Set polution enabled state for this game.
description=game-speed=Set or get the current game speed.
description-game-speed=Set or get the current game speed.
arg-state=State to set, default is to toggle the current value.
arg-player=Player to toggle cheat mode for.
arg-force-friendly-fire=Force to research all technology for.
@@ -62,7 +62,7 @@ same-server=You are already connected to the server: __1__
offline=You cannot connect as the server is currently offline: __1__
none-matching=No servers were found with that name, if you used an address please append true to the end of your command.
[expcom-debug]
[exp-commands_debug]
description=Opens the debug gui.
[exp-commands_enemy]
@@ -115,7 +115,7 @@ description=Sends an action message in the chat.
arg-action=Action you want to perform.
response=* __1__ __2__ *
[expcom-protection]
[exp-commands_entity-protection]
description-entity=Toggles entity protection selection, hold shift to remove protection
description-area=Toggles area protection selection, hold shift to remove protection
enter-entity-selection=Entered entity selection, select entites to protect, hold shift to remove protection.
@@ -129,7 +129,7 @@ protected-area=This area is now protected.
unprotected-area=This area is now unprotected.
repeat-offence=__1__ has removed __2__ at [gps=__3__,__4__]
[exp-commands_protected-tags]
[exp-commands_tag-protection]
description=Toggles protected tag mode, edit and create protected map tags.
exit=You have left protected tag mode, any new tags will not be protected.
enter=You have entered protected tag mode, any new tags will be protected.
@@ -183,14 +183,14 @@ removed-all=__1__ has has all of their reports removed by __2__.
removed=__1__ has a report removed by __2__.
[exp-commands_research]
description-ares=Sets research to be automatically queued.
description=Sets research to be automatically queued.
arg-state=State to set, default is to toggle.
auto-research=__1__ set auto research to __2__
queue=[color=255, 255, 255] Research added to queue - [technology=__1__] - __2__[/color]
[exp-commands_roles]
description-assign-role=Assigns a role to a player.
description-unassign-role=Unassigns a role from a player.
description-assign=Assigns a role to a player.
description-unassign=Unassigns a role from a player.
description-get=Get all roles that a player has, if no player provided it lists all roles.
arg-player-assign=Player to assign the role to.
arg-player-unassign=Player to unassign the role from.
@@ -207,6 +207,7 @@ description-online=Display online players sorted by the quantity of an item held
description-amount=Display players sorted by the quantity of an item held.
description-recent=Display players who hold an item sorted by join time.
invalid-item=No item was found with internal name __1__; try using rich text selection.
arg-item=Item to search for.
no-results=No players have [item=__1__]
title=Players found with [item=__1__]:
result=\n__1__) __2__ has __3__ items. (__4__)
@@ -222,7 +223,7 @@ description-items=Clear all items on the ground.
description-blueprints=Clear all blueprints.
description-radius=Clear all blueprints in an radius around you.
arg-surface=Surface to clear on, default all.
arg-radis=Radius to clear.
arg-radius=Radius to clear.
items-surface=__1__ cleared all items on the ground of __2__.
items-all=__1__ cleared all items on the ground for all surfaces.
blueprints-surface=__1__ cleared all blueprints on __2__.
@@ -241,7 +242,7 @@ description-bring=Teleports a player to you.
description-goto=Teleports you to a player.
description-spawn=Teleport to spawn
arg-player-teleport=Player to teleport, if target is not given then you are teleported to this player.
arg-player-from=Player to teleported.
arg-player-from=Player to teleport.
arg-player-to=Player who is the target.
unavailable=They was a problem teleporting you, likely no position found, please try again later.
same-player=Player can not be teleported to themselves.
@@ -259,7 +260,7 @@ description-clear-script=Clears all script warnings from a player.
description-clear-last=Clears the last warning from a player.
arg-player-create=Player to give the warning to.
arg-player-get=Player to get the warning of, if not given all players are returned.
arg-player=clear=Player to clear the warnings of.
arg-player-clear=Player to clear the warnings of.
arg-reason=Reason the user is receiving a warning.
create=__1__ received a warning from __2__ for __3__.
player-title=__1__ has __2__ warnings and __3__/__4__ script warnings.