Update all code styles

This commit is contained in:
Cooldude2606
2024-09-28 01:56:54 +01:00
parent 5e2a62ab27
commit 292c1a1b68
194 changed files with 9817 additions and 9703 deletions

View File

@@ -10,17 +10,18 @@ require("modules.exp_legacy.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', {'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}
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
end
return Commands.success -- prevents command complete message from showing
end)
return Commands.success -- prevents command complete message from showing
end)

View File

@@ -13,7 +13,7 @@ local markers = {} -- Stores all admin markers
--- Storage variables
Storage.register({
admins = admins,
markers = markers
markers = markers,
}, function(tbl)
admins = tbl.admins
markers = tbl.markers
@@ -21,20 +21,20 @@ end)
--- Toggle admin marker mode, can only be applied to yourself
-- @command admin-marker
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)
if admins[player.name] then
-- Exit admin mode
admins[player.name] = nil
return Commands.success{'expcom-admin-marker.exit'}
else
-- Enter admin mode
admins[player.name] = true
return Commands.success{'expcom-admin-marker.enter'}
end
end)
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)
if admins[player.name] then
-- Exit admin mode
admins[player.name] = nil
return Commands.success{ "expcom-admin-marker.exit" }
else
-- Enter admin mode
admins[player.name] = true
return Commands.success{ "expcom-admin-marker.enter" }
end
end)
--- Listen for new map markers being added, add admin marker if done by player in admin mode
Event.add(defines.events.on_chart_tag_added, function(event)
@@ -42,8 +42,8 @@ Event.add(defines.events.on_chart_tag_added, function(event)
local player = game.get_player(event.player_index)
if not admins[player.name] then return end
local tag = event.tag
markers[tag.force.name..tag.tag_number] = true
Commands.print({'expcom-admin-marker.place'}, nil, player)
markers[tag.force.name .. tag.tag_number] = true
Commands.print({ "expcom-admin-marker.place" }, nil, player)
end)
--- Listen for players leaving the game, leave admin mode to avoid unexpected admin markers
@@ -57,30 +57,30 @@ end)
local function maintain_tag(event)
local tag = event.tag
if not event.player_index then return end
if not markers[tag.force.name..tag.tag_number] then return end
if not markers[tag.force.name .. tag.tag_number] then return end
local player = game.get_player(event.player_index)
if player.admin then
-- Player is admin, tell them it was an admin marker
Commands.print({'expcom-admin-marker.edit'}, nil, player)
Commands.print({ "expcom-admin-marker.edit" }, nil, player)
elseif event.name == defines.events.on_chart_tag_modified then
-- Tag was modified, revert the changes
tag.text = event.old_text
tag.last_user = event.old_player
if event.old_icon then tag.icon = event.old_icon end
player.play_sound{path='utility/wire_pickup'}
Commands.print({'expcom-admin-marker.revert'}, nil, player)
player.play_sound{ path = "utility/wire_pickup" }
Commands.print({ "expcom-admin-marker.revert" }, nil, player)
else
-- Tag was removed, remake the tag
player.play_sound{path='utility/wire_pickup'}
Commands.print({'expcom-admin-marker.revert'}, 'orange_red', player)
player.play_sound{ path = "utility/wire_pickup" }
Commands.print({ "expcom-admin-marker.revert" }, "orange_red", player)
local new_tag = tag.force.add_chart_tag(tag.surface, {
last_user = tag.last_user,
position = tag.position,
icon = tag.icon,
text = tag.text,
})
markers[tag.force.name..tag.tag_number] = nil
markers[new_tag.force.name..new_tag.tag_number] = true
markers[tag.force.name .. tag.tag_number] = nil
markers[new_tag.force.name .. new_tag.tag_number] = true
end
end

View File

@@ -6,21 +6,17 @@
local Commands = require("modules.exp_legacy.expcore.commands") --- @dep expcore.commands
require("modules.exp_legacy.config.expcore.command_general_parse")
local Selection = require("modules.exp_legacy.modules.control.selection") --- @dep modules.control.selection
local SelectionArtyArea = 'ArtyArea'
local SelectionArtyArea = "ArtyArea"
local function location_break(player, pos)
if player.force.is_chunk_charted(player.surface, {x=math.floor(pos.left_top.x / 32), y=math.floor(pos.left_top.y / 32)}) then
if player.force.is_chunk_charted(player.surface, { x = math.floor(pos.left_top.x / 32), y = math.floor(pos.left_top.y / 32) }) then
return true
elseif player.force.is_chunk_charted(player.surface, {x=math.floor(pos.left_top.x / 32), y=math.floor(pos.right_bottom.y / 32)}) then
elseif player.force.is_chunk_charted(player.surface, { x = math.floor(pos.left_top.x / 32), y = math.floor(pos.right_bottom.y / 32) }) then
return true
elseif player.force.is_chunk_charted(player.surface, {x=math.floor(pos.right_bottom.x / 32), y=math.floor(pos.left_top.y / 32)}) then
elseif player.force.is_chunk_charted(player.surface, { x = math.floor(pos.right_bottom.x / 32), y = math.floor(pos.left_top.y / 32) }) then
return true
elseif player.force.is_chunk_charted(player.surface, {x=math.floor(pos.right_bottom.x / 32), y=math.floor(pos.right_bottom.y / 32)}) then
elseif player.force.is_chunk_charted(player.surface, { x = math.floor(pos.right_bottom.x / 32), y = math.floor(pos.right_bottom.y / 32) }) then
return true
else
return false
end
@@ -29,8 +25,8 @@ end
--- align an aabb to the grid by expanding it
local function aabb_align_expand(aabb)
return {
left_top = {x = math.floor(aabb.left_top.x), y = math.floor(aabb.left_top.y)},
right_bottom = {x = math.ceil(aabb.right_bottom.x), y = math.ceil(aabb.right_bottom.y)}
left_top = { x = math.floor(aabb.left_top.x), y = math.floor(aabb.left_top.y) },
right_bottom = { x = math.ceil(aabb.right_bottom.x), y = math.ceil(aabb.right_bottom.y) },
}
end
@@ -50,7 +46,7 @@ Selection.on_selection(SelectionArtyArea, function(event)
local count = 0
local hit = {}
for _, e in pairs(player.surface.find_entities_filtered({area=area, type={'unit-spawner', 'turret'}, force='enemy'})) do
for _, e in pairs(player.surface.find_entities_filtered{ area = area, type = { "unit-spawner", "turret" }, force = "enemy" }) do
local skip = false
for _, pos in ipairs(hit) do
@@ -61,7 +57,7 @@ Selection.on_selection(SelectionArtyArea, function(event)
end
if not skip then
player.surface.create_entity{name='artillery-flare', position=e.position, force=player.force, life_time=240, movement={0, 0}, height=0, vertical_speed=0, frame_speed=0}
player.surface.create_entity{ name = "artillery-flare", position = e.position, force = player.force, life_time = 240, movement = { 0, 0 }, height = 0, vertical_speed = 0, frame_speed = 0 }
table.insert(hit, e.position)
count = count + 1
@@ -72,13 +68,13 @@ Selection.on_selection(SelectionArtyArea, function(event)
end
end)
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)
else
Selection.start(player, SelectionArtyArea)
end
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)
else
Selection.start(player, SelectionArtyArea)
end
return Commands.success
end)
return Commands.success
end)

