mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
Merge Game, FlyingText, Common and table
This commit is contained in:
@@ -3,8 +3,9 @@
|
||||
@commands Admin-Chat
|
||||
]]
|
||||
|
||||
local ExpUtil = require("modules/exp_util")
|
||||
local Commands = require("modules.exp_legacy.expcore.commands") --- @dep expcore.commands
|
||||
local format_chat_player_name = _C.format_chat_player_name --- @dep expcore.common
|
||||
local format_player_name = ExpUtil.format_player_name_locale --- @dep expcore.common
|
||||
require("modules.exp_legacy.config.expcore.command_general_parse")
|
||||
|
||||
--- Sends a message in chat that only admins can see
|
||||
@@ -16,7 +17,7 @@ Commands.new_command("admin-chat", { "expcom-admin-chat.description" }, "Sends a
|
||||
:set_flag("admin_only")
|
||||
:add_alias("ac")
|
||||
:register(function(player, message)
|
||||
local player_name_colour = format_chat_player_name(player)
|
||||
local player_name_colour = format_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 }
|
||||
|
||||
@@ -3,21 +3,26 @@
|
||||
@commands Clear-Inventory
|
||||
]]
|
||||
|
||||
local ExpUtil = require("modules/exp_util")
|
||||
local Commands = require("modules.exp_legacy.expcore.commands") --- @dep expcore.commands
|
||||
local move_items_stack = _C.move_items_stack --- @dep expcore.common
|
||||
require("modules.exp_legacy.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", { "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)
|
||||
local inv = player.get_main_inventory()
|
||||
if not inv then
|
||||
return Commands.error{ "expcore-commands.reject-player-alive" }
|
||||
end
|
||||
move_items_stack(inv)
|
||||
inv.clear()
|
||||
end)
|
||||
:add_param("player", false, "player-role")
|
||||
:add_alias("clear-inv", "move-inventory", "move-inv")
|
||||
:register(function(_, player)
|
||||
local inventory = player.get_main_inventory()
|
||||
if not inventory then
|
||||
return Commands.error{ "expcore-commands.reject-player-alive" }
|
||||
end
|
||||
|
||||
ExpUtil.transfer_inventory_to_surface{
|
||||
inventory = inventory,
|
||||
surface = player.surface,
|
||||
name = "iron-chest",
|
||||
allow_creation = true,
|
||||
}
|
||||
end)
|
||||
|
||||
@@ -3,13 +3,14 @@
|
||||
@commands Interface
|
||||
]]
|
||||
|
||||
local Commands = require("modules.exp_legacy.expcore.commands") --- @dep expcore.commands
|
||||
local ExpUtil = require("modules/exp_util")
|
||||
local Storage = require("modules/exp_util/storage")
|
||||
local Commands = require("modules.exp_legacy.expcore.commands") --- @dep expcore.commands
|
||||
|
||||
-- modules that are loaded into the interface env to be accessed
|
||||
local interface_modules = {
|
||||
["Commands"] = Commands,
|
||||
["output"] = _C.player_return,
|
||||
["output"] = Commands.print,
|
||||
["Group"] = "expcore.permission_groups",
|
||||
["Roles"] = "expcore.roles",
|
||||
["Gui"] = "expcore.gui",
|
||||
@@ -20,7 +21,7 @@ local interface_modules = {
|
||||
-- loads all the modules given in the above table
|
||||
for key, value in pairs(interface_modules) do
|
||||
if type(value) == "string" then
|
||||
interface_modules[key] = _C.opt_require(value)
|
||||
interface_modules[key] = ExpUtil.optional_require(value)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
@commands Jail
|
||||
]]
|
||||
|
||||
local ExpUtil = require("modules/exp_util")
|
||||
local Commands = require("modules.exp_legacy.expcore.commands") --- @dep expcore.commands
|
||||
local Jail = require("modules.exp_legacy.modules.control.jail") --- @dep modules.control.jail
|
||||
local format_chat_player_name = _C.format_chat_player_name --- @dep expcore.common
|
||||
local format_player_name = ExpUtil.format_player_name_locale --- @dep expcore.common
|
||||
require("modules.exp_legacy.config.expcore.command_role_parse")
|
||||
|
||||
--- Puts a player into jail and removes all other roles.
|
||||
@@ -18,8 +19,8 @@ Commands.new_command("jail", { "expcom-jail.description-jail" }, "Puts a player
|
||||
:enable_auto_concat()
|
||||
: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 action_player_name_color = format_player_name(action_player)
|
||||
local by_player_name_color = format_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 }
|
||||
@@ -36,8 +37,8 @@ Commands.new_command("unjail", { "expcom-jail.description-unjail" }, "Removes a
|
||||
:add_alias("clear-jail", "remove-jail")
|
||||
:enable_auto_concat()
|
||||
: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 action_player_name_color = format_player_name(action_player)
|
||||
local by_player_name_color = format_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 }
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
@commands LastLocation
|
||||
]]
|
||||
|
||||
local ExpUtil = require("modules/exp_util")
|
||||
local Commands = require("modules.exp_legacy.expcore.commands") --- @dep expcore.commands
|
||||
local format_chat_player_name = _C.format_chat_player_name --- @dep expcore.common
|
||||
local format_player_name = ExpUtil.format_player_name_locale --- @dep expcore.common
|
||||
require("modules.exp_legacy.config.expcore.command_general_parse")
|
||||
|
||||
--- Get the last location of a player.
|
||||
@@ -14,6 +15,6 @@ Commands.new_command("last-location", { "expcom-lastlocation.description" }, "Se
|
||||
:add_alias("location")
|
||||
:add_param("player", false, "player")
|
||||
:register(function(_, action_player)
|
||||
local action_player_name_color = format_chat_player_name(action_player)
|
||||
local action_player_name_color = format_player_name(action_player)
|
||||
return Commands.success{ "expcom-lastlocation.response", action_player_name_color, string.format("%.1f", action_player.position.x), string.format("%.1f", action_player.position.y) }
|
||||
end)
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
@commands Protection
|
||||
]]
|
||||
|
||||
local ExpUtil = require("modules/exp_util")
|
||||
local Event = require("modules/exp_legacy/utils/event") --- @dep utils.event
|
||||
local Storage = require("modules/exp_util/storage")
|
||||
local Roles = require("modules.exp_legacy.expcore.roles") --- @dep expcore.roles
|
||||
local Commands = require("modules.exp_legacy.expcore.commands") --- @dep expcore.commands
|
||||
local format_chat_player_name = _C.format_chat_player_name --- @dep expcore.common
|
||||
local format_player_name = ExpUtil.format_player_name_locale --- @dep expcore.common
|
||||
local EntityProtection = require("modules.exp_legacy.modules.control.protection") --- @dep modules.control.protection
|
||||
local Selection = require("modules.exp_legacy.modules.control.selection") --- @dep modules.control.selection
|
||||
|
||||
@@ -215,6 +216,6 @@ end)
|
||||
|
||||
--- When there is a repeat offence print it in chat
|
||||
Event.add(EntityProtection.events.on_repeat_violation, function(event)
|
||||
local player_name = format_chat_player_name(event.player_index)
|
||||
local player_name = format_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)
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
@commands Rainbow
|
||||
]]
|
||||
|
||||
local ExpUtil = require("modules/exp_util")
|
||||
local Commands = require("modules.exp_legacy.expcore.commands") --- @dep expcore.commands
|
||||
local format_chat_colour = _C.format_chat_colour --- @dep expcore.common
|
||||
local format_chat_colour = ExpUtil.format_rich_text_color --- @dep expcore.common
|
||||
|
||||
local function step_component(c1, c2)
|
||||
if c1 < 0 then
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
@commands Reports
|
||||
]]
|
||||
|
||||
local ExpUtil = require("modules/exp_util")
|
||||
local Roles = require("modules.exp_legacy.expcore.roles") --- @dep expcore.roles
|
||||
local Commands = require("modules.exp_legacy.expcore.commands") --- @dep expcore.commands
|
||||
local Reports = require("modules.exp_legacy.modules.control.reports") --- @dep modules.control.reports
|
||||
local format_chat_player_name = _C.format_chat_player_name --- @dep expcore.common
|
||||
local format_player_name = ExpUtil.format_player_name_locale --- @dep expcore.common
|
||||
require("modules.exp_legacy.config.expcore.command_general_parse")
|
||||
|
||||
--- Print a message to all players who match the value of admin
|
||||
@@ -38,8 +39,8 @@ Commands.new_command("report", { "expcom-report.description-report" }, "Reports
|
||||
:add_alias("report-player")
|
||||
:enable_auto_concat()
|
||||
: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)
|
||||
local action_player_name_color = format_player_name(action_player)
|
||||
local by_player_name_color = format_player_name(player)
|
||||
if Reports.report_player(action_player, player.name, reason) then
|
||||
print_to_players(false, { "expcom-report.non-admin", action_player_name_color, reason })
|
||||
print_to_players(true, { "expcom-report.admin", action_player_name_color, by_player_name_color, reason })
|
||||
@@ -58,17 +59,17 @@ Commands.new_command("get-reports", { "expcom-report.description-get-reports" },
|
||||
:register(function(_, player)
|
||||
if player then
|
||||
local reports = Reports.get_reports(player)
|
||||
local player_name_color = format_chat_player_name(player)
|
||||
local player_name_color = format_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)
|
||||
local by_player_name_color = format_player_name(player_name)
|
||||
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 in pairs(user_reports) do
|
||||
local player_name_color = format_chat_player_name(player_name)
|
||||
local player_name_color = format_player_name(player_name)
|
||||
local report_count = Reports.count_reports(player_name)
|
||||
Commands.print{ "expcom-report.list", player_name_color, report_count }
|
||||
end
|
||||
@@ -92,7 +93,7 @@ Commands.new_command("clear-reports", { "expcom-report.description-clear-reports
|
||||
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)
|
||||
local action_player_name_color = format_player_name(action_player)
|
||||
local by_player_name_color = format_player_name(player)
|
||||
game.print{ "expcom-report.removed", action_player_name_color, by_player_name_color }
|
||||
end)
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
@commands Roles
|
||||
]]
|
||||
|
||||
local ExpUtil = require("modules/exp_util")
|
||||
local Commands = require("modules.exp_legacy.expcore.commands") --- @dep expcore.commands
|
||||
local Roles = require("modules.exp_legacy.expcore.roles") --- @dep expcore.roles
|
||||
local Colours = require("modules/exp_util/include/color")
|
||||
local format_chat_player_name, format_chat_colour_localized = _C.format_chat_player_name, _C.format_chat_colour_localized
|
||||
local format_player_name, format_color = ExpUtil.format_player_name_locale, ExpUtil.format_rich_text_color
|
||||
|
||||
--- Assigns a role to a player
|
||||
-- @command assign-role
|
||||
@@ -63,11 +64,11 @@ Commands.new_command("list-roles", { "expcom-roles.description-list-roles" }, "L
|
||||
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_color(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)
|
||||
local player_name_colour = format_player_name(player)
|
||||
message = { "expcom-roles.list-player", player_name_colour, role_name }
|
||||
end
|
||||
else
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
@commands InventorySearch
|
||||
]]
|
||||
|
||||
local ExpUtil = require("modules/exp_util")
|
||||
local Commands = require("modules.exp_legacy.expcore.commands") --- @dep expcore.commands
|
||||
local format_number = require("util").format_number --- @dep util
|
||||
local format_chat_player_name = _C.format_chat_player_name --- @dep expcore.common
|
||||
local format_time = _C.format_time
|
||||
local format_player_name = ExpUtil.format_player_name_locale
|
||||
require("modules.exp_legacy.config.expcore.command_general_parse")
|
||||
|
||||
--- Input parse for items by name
|
||||
@@ -85,13 +85,15 @@ local function sort_players(players, func)
|
||||
return sorted
|
||||
end
|
||||
|
||||
local display_players_time_format = ExpUtil.format_time_factory_locale{ format = "short", hours = true, minutes = true }
|
||||
|
||||
--- Display to the player the top players which were found
|
||||
local function display_players(player, players, item)
|
||||
player.print{ "expcom-inv-search.results-heading", item.name }
|
||||
for index, data in ipairs(players) do
|
||||
local player_name_color = format_chat_player_name(data.player)
|
||||
local player_name_color = format_player_name(data.player)
|
||||
local amount = format_number(data.count)
|
||||
local time = format_time(data.online_time)
|
||||
local time = display_players_time_format(data.online_time)
|
||||
player.print{ "expcom-inv-search.results-item", index, player_name_color, amount, time }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,22 +3,28 @@
|
||||
@commands Clear Item On Ground
|
||||
]]
|
||||
|
||||
local copy_items_stack = _C.copy_items_stack --- @dep expcore.common
|
||||
local ExpUtil = require("modules/exp_util")
|
||||
local Commands = require("modules.exp_legacy.expcore.commands") --- @dep expcore.commands
|
||||
require("modules.exp_legacy.config.expcore.command_general_parse")
|
||||
|
||||
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
|
||||
local items = {} --- @type LuaItemStack[]
|
||||
local entities = player.surface.find_entities_filtered{ position = player.position, radius = range, name = "item-on-ground" }
|
||||
for _, e in pairs(entities) do
|
||||
if e.stack then
|
||||
-- calling move_items_stack(e.stack) will crash to desktop
|
||||
-- https://forums.factorio.com/viewtopic.php?f=7&t=110322
|
||||
copy_items_stack{ e.stack }
|
||||
e.stack.clear()
|
||||
items[#items + 1] = e.stack
|
||||
end
|
||||
end
|
||||
|
||||
ExpUtil.move_items_to_surface{
|
||||
items = items,
|
||||
surface = player.surface,
|
||||
allow_creation = true,
|
||||
name = "iron-chest",
|
||||
}
|
||||
|
||||
return Commands.success
|
||||
end)
|
||||
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
@commands Warnings
|
||||
]]
|
||||
|
||||
local ExpUtil = require("modules/exp_util")
|
||||
local Commands = require("modules.exp_legacy.expcore.commands") --- @dep expcore.commands
|
||||
local Warnings = require("modules.exp_legacy.modules.control.warnings") --- @dep modules.control.warnings
|
||||
local format_chat_player_name = _C.format_chat_player_name --- @dep expcore.common
|
||||
local format_player_name = ExpUtil.format_player_name_locale
|
||||
local config = require("modules.exp_legacy.config.warnings") --- @dep config.warnings
|
||||
require("modules.exp_legacy.config.expcore.command_role_parse")
|
||||
|
||||
@@ -20,8 +21,8 @@ Commands.new_command("give-warning", { "expcom-warnings.description-give" }, "Gi
|
||||
:enable_auto_concat()
|
||||
: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)
|
||||
local action_player_name_color = format_player_name(action_player)
|
||||
local by_player_name_color = format_player_name(player)
|
||||
game.print{ "expcom-warnings.received", action_player_name_color, by_player_name_color, reason }
|
||||
end)
|
||||
|
||||
@@ -35,10 +36,10 @@ Commands.new_command("get-warnings", { "expcom-warnings.description-get" }, "Get
|
||||
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)
|
||||
local player_name_color = format_player_name(player)
|
||||
Commands.print{ "expcom-warnings.player", player_name_color, #warnings, #script_warnings, config.temp_warning_limit }
|
||||
for _, warning in ipairs(warnings) do
|
||||
Commands.print{ "expcom-warnings.player-detail", format_chat_player_name(warning.by_player_name), warning.reason }
|
||||
Commands.print{ "expcom-warnings.player-detail", format_player_name(warning.by_player_name), warning.reason }
|
||||
end
|
||||
else
|
||||
local rtn = {}
|
||||
@@ -56,7 +57,7 @@ Commands.new_command("get-warnings", { "expcom-warnings.description-get" }, "Get
|
||||
|
||||
Commands.print{ "expcom-warnings.list-title" }
|
||||
for player_name, warnings in pairs(rtn) do
|
||||
local player_name_color = format_chat_player_name(player_name)
|
||||
local player_name_color = format_player_name(player_name)
|
||||
Commands.print{ "expcom-warnings.list", player_name_color, warnings[1], warnings[2], config.temp_warning_limit }
|
||||
end
|
||||
end
|
||||
@@ -70,7 +71,7 @@ Commands.new_command("clear-warnings", { "expcom-warnings.description-clear" },
|
||||
:register(function(player, action_player)
|
||||
Warnings.clear_warnings(action_player, player.name)
|
||||
Warnings.clear_script_warnings(action_player)
|
||||
local action_player_name_color = format_chat_player_name(action_player)
|
||||
local by_player_name_color = format_chat_player_name(player)
|
||||
local action_player_name_color = format_player_name(action_player)
|
||||
local by_player_name_color = format_player_name(player)
|
||||
game.print{ "expcom-warnings.cleared", action_player_name_color, by_player_name_color }
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user