View File

@@ -6,20 +6,20 @@
local Commands = require("modules.exp_legacy.expcore.commands") --- @dep expcore.commands
require("modules.exp_legacy.config.expcore.command_general_parse")
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
local f = player.force.max_failed_attempts_per_tick_per_construction_queue
return Commands.success{'expcom-bot-queue.result', player.name, s, f}
end)
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
local f = player.force.max_failed_attempts_per_tick_per_construction_queue
return Commands.success{ "expcom-bot-queue.result", player.name, s, f }
end)
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)
player.force.max_successful_attempts_per_tick_per_construction_queue = 3 * amount
player.force.max_failed_attempts_per_tick_per_construction_queue = 1 * amount
game.print{'expcom-bot-queue.result', player.name, 3 * amount, 1 * amount}
return Commands.success
end)
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)
player.force.max_successful_attempts_per_tick_per_construction_queue = 3 * amount
player.force.max_failed_attempts_per_tick_per_construction_queue = 1 * amount
game.print{ "expcom-bot-queue.result", player.name, 3 * amount, 1 * amount }
return Commands.success
end)

View File

@@ -9,37 +9,37 @@ require("modules.exp_legacy.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', {'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
end}
:set_flag('admin_only')
:register(function(_, player)
player.cheat_mode = not player.cheat_mode
return Commands.success
end)
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
end }
:set_flag("admin_only")
:register(function(_, player)
player.cheat_mode = not player.cheat_mode
return Commands.success
end)
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)
return player.force
end}
:register(function(player, force)
force.research_all_technologies()
game.print{'expcom-cheat.res', player.name}
return Commands.success
end)
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)
return player.force
end }
:register(function(player, force)
force.research_all_technologies()
game.print{ "expcom-cheat.res", player.name }
return Commands.success
end)
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)
return player.surface
end}
:register(function(player, surface)
surface.always_day = not surface.always_day
game.print{'expcom-cheat.day', player.name, surface.always_day}
return Commands.success
end)
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)
return player.surface
end }
:register(function(player, surface)
surface.always_day = not surface.always_day
game.print{ "expcom-cheat.day", player.name, surface.always_day }
return Commands.success
end)

View File

@@ -10,14 +10,14 @@ 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)
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)

View File

@@ -30,20 +30,20 @@ local function get_server_id(server)
end
if server_count > 1 then
return false, Commands.error{'expcom-connect.too-many-matching', concat(server_names, ', ')}
return false, Commands.error{ "expcom-connect.too-many-matching", concat(server_names, ", ") }
elseif server_count == 1 then
local server_id, server_details = next(servers)
local status = External.get_server_status(server_id)
if server_id == current_server.id then
return false, Commands.error{'expcom-connect.same-server', server_details.name}
elseif status == 'Offline' then
return false, Commands.error{'expcom-connect.offline', server_details.name}
return false, Commands.error{ "expcom-connect.same-server", server_details.name }
elseif status == "Offline" then
return false, Commands.error{ "expcom-connect.offline", server_details.name }
end
return true, server_id
elseif server_count_before > 0 then
return false, Commands.error{'expcom-connect.wrong-version', concat(server_names_before, ', ')}
return false, Commands.error{ "expcom-connect.wrong-version", concat(server_names_before, ", ") }
else
return false, Commands.error{'expcom-connect.none-matching'}
return false, Commands.error{ "expcom-connect.none-matching" }
end
end
@@ -51,57 +51,57 @@ 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', {'expcom-connect.description'}, 'Connect to another server')
:add_param('server')
:add_param('is_address', true, 'boolean')
:add_alias('join', 'server')
:register(function(player, server, is_address)
local server_id = server
if not is_address and External.valid() then
local success, new_server_id = get_server_id(server)
if not success then return new_server_id end
server_id = new_server_id
end
Commands.new_command("connect", { "expcom-connect.description" }, "Connect to another server")
:add_param("server")
:add_param("is_address", true, "boolean")
:add_alias("join", "server")
:register(function(player, server, is_address)
local server_id = server
if not is_address and External.valid() then
local success, new_server_id = get_server_id(server)
if not success then return new_server_id end
server_id = new_server_id
end
Async(request_connection, player, server_id, true)
end)
Async(request_connection, player, server_id, true)
end)
--- Connect a player to a different server
-- @command connect-player
-- @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', {'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')
:register(function(_, player, server, is_address)
local server_id = server
if not is_address and External.valid() then
local success, new_server_id = get_server_id(server)
if not success then return new_server_id end
server_id = new_server_id
end
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")
:register(function(_, player, server, is_address)
local server_id = server
if not is_address and External.valid() then
local success, new_server_id = get_server_id(server)
if not success then return new_server_id end
server_id = new_server_id
end
External.request_connection(player, server_id)
end)
External.request_connection(player, server_id)
end)
--- Connect all players to a different server
-- @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', {'expcom-connect.description-all'}, 'Connect all players to another server')
:add_param('server')
:add_param('is_address', true, 'boolean')
:register(function(_, server, is_address)
local server_id = server
if not is_address and External.valid() then
local success, new_server_id = get_server_id(server)
if not success then return new_server_id end
server_id = new_server_id
end
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)
local server_id = server
if not is_address and External.valid() then
local success, new_server_id = get_server_id(server)
if not success then return new_server_id end
server_id = new_server_id
end
for _, player in pairs(game.connected_players) do
External.request_connection(player, server_id)
end
end)
for _, player in pairs(game.connected_players) do
External.request_connection(player, server_id)
end
end)

View File

@@ -8,7 +8,7 @@ local Commands = require("modules.exp_legacy.expcore.commands") --- @dep expcore
--- Opens the debug pannel for viewing tables.
-- @command debug
Commands.new_command('debug', {'expcom-debug.description'}, 'Opens the debug pannel for viewing tables.')
:register(function(player)
DebugView.open_dubug(player)
end)
Commands.new_command("debug", { "expcom-debug.description" }, "Opens the debug pannel for viewing tables.")
:register(function(player)
DebugView.open_dubug(player)
end)

View File

@@ -6,24 +6,24 @@
local Commands = require("modules.exp_legacy.expcore.commands") --- @dep expcore.commands
require("modules.exp_legacy.config.expcore.command_general_parse")
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("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', {'expcom-enemy.description-remove'}, 'Remove biters and prevent generation')
:set_flag('admin_only')
:add_param('surface', true, 'surface')
:set_defaults{surface=function(player)
return player.surface
end}
:register(function(_, surface)
for _, entity in pairs(surface.find_entities_filtered({force='enemy'})) do
entity.destroy()
end
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)
return player.surface
end }
:register(function(_, surface)
for _, entity in pairs(surface.find_entities_filtered{ force = "enemy" }) do
entity.destroy()
end
surface.map_gen_settings.autoplace_controls['enemy-base'].size = 'none'
return Commands.success
end)
surface.map_gen_settings.autoplace_controls["enemy-base"].size = "none"
return Commands.success
end)

View File

@@ -9,11 +9,11 @@ require("modules.exp_legacy.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', {'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)
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)

View File

@@ -7,13 +7,13 @@ local Commands = require("modules.exp_legacy.expcore.commands") --- @dep expcore
require("modules.exp_legacy.config.expcore.command_general_parse")
-- For Modded Server Use
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
end}
:register(function(player, force)
force.friendly_fire = not force.friendly_fire
game.print{'expcom-ff.ff', player.name, force.friendly_fire}
return Commands.success
end)
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
end }
:register(function(player, force)
force.friendly_fire = not force.friendly_fire
game.print{ "expcom-ff.ff", player.name, force.friendly_fire }
return Commands.success
end)

View File

@@ -18,78 +18,77 @@ 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', {'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
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
-- 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
if page_count >= results_per_page then
page_count = 0
current_page = current_page + 1
table.insert(pages, {})
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
if page_count >= results_per_page then
page_count = 0
current_page = current_page + 1
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], {
"expcom-chelp.format",
command_data.name,
command_data.description,
command_data.help,
alias_format,
})
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], {
'expcom-chelp.format',
command_data.name,
command_data.description,
command_data.help,
alias_format
})
end
-- adds the result to the cache
search_cache[player_index] = {
keyword=keyword:lower(),
pages=pages,
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)
-- adds the result to the cache
search_cache[player_index] = {
keyword = keyword:lower(),
pages = pages,
found = found,
}
end
Commands.print({'expcom-chelp.footer', found, page, #pages}, 'cyan')
-- print the requested page
keyword = keyword == "" and "<all>" or keyword
Commands.print({ "expcom-chelp.title", keyword }, "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)
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

View File

@@ -14,7 +14,7 @@ end)
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)
@@ -23,61 +23,61 @@ end
local function floor_pos(position)
return {
x=math.floor(position.x),
y=math.floor(position.y)
x = math.floor(position.x),
y = math.floor(position.y),
}
end
--- Teleports you to your home location
-- @command home
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
return Commands.error{'expcom-home.no-home'}
end
local rtn = floor_pos(player.position)
teleport(player, home[1])
home[2] = rtn
Commands.print{'expcom-home.return-set', rtn.x, rtn.y}
end)
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
return Commands.error{ "expcom-home.no-home" }
end
local rtn = floor_pos(player.position)
teleport(player, home[1])
home[2] = rtn
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', {'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
home = {}
homes[player.index] = home
end
local pos = floor_pos(player.position)
home[1] = pos
Commands.print{'expcom-home.home-set', pos.x, pos.y}
end)
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
home = {}
homes[player.index] = home
end
local pos = floor_pos(player.position)
home[1] = pos
Commands.print{ "expcom-home.home-set", pos.x, pos.y }
end)
--- Returns your current home location
-- @command home-get
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
return Commands.error{'expcom-home.no-home'}
end
local pos = home[1]
Commands.print{'expcom-home.home-get', pos.x, pos.y}
end)
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
return Commands.error{ "expcom-home.no-home" }
end
local pos = home[1]
Commands.print{ "expcom-home.home-get", pos.x, pos.y }
end)
--- Teleports you to previous location
-- @command return
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
return Commands.error{'expcom-home.no-return'}
end
local rtn = floor_pos(player.position)
teleport(player, home[2])
home[2] = rtn
Commands.print{'expcom-home.return-set', rtn.x, rtn.y}
end)
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
return Commands.error{ "expcom-home.no-return" }
end
local rtn = floor_pos(player.position)
teleport(player, home[2])
home[2] = rtn
Commands.print{ "expcom-home.return-set", rtn.x, rtn.y }
end)

View File

@@ -8,18 +8,18 @@ local Storage = require("modules/exp_util/storage")
-- modules that are loaded into the interface env to be accessed
local interface_modules = {
['Commands'] = Commands,
['output'] = _C.player_return,
['Group'] = 'expcore.permission_groups',
['Roles'] = 'expcore.roles',
['Gui'] = 'expcore.gui',
['Datastore'] = 'expcore.datastore',
['External'] = 'expcore.external'
["Commands"] = Commands,
["output"] = _C.player_return,
["Group"] = "expcore.permission_groups",
["Roles"] = "expcore.roles",
["Gui"] = "expcore.gui",
["Datastore"] = "expcore.datastore",
["External"] = "expcore.external",
}
-- loads all the modules given in the above table
for key, value in pairs(interface_modules) do
if type(value) == 'string' then
if type(value) == "string" then
interface_modules[key] = _C.opt_require(value)
end
end
@@ -42,7 +42,7 @@ end
-- @tparam string name The name that the value is assigned to
-- @tparam function callback The function that will be called to get the value
local function add_interface_callback(name, callback)
if type(callback) == 'function' then
if type(callback) == "function" then
interface_callbacks[name] = callback
end
end
@@ -61,55 +61,55 @@ 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', {'expcom-interface.description'}, 'Sends an invocation to be ran and returns the result.')
:add_param('invocation', false)
:enable_auto_concat()
:set_flag('admin_only')
:register(function(player, invocation)
-- If the invocation has no white space then prepend return to it
if not invocation:find('%s') and not invocation:find('return') then
invocation = 'return '..invocation
end
-- _env will be the new _ENV that the invocation will run inside of
local _env = setmetatable({}, {
__index = get_index,
__newindex = interface_env
})
-- If the command is ran by a player then load the dynamic values
if player then
for name, callback in pairs(interface_callbacks) do
local _, rtn = pcall(callback, player)
rawset(_env, name, rtn)
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")
:register(function(player, invocation)
-- If the invocation has no white space then prepend return to it
if not invocation:find("%s") and not invocation:find("return") then
invocation = "return " .. invocation
end
end
-- Compile the invocation with the custom _env value
local invocation_func, compile_error = load(invocation, 'interface', nil, _env)
if compile_error then return Commands.error(compile_error) end
-- _env will be the new _ENV that the invocation will run inside of
local _env = setmetatable({}, {
__index = get_index,
__newindex = interface_env,
})
-- Run the invocation
local success, rtn = pcall(invocation_func)
if not success then
local err = rtn:gsub('%.%.%..-/temp/currently%-playing', '')
return Commands.error(err)
end
return Commands.success(rtn)
end)
-- If the command is ran by a player then load the dynamic values
if player then
for name, callback in pairs(interface_callbacks) do
local _, rtn = pcall(callback, player)
rawset(_env, name, rtn)
end
end
-- Compile the invocation with the custom _env value
local invocation_func, compile_error = load(invocation, "interface", nil, _env)
if compile_error then return Commands.error(compile_error) end
-- Run the invocation
local success, rtn = pcall(invocation_func)
if not success then
local err = rtn:gsub("%.%.%..-/temp/currently%-playing", "")
return Commands.error(err)
end
return Commands.success(rtn)
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)
-- Module Return
return {
add_interface_module = add_interface_module,
add_interface_callback = add_interface_callback,
interface_env = interface_env,
clean_stack_trace = function(str) return str:gsub('%.%.%..-/temp/currently%-playing', '') end
clean_stack_trace = function(str) return str:gsub("%.%.%..-/temp/currently%-playing", "") end,
}

View File

@@ -12,36 +12,36 @@ require("modules.exp_legacy.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', {'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()
: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}
else
return Commands.error{'expcom-jail.already-jailed', action_player_name_color}
end
end)
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()
: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 }
else
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', {'expcom-jail.description-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)
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}
else
return Commands.error{'expcom-jail.not-jailed', action_player_name_color}
end
end)
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()
: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 }
else
return Commands.error{ "expcom-jail.not-jailed", action_player_name_color }
end
end)

View File

@@ -11,26 +11,24 @@ require("modules.exp_legacy.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', {'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
if player.character and player.character.health > 0 then
return player
end
end}
: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
action_player.character.die()
else
return Commands.error{'expcore-commands.unauthorized'}
end
end)
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
if player.character and player.character.health > 0 then
return player
end
end }
: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
action_player.character.die()
else
return Commands.error{ "expcore-commands.unauthorized" }
end
end)

View File

@@ -10,10 +10,10 @@ require("modules.exp_legacy.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', {'expcom-lastlocation.description'}, 'Sends you the last location of a player')
:add_alias('location')
:add_param('player', false, 'player')
:register(function(_, action_player)
local action_player_name_color = format_chat_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)
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)
local action_player_name_color = format_chat_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)

View File

@@ -8,10 +8,10 @@ local Commands = require("modules.exp_legacy.expcore.commands") --- @dep expcore
--- Sends an action message in the chat
-- @command me
-- @tparam string action the action that follows your name in 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)
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)

View File

@@ -6,29 +6,29 @@
local Commands = require("modules.exp_legacy.expcore.commands") --- @dep expcore.commands
require("modules.exp_legacy.config.expcore.command_general_parse")
Commands.new_command('pollution-clear', {'expcom-pol.description-clr'}, 'Clear pollution')
:set_flag('admin_only')
:add_alias('pol-clr')
:add_param('surface', true, 'surface')
:set_defaults{surface=function(player)
return player.surface
end}
:register(function(player, surface)
surface.clear_pollution()
game.print{'expcom-pol.clr', player.name}
return Commands.success
end)
Commands.new_command("pollution-clear", { "expcom-pol.description-clr" }, "Clear pollution")
:set_flag("admin_only")
:add_alias("pol-clr")
:add_param("surface", true, "surface")
:set_defaults{ surface = function(player)
return player.surface
end }
:register(function(player, surface)
surface.clear_pollution()
game.print{ "expcom-pol.clr", player.name }
return Commands.success
end)
Commands.new_command('pollution-off', {'expcom-pol.description-off'}, 'Disable pollution')
:set_flag('admin_only')
:add_alias('pol-off')
:register(function(player)
game.map_settings.pollution.enabled = false
Commands.new_command("pollution-off", { "expcom-pol.description-off" }, "Disable pollution")
:set_flag("admin_only")
:add_alias("pol-off")
:register(function(player)
game.map_settings.pollution.enabled = false
for _, v in pairs(game.surfaces) do
v.clear_pollution()
end
for _, v in pairs(game.surfaces) do
v.clear_pollution()
end
game.print{'expcom-pol.off', player.name}
return Commands.success
end)
game.print{ "expcom-pol.off", player.name }
return Commands.success
end)

View File

@@ -11,12 +11,12 @@ local format_chat_player_name = _C.format_chat_player_name --- @dep expcore.comm
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
local SelectionProtectEntity = 'ProtectEntity'
local SelectionProtectArea = 'ProtectArea'
local SelectionProtectEntity = "ProtectEntity"
local SelectionProtectArea = "ProtectArea"
local renders = {} -- Stores all renders for a player
Storage.register({
renders = renders
renders = renders,
}, function(tbl)
renders = tbl.renders
end)
@@ -36,19 +36,19 @@ end
--- Align an aabb to the grid by expanding it
local function aabb_align_expand(aabb)
return {
left_top = {x = math.floor(aabb.left_top.x), y = math.floor(aabb.left_top.y)},
right_bottom = {x = math.ceil(aabb.right_bottom.x), y = math.ceil(aabb.right_bottom.y)}
left_top = { x = math.floor(aabb.left_top.x), y = math.floor(aabb.left_top.y) },
right_bottom = { x = math.ceil(aabb.right_bottom.x), y = math.ceil(aabb.right_bottom.y) },
}
end
--- Get the key used in protected_entities
local function get_entity_key(entity)
return string.format('%i,%i', math.floor(entity.position.x), math.floor(entity.position.y))
return string.format("%i,%i", math.floor(entity.position.x), math.floor(entity.position.y))
end
--- Get the key used in protected_areas
local function get_area_key(area)
return string.format('%i,%i', math.floor(area.left_top.x), math.floor(area.left_top.y))
return string.format("%i,%i", math.floor(area.left_top.x), math.floor(area.left_top.y))
end
--- Show a protected entity to a player
@@ -57,16 +57,16 @@ local function show_protected_entity(player, entity)
if renders[player.index][key] then return end
local rb = entity.selection_box.right_bottom
local render_id = rendering.draw_sprite{
sprite = 'utility/notification',
sprite = "utility/notification",
target = entity,
target_offset = {
(rb.x-entity.position.x)*0.75,
(rb.y-entity.position.y)*0.75
(rb.x - entity.position.x) * 0.75,
(rb.y - entity.position.y) * 0.75,
},
x_scale = 2,
y_scale = 2,
surface = entity.surface,
players = { player }
players = { player },
}
renders[player.index][key] = render_id
end
@@ -76,13 +76,13 @@ local function show_protected_area(player, surface, area)
local key = get_area_key(area)
if renders[player.index][key] then return end
local render_id = rendering.draw_rectangle{
color = {1, 1, 0, 0.5},
color = { 1, 1, 0, 0.5 },
filled = false,
width = 3,
left_top = area.left_top,
right_bottom = area.right_bottom,
surface = surface,
players = { player }
players = { player },
}
renders[player.index][key] = render_id
end
@@ -96,29 +96,29 @@ end
--- Toggles entity protection selection
-- @command protect-entity
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
Selection.stop(player)
else
Selection.start(player, SelectionProtectEntity)
return Commands.success{'expcom-protection.entered-entity-selection'}
end
end)
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
Selection.stop(player)
else
Selection.start(player, SelectionProtectEntity)
return Commands.success{ "expcom-protection.entered-entity-selection" }
end
end)
--- Toggles area protection selection
-- @command protect-area
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
Selection.stop(player)
else
Selection.start(player, SelectionProtectArea)
return Commands.success{'expcom-protection.entered-area-selection'}
end
end)
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
Selection.stop(player)
else
Selection.start(player, SelectionProtectArea)
return Commands.success{ "expcom-protection.entered-area-selection" }
end
end)
--- When an area is selected to add protection to entities
Selection.on_selection(SelectionProtectEntity, function(event)
@@ -127,7 +127,8 @@ Selection.on_selection(SelectionProtectEntity, function(event)
EntityProtection.add_entity(entity)
show_protected_entity(player, entity)
end
player.print{'expcom-protection.protected-entities', #event.entities}
player.print{ "expcom-protection.protected-entities", #event.entities }
end)
--- When an area is selected to remove protection from entities
@@ -137,7 +138,8 @@ Selection.on_alt_selection(SelectionProtectEntity, function(event)
EntityProtection.remove_entity(entity)
remove_render(player, get_entity_key(entity))
end
player.print{'expcom-protection.unprotected-entities', #event.entities}
player.print{ "expcom-protection.unprotected-entities", #event.entities }
end)
--- When an area is selected to add protection to the area
@@ -147,12 +149,13 @@ Selection.on_selection(SelectionProtectArea, function(event)
local player = game.get_player(event.player_index)
for _, next_area in pairs(areas) do
if aabb_area_enclosed(area, next_area) then
return player.print{'expcom-protection.already-protected'}
return player.print{ "expcom-protection.already-protected" }
end
end
EntityProtection.add_area(event.surface, area)
show_protected_area(player, event.surface, area)
player.print{'expcom-protection.protected-area'}
player.print{ "expcom-protection.protected-area" }
end)
--- When an area is selected to remove protection from the area
@@ -163,7 +166,7 @@ Selection.on_alt_selection(SelectionProtectArea, function(event)
for _, next_area in pairs(areas) do
if aabb_area_enclosed(next_area, area) then
EntityProtection.remove_area(event.surface, next_area)
player.print{'expcom-protection.unprotected-area'}
player.print{ "expcom-protection.unprotected-area" }
remove_render(player, get_area_key(next_area))
end
end
@@ -180,6 +183,7 @@ Event.add(Selection.events.on_player_selection_start, function(event)
for _, entity in pairs(entities) do
show_protected_entity(player, entity)
end
-- Show always protected entities by name
if #EntityProtection.protected_entity_names > 0 then
for _, entity in pairs(surface.find_entities_filtered{ name = EntityProtection.protected_entity_names, force = player.force }) do
@@ -205,11 +209,12 @@ Event.add(Selection.events.on_player_selection_end, function(event)
for _, id in pairs(renders[event.player_index]) do
if rendering.is_valid(id) then rendering.destroy(id) end
end
renders[event.player_index] = nil
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)
Roles.print_to_roles_higher('Regular', {'expcom-protection.repeat-offence', player_name, event.entity.localised_name, event.entity.position.x, event.entity.position.y})
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)

View File

@@ -8,9 +8,9 @@ local format_chat_colour = _C.format_chat_colour --- @dep expcore.common
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
end
@@ -25,17 +25,17 @@ local function step_color(color)
end
local function next_color(color, step)
step = step or 0.1
local new_color = {r=0, g=0, b=0}
step = step or 0.1
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
new_color.r = color.r - step
new_color.g = color.g + step
elseif color.r == 0 and color.g ~= 0 then
new_color.g = color.g-step
new_color.b = color.b+step
new_color.g = color.g - step
new_color.b = color.b + step
elseif color.g == 0 and color.b ~= 0 then
new_color.b = color.b-step
new_color.r = color.r+step
new_color.b = color.b - step
new_color.r = color.r + step
end
return step_color(new_color)
end
@@ -43,20 +43,20 @@ 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', {'expcom-rainbow.description'}, 'Sends an rainbow message in the chat')
:add_param('message', false)
:enable_auto_concat()
: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)
return rtn
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)
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)
return rtn
end)
game.print(output)
end)
game.print(output)
end)

View File

@@ -1,86 +1,83 @@
local Commands = require("modules.exp_legacy.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 effect2 = moduleInventory.get_item_count("productivity-module-2") -- type 2
local effect3 = moduleInventory.get_item_count("productivity-module-3") -- type 3
local multi = effect1*4+effect2*6+effect3*10
return multi/100+1
local multi = effect1 * 4 + effect2 * 6 + effect3 * 10
return multi / 100 + 1
end
local function AmountOfMachines(itemsPerSecond, output)
if(itemsPerSecond) then
return itemsPerSecond/output
if (itemsPerSecond) then
return itemsPerSecond / output
end
end
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
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'
if not machine then -- nil check
return Commands.error{ "expcom-ratio.notSelecting" }
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'
if machine.type ~= "assembling-machine" and machine.type ~= "furnace" then
return Commands.error{ "expcom-ratio.notSelecting" }
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
local recipe = machine.get_recipe() -- recipe
end
if not recipe then -- nil check
return Commands.error{ "expcom-ratio.notSelecting" }
end
if amountOfMachines ~= 1 then
Commands.print{'expcom-ratio.machines', amountOfMachines}
end
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
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)

View File

@@ -11,42 +11,42 @@ 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', {'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
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}}
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
if ghost.valid then
local x = ghost.position.x-center.x
local y = ghost.position.y-center.y
if x^2+y^2 <= range2 then
if config.allow_blueprint_repair or ghost.time_to_live ~= max_time_to_live then
revive_count = revive_count+1
if not config.disallow[ghost.ghost_name] then ghost.revive() end
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
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 } }
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
if ghost.valid then
local x = ghost.position.x - center.x
local y = ghost.position.y - center.y
if x ^ 2 + y ^ 2 <= range2 then
if config.allow_blueprint_repair or ghost.time_to_live ~= max_time_to_live then
revive_count = revive_count + 1
if not config.disallow[ghost.ghost_name] then ghost.revive() end
end
end
end
end
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
if entity.valid then
local x = entity.position.x-center.x
local y = entity.position.y-center.y
if entity.health and entity.get_health_ratio() ~= 1 and x^2+y^2 <= range2 then
heal_count = heal_count+1
entity.health = max_time_to_live
if config.allow_heal_entities then
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
if entity.health and entity.get_health_ratio() ~= 1 and x ^ 2 + y ^ 2 <= range2 then
heal_count = heal_count + 1
entity.health = max_time_to_live
end
end
end
end
end
return Commands.success{'expcom-repair.result', revive_count, heal_count}
end)
return Commands.success{ "expcom-repair.result", revive_count, heal_count }
end)

View File

@@ -6,7 +6,7 @@
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_chat_player_name = _C.format_chat_player_name --- @dep expcore.common
require("modules.exp_legacy.config.expcore.command_general_parse")
--- Print a message to all players who match the value of admin
@@ -22,76 +22,77 @@ 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', {'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
if Roles.player_has_flag(input, 'report-immune') then
return reject{'expcom-report.player-immune'}
elseif player == input then
return reject{'expcom-report.self-report'}
else
return input
end
end)
:add_param('reason', false)
: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)
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})
else
return Commands.error{'expcom-report.already-reported'}
end
end)
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
if Roles.player_has_flag(input, "report-immune") then
return reject{ "expcom-report.player-immune" }
elseif player == input then
return reject{ "expcom-report.self-report" }
else
return input
end
end)
:add_param("reason", false)
: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)
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 })
else
return Commands.error{ "expcom-report.already-reported" }
end
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', {'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)
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.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)
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 }
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 report_count = Reports.count_reports(player_name)
Commands.print{ "expcom-report.list", player_name_color, report_count }
end
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 report_count = Reports.count_reports(player_name)
Commands.print{'expcom-report.list', player_name_color, report_count}
end
end
end)
end)
--- Clears all reports from a player or just the report from one player.
-- @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', {'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)
if from_player then
if not Reports.remove_report(action_player, from_player.name, player.name) then
return Commands.error{'expcom-report.not-reported'}
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)
if from_player 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
return Commands.error{ "expcom-report.not-reported" }
end
end
else
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}
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 }
end)

View File

@@ -10,35 +10,35 @@ end)
local function res_queue(force, by_script)
local res_q = force.research_queue
local res = force.technologies['mining-productivity-4']
local res = force.technologies["mining-productivity-4"]
if #res_q < config.queue_amount then
for i=1, config.queue_amount - #res_q do
for i = 1, config.queue_amount - #res_q do
force.add_research(res)
if not (by_script) then
game.print{'expcom-res.inf-q', res.name, res.level + i}
game.print{ "expcom-res.inf-q", res.name, res.level + i }
end
end
end
end
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
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
if research.res_queue_enable then
res_queue(player.force, true)
end
if research.res_queue_enable then
res_queue(player.force, true)
end
game.print{'expcom-res.res', player.name, research.res_queue_enable}
return Commands.success
end)
game.print{ "expcom-res.res", player.name, research.res_queue_enable }
return Commands.success
end)
Event.add(defines.events.on_research_finished, function(event)
if research.res_queue_enable then
if event.research.force.rockets_launched > 0 and event.research.force.technologies['mining-productivity-4'].level > 4 then
if event.research.force.rockets_launched > 0 and event.research.force.technologies["mining-productivity-4"].level > 4 then
res_queue(event.research.force, event.by_script)
end
end

View File

@@ -12,70 +12,68 @@ 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', {'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)
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
end)
if player_highest.index < role.index then
Roles.assign_player(action_player, role, player.name)
else
return Commands.error{ "expcom-roles.higher-role" }
end
end)
--- Unassigns a role from a player
-- @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', {'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)
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
end)
if player_highest.index < role.index then
Roles.unassign_player(action_player, role, player.name)
else
return Commands.error{ "expcom-roles.higher-role" }
end
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', {'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'}
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}
if player then
roles = Roles.get_player_roles(player)
end
end
return Commands.success(message)
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)

View File

@@ -12,19 +12,19 @@ require("modules.exp_legacy.config.expcore.command_general_parse")
--- Input parse for items by name
local function item_parse(input, _, reject)
if input == nil then return end
local lower_input = input:lower():gsub(' ', '-')
local lower_input = input:lower():gsub(" ", "-")
-- Simple Case - internal name is given
local item = prototypes.item[lower_input]
if item then return item end
-- Second Case - rich text is given
local item_name = input:match('%[item=([0-9a-z-]+)%]')
local item_name = input:match("%[item=([0-9a-z-]+)%]")
item = prototypes.item[item_name]
if item then return item end
-- No item found, we do not attempt to search all prototypes as this will be expensive
return reject{'expcom-inv-search.reject-item', lower_input}
return reject{ "expcom-inv-search.reject-item", lower_input }
end
--- Search all players for this item
@@ -37,7 +37,7 @@ local function search_players(players, item)
local item_count = player.get_item_count(item.name)
if item_count > 0 then
-- Add the player to the array as they have the item
found[head] = { player=player, count=item_count, online_time=player.online_time }
found[head] = { player = player, count = item_count, online_time = player.online_time }
head = head + 1
end
end
@@ -66,9 +66,10 @@ local function sort_players(players, func)
break
end
end
-- Insert the element, this can only be called when index <= 5
if not inserted then
sorted[#sorted+1] = player
sorted[#sorted + 1] = player
end
-- Update the threshold
if sorted[6] then
@@ -86,12 +87,12 @@ end
--- 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}
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 amount = format_number(data.count)
local time = format_time(data.online_time)
player.print{'expcom-inv-search.results-item', index, player_name_color, amount, time}
player.print{ "expcom-inv-search.results-item", index, player_name_color, amount, time }
end
end
@@ -103,16 +104,16 @@ 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', {'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()
:register(function(player, item)
local players = search_players(game.players, item)
if #players == 0 then return {'expcom-inv-search.results-none', item.name} end
local top_players = sort_players(players, amount_sort)
display_players(player, top_players, item)
end)
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()
:register(function(player, item)
local players = search_players(game.players, item)
if #players == 0 then return { "expcom-inv-search.results-none", item.name } end
local top_players = sort_players(players, amount_sort)
display_players(player, top_players, item)
end)
--- Return the index of the player, higher means they joined more recently
local function recent_sort(data)
@@ -122,46 +123,46 @@ 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', {'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()
:register(function(player, item)
local players = search_players(game.players, item)
if #players == 0 then return {'expcom-inv-search.results-none', item.name} end
local top_players = sort_players(players, recent_sort)
display_players(player, top_players, item)
end)
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()
:register(function(player, item)
local players = search_players(game.players, item)
if #players == 0 then return { "expcom-inv-search.results-none", item.name } end
local top_players = sort_players(players, recent_sort)
display_players(player, top_players, item)
end)
--- Return the the amount of an item a player has divided by their playtime
local function combined_sort(data)
return data.count/data.online_time
return data.count / data.online_time
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', {'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()
:register(function(player, item)
local players = search_players(game.players, item)
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)
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()
:register(function(player, item)
local players = search_players(game.players, item)
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)
--- 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', {'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()
:register(function(player, item)
local players = search_players(game.connected_players, item)
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)
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()
:register(function(player, item)
local players = search_players(game.connected_players, item)
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)

View File

@@ -9,7 +9,7 @@ local Roles = require("modules.exp_legacy.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)
-- return false if no new position
if not position then
return false
@@ -39,29 +39,28 @@ 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', {'expcom-spawn.description'}, '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
return player
Commands.new_command("go-to-spawn", { "expcom-spawn.description" }, "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
return player
end
end,
}
: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
if not teleport(action_player) then
return Commands.error{ "expcom-spawn.unavailable" }
end
else
return Commands.error{ "expcore-commands.unauthorized" }
end
end
}
: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
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,26 +9,25 @@ require("modules.exp_legacy.config.expcore.command_general_parse")
--- Toggles spectator mode for the caller
-- @command spectate
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
end)
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
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', {'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)
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)

View File

@@ -6,11 +6,11 @@
local Commands = require("modules.exp_legacy.expcore.commands") --- @dep expcore.commands
require("modules.exp_legacy.config.expcore.command_general_parse")
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)
game.speed = math.round(amount, 3)
game.print{'expcom-speed.result', player.name, string.format('%.3f', amount)}
return Commands.success
end)
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)
game.speed = math.round(amount, 3)
game.print{ "expcom-speed.result", player.name, string.format("%.3f", amount) }
return Commands.success
end)

View File

@@ -7,27 +7,27 @@ local copy_items_stack = _C.copy_items_stack --- @dep expcore.common
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
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()
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
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()
end
end
end
return Commands.success
end)
return Commands.success
end)
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
e.destroy()
end
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
e.destroy()
end
return Commands.success
end)
return Commands.success
end)

View File

@@ -8,7 +8,7 @@ require("modules.exp_legacy.config.expcore.command_general_parse")
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)
-- return false if no new position
if not position then
@@ -41,53 +41,53 @@ 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', {'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')
:set_flag('admin_only')
: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
-- return if the teleport failed
return Commands.error{'expcom-tp.no-position-found'}
end
end)
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")
:set_flag("admin_only")
: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
-- return if the teleport failed
return Commands.error{ "expcom-tp.no-position-found" }
end
end)
--- Teleports a player to you.
-- @command bring
-- @tparam LuaPlayer player the player that will be teleported, must be alive
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)
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
-- return if the teleport failed
return Commands.error{'expcom-tp.no-position-found'}
end
from_player.print('Come here my friend')
end)
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)
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
-- return if the teleport failed
return Commands.error{ "expcom-tp.no-position-found" }
end
from_player.print("Come here my friend")
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', {'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)
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
-- return if the teleport failed
return Commands.error{'expcom-tp.no-position-found'}
end
end)
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)
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
-- return if the teleport failed
return Commands.error{ "expcom-tp.no-position-found" }
end
end)

View File

@@ -7,17 +7,17 @@ local Commands = require("modules.exp_legacy.expcore.commands") --- @dep expcore
require("modules.exp_legacy.config.expcore.command_general_parse")
local format_number = require("util").format_number
Commands.new_command('set-trains-to-automatic', {'expcom-train.description'}, 'Set All Trains to Automatic')
:register(function(player)
local count = 0
Commands.new_command("set-trains-to-automatic", { "expcom-train.description" }, "Set All Trains to Automatic")
:register(function(player)
local count = 0
for _, v in pairs(player.force.get_trains()) do
if v.manual_mode then
count = count + 1
v.manual_mode = false
for _, v in pairs(player.force.get_trains()) do
if v.manual_mode then
count = count + 1
v.manual_mode = false
end
end
end
game.print{'expcom-train.manual-result', player.name, format_number(count)}
return Commands.success
end)
game.print{ "expcom-train.manual-result", player.name, format_number(count) }
return Commands.success
end)

View File

@@ -5,11 +5,11 @@ local Commands = require("modules.exp_legacy.expcore.commands") --- @dep expcore
require("modules.exp_legacy.config.expcore.command_general_parse")
local vlayer = require("modules.exp_legacy.modules.control.vlayer")
Commands.new_command('vlayer-info', {'vlayer.description-vi'}, 'Vlayer Info')
:register(function(_)
local c = vlayer.get_circuits()
Commands.new_command("vlayer-info", { "vlayer.description-vi" }, "Vlayer Info")
:register(function(_)
local c = vlayer.get_circuits()
for k, v in pairs(c) do
Commands.print(v .. ' : ' .. k)
end
end)
for k, v in pairs(c) do
Commands.print(v .. " : " .. k)
end
end)

View File

@@ -13,62 +13,64 @@ require("modules.exp_legacy.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', {'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')
: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)
game.print{'expcom-warnings.received', action_player_name_color, by_player_name_color, reason}
end)
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")
: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)
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', {'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)
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}
for _, warning in ipairs(warnings) do
Commands.print{'expcom-warnings.player-detail', format_chat_player_name(warning.by_player_name), warning.reason}
end
else
local rtn = {}
local user_script_warnings = Warnings.user_script_warnings
for player_name, warnings in pairs(Warnings.user_warnings:get_all()) do
rtn[player_name] = {#warnings, 0}
end
for player_name, warnings in pairs(user_script_warnings) do
if not rtn[player_name] then
rtn[player_name] = {0, 0}
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)
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 }
for _, warning in ipairs(warnings) do
Commands.print{ "expcom-warnings.player-detail", format_chat_player_name(warning.by_player_name), warning.reason }
end
else
local rtn = {}
local user_script_warnings = Warnings.user_script_warnings
for player_name, warnings in pairs(Warnings.user_warnings:get_all()) do
rtn[player_name] = { #warnings, 0 }
end
for player_name, warnings in pairs(user_script_warnings) do
if not rtn[player_name] then
rtn[player_name] = { 0, 0 }
end
rtn[player_name][2] = #warnings
end
Commands.print{ "expcom-warnings.list-title" }
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 }
end
rtn[player_name][2] = #warnings
end
Commands.print{'expcom-warnings.list-title'}
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}
end
end
end)
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', {'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)
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)
game.print{'expcom-warnings.cleared', action_player_name_color, by_player_name_color}
end)
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)
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)
game.print{ "expcom-warnings.cleared", action_player_name_color, by_player_name_color }
end)

View File

@@ -4,33 +4,33 @@
local Commands = require("modules.exp_legacy.expcore.commands") --- @dep expcore.commands
require("modules.exp_legacy.config.expcore.command_general_parse")
local Selection = require("modules.exp_legacy.modules.control.selection") --- @dep modules.control.selection
local SelectionConvertArea = 'ConvertArea'
local SelectionConvertArea = "ConvertArea"
--- Align an aabb to the grid by expanding it
local function aabb_align_expand(aabb)
return {
left_top = {x = math.floor(aabb.left_top.x), y = math.floor(aabb.left_top.y)},
right_bottom = {x = math.ceil(aabb.right_bottom.x), y = math.ceil(aabb.right_bottom.y)}
left_top = { x = math.floor(aabb.left_top.x), y = math.floor(aabb.left_top.y) },
right_bottom = { x = math.ceil(aabb.right_bottom.x), y = math.ceil(aabb.right_bottom.y) },
}
end
Commands.new_command('waterfill', {'expcom-waterfill.description'}, 'Change tile to water')
:register(function(player)
local inv = player.get_main_inventory()
Commands.new_command("waterfill", { "expcom-waterfill.description" }, "Change tile to water")
:register(function(player)
local inv = player.get_main_inventory()
if (inv.get_item_count('cliff-explosives')) == 0 then
return player.print{'expcom-waterfill.waterfill-cliff'}
end
if (inv.get_item_count("cliff-explosives")) == 0 then
return player.print{ "expcom-waterfill.waterfill-cliff" }
end
if Selection.is_selecting(player, SelectionConvertArea) then
Selection.stop(player)
else
Selection.start(player, SelectionConvertArea)
return Commands.success{'expcom-waterfill.entered-area-selection'}
end
if Selection.is_selecting(player, SelectionConvertArea) then
Selection.stop(player)
else
Selection.start(player, SelectionConvertArea)
return Commands.success{ "expcom-waterfill.entered-area-selection" }
end
return Commands.success
end)
return Commands.success
end)
--- When an area is selected to add protection to the area
Selection.on_selection(SelectionConvertArea, function(event)
@@ -41,10 +41,10 @@ Selection.on_selection(SelectionConvertArea, function(event)
return
end
local entities = player.surface.find_entities_filtered{area=area, name='steel-chest'}
local entities = player.surface.find_entities_filtered{ area = area, name = "steel-chest" }
if #entities == 0 then
player.print('No steel chest found')
player.print("No steel chest found")
return
end
@@ -55,21 +55,21 @@ Selection.on_selection(SelectionConvertArea, function(event)
return
end
local clf_exp = inv.get_item_count('cliff-explosives')
local clf_exp = inv.get_item_count("cliff-explosives")
for _, entity in pairs(entities) do
if clf_exp >= 1 then
if entity.get_inventory(defines.inventory.chest).is_empty() then
if (math.floor(player.position.x) ~= math.floor(entity.position.x)) or (math.floor(player.position.y) ~= math.floor(entity.position.y)) then
table.insert(tiles_to_make, {name='water-mud', position=entity.position})
table.insert(tiles_to_make, { name = "water-mud", position = entity.position })
entity.destroy()
else
player.print{'expcom-waterfill.waterfill-distance'}
player.print{ "expcom-waterfill.waterfill-distance" }
end
end
clf_exp = clf_exp - 1
inv.remove({name='cliff-explosives', count=1})
inv.remove{ name = "cliff-explosives", count = 1 }
else
break
